0
$\begingroup$

Rosanswers logo

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;
}

Originally posted by Emilien on ROS Answers with karma: 167 on 2016-04-04

Post score: 0


Original comments

Comment by thepirate16 on 2016-04-04:
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.

Comment by ahendrix on 2016-04-04:
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.

Comment by ahendrix on 2016-04-04:
You've done this enough times and offended enough other users that I'm setting your account to moderated.

Comment by Emilien on 2016-04-05:
ok thank you

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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


Originally posted by NEngelhard with karma: 3519 on 2016-04-07

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by Emilien on 2016-04-07:
i don't understand you. can you explain it more please?

Comment by ahendrix on 2016-04-09:
Since the Int8 message has a member called data, you use servo_msg.data to get the data.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.