Robotics StackExchange | Archived questions

subscribe variable in arduino

hi, i create a node arduino that publish a variable with 3 values in Int8 type, and also i create a node cpp that subscribe in the variable value. when i subscribe, i receive a value fix and different to my values with 8 numbers. what can i do please? this is my code:

    #include "ros/ros.h"
#include "std_msgs/Int8.h"
void angleCallback(const std_msgs::Int8& servo_msg)
{
ROS_INFO("I turn: [%i]", servo_msg);
}
int main(int argc, char **argv)
{
ros::init(argc, argv, "angle_listener");
ros::NodeHandle n;
ros::Subscriber sub = n.subscribe("/servo", 1000, angleCallback);
ros::spin();
return 0;
}

but when i run: rosrun echo /servo, i receive my values

Asked by Emilien on 2016-04-06 08:15:08 UTC

Comments

"what can i do please?" You could show your code : )

Asked by NEngelhard on 2016-04-06 08:55:38 UTC

ok i add my code.

Asked by Emilien on 2016-04-06 09:19:58 UTC

This is a duplicate of http://answers.ros.org/question/230978/subscribe-node/ . Please follow the comments and update your existing question instead of asking a new question.

Asked by ahendrix on 2016-04-06 14:03:39 UTC

Answers