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

publish sevomoteur angle

asked 2016-04-05 08:40:18 -0500

Emilien gravatar image

hi, i created a program that published angle of servomotor, and also this code to subscribe to this angle:

    #include "ros/ros.h"
#include "std_msgs/Uint16.h"
int angle = 0;
void angleCallback(const std_msgs::String::ConstPtr& servo_msg)
Angle = servo_msg->angle
ROS_INFO("I turn: [%d]degree", angle
int main(int argc, char **argv)
ros::init(argc, argv, "angle_listener");
ros::NodeHandle n;
ros::Subscriber sub = n.subscribe("/servo", 1000, angleCallback);
return 0;

but i have an error in my code in fonction angleCallback. Can you help me please?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-04-05 10:05:15 -0500

NEngelhard gravatar image

You should maybe start with a C++-Tutorial.

  1. 'Angle' is not defined
  2. std_msgs/String has no "angle" member but only a 'data'-member
  3. Your ROS_INFO is not terminated so your program does not even compile.
  4. " i have an error in my code" is the WORST error description so please at least post the error message.
  5. There is a missing ';' after servo_msg->angle
edit flag offensive delete link more


While the points you mention are definitely issues, perhaps a bit more of a constructive tone would work better ;).

gvdhoorn gravatar image gvdhoorn  ( 2016-04-05 10:19:32 -0500 )edit

You are probably right. But the last posts showed a similar effort to create a meaningful question...

NEngelhard gravatar image NEngelhard  ( 2016-04-05 10:38:18 -0500 )edit

Question Tools

1 follower


Asked: 2016-04-05 08:40:18 -0500

Seen: 129 times

Last updated: Apr 05 '16