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

Revision history [back]

gvdhoorn is right. You are setting up a subscriber with a callback function called cmd_msg, but cmd_msg has not been defined, further more you seem to have coded your callback function into the loop function so it would run continuously.

You'll need to define a function called cmd_msg and access the angle that the message contains as shown below:

void cmd_msg(const std_msgs::UInt16::ConstPtr& msg)
{
  int angle = msg.data;
  ...
  ...
}

Then add the rest of the code you have inside loop into this callback function.

Have a look at the publisher and subscriber example for some pointers.

Hope this helps.