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

Revision history [back]

The problem is you never service the callbacks. This only happens when you do a spin call.

However, you are looping without calling spin.

Thus, instead of:

while (ros::ok())
{
    ROS_INFO("This is x: %.2f", moverobot.x);
}
loop_rate.sleep();
ros::spin();

You need to have

while (ros::ok())
{
    ROS_INFO("This is x: %.2f", moverobot.x);
    loop_rate.sleep();
    ros::spinOnce();
}

Note: spin() is ´looping itself, thus the call to spinOnce here.

See also: http://wiki.ros.org/roscpp/Overview/Callbacks%20and%20Spinning