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

Subscriber Error

asked 2016-04-04 15:28:38 -0600

Emilien gravatar image

updated 2016-04-07 04:28:33 -0600

ahendrix gravatar image

hi, i create a rosserial_python node with arduino which publish ultrasound data. and also, i create a node in my PC which subscribe to ultrasound data. but when i run rosrun to subscribe, i receive special characters.
can you help me please? i think that is convertion uint8_t to string but i don't know how can i do it.

UPDATE

#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;
}
edit retag flag offensive close merge delete

Comments

Better if you could put the code and what you receive. Those "special" characters.

At first look could be that the field of the message where you want to put the ultrasound data doesnt have the same type as the data itself. For example in the msg file appears as string what in reality is an array.

thepirate16 gravatar image thepirate16  ( 2016-04-04 17:43:14 -0600 )edit
1

You keep asking questions and then deleting them; even the ones that are answered. This is bad etiquette, and by constantly changing the question title you decrease the chance that someone will see and answer your question.

ahendrix gravatar image ahendrix  ( 2016-04-04 18:03:16 -0600 )edit
2

You've done this enough times and offended enough other users that I'm setting your account to moderated.

ahendrix gravatar image ahendrix  ( 2016-04-04 18:04:11 -0600 )edit

ok thank you

Emilien gravatar image Emilien  ( 2016-04-05 02:20:28 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-04-07 04:34:55 -0600

NEngelhard gravatar image

Have a look at the message definition: http://docs.ros.org/jade/api/std_msgs... You have to access the data-member.

edit flag offensive delete link more

Comments

i don't understand you. can you explain it more please?

Emilien gravatar image Emilien  ( 2016-04-07 07:07:47 -0600 )edit
1

Since the Int8 message has a member called data, you use servo_msg.data to get the data.

ahendrix gravatar image ahendrix  ( 2016-04-09 13:47:27 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-04-04 15:28:38 -0600

Seen: 588 times

Last updated: Apr 07 '16