ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
You have a 5-second delay in your main loop, which means that you're only calling nh.spinOnce every 5 seconds.
nh.spinOnce()
is where ROS processes incoming messages and handles callbacks, so calling it once every 5 seconds means that you'll only process the incoming serial data and update the PWM values once every 5 seconds (assuming that your incoming serial buffers don't overflow in that time)
You should probably restructure your code so that you either use a small or no loop delay, and instead trigger your leak sensor check by checking against the system clock (millis()
) or using a timer.