ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

I think I get what you are asking, but if you could edit your question to be more clear that would be nice. It sounds like you want a node that checks a sensor, increases the robot's velocity, and then publishes that velocity. I would use 2 separate functions for this. You need a callback function to read the sensor data, and a second function to increment the velocity and publish it. Then in your main function have something like

while(ros::ok())
{
  check_sensor();
  inc_vel();
  ros::spinOnce();
}

That's a really basic idea of how to do this. More complex systems require other things like using multiple threads with synchronous or asynchronous spinners. Check out the callbacks page on the wiki.