ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

servo controller publisher

asked 2016-05-03 17:25:00 -0600

Emilien gravatar image

updated 2016-05-04 02:46:59 -0600

gvdhoorn gravatar image

hi, i create a subscribe sevo controller like this tutorial wiki/rosserial_arduino/Tutorials/Servo Controller and i want to create a publisher on my PC. i try with this code, but it doesnt work. could you help me please?

  int main(int argc, char **argv)
        ros::init(argc, argv, "servo_publisher");
        ros::NodeHandle n;
        ros::Publisher servo_pub = n.advertise<std_msgs::UInt16>("servo", 1000);
        ros::Rate loop_rate(10);
        int count = 0;
            std_msgs::UInt16 cmd_msg;
   = 10;
        return 0;
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-05-04 04:36:53 -0600

mgruhler gravatar image

This should be a ros::spinOnce(); instead of ros::spin();

ros::spin() is spinning continuously and thus you should only receive the very first message.

Check out the wiki for more info.

edit flag offensive delete link more


thank you very much

Emilien gravatar image Emilien  ( 2016-05-04 05:03:09 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2016-05-03 17:25:00 -0600

Seen: 130 times

Last updated: May 04 '16