0
$\begingroup$

Rosanswers logo

Hello, I'm trying to write a ROS subscriber to subscribe to some of the data from the kinect sensor on a turtlebot. I started by copying the subscriber part of the tutorial here: h t t p : / / w i k i . r o s . o r g / R O S / T u t o r i a l s / W r i t i n g P u b l i s h e r S u b s c r i b e r % 2 8 c % 2 B % 2 B % 2 9, and then copying and modifying the various parts of the program to fit the topics that I'm trying to subscribe to. For example, one of the topics I'm trying to subscribe to is /odom, and my code for this part is as follows: //(outside the main class) void blabberingEavesdropper(const std_msgs::String::ConstPtr& msg) //modification of the chatterCallback function { ROS_INFO("I heard: [%s]", msg->data.c_str()); } //(inside the main class) ros::Subscriber odomSub = n.subscribe("/odom", 1000, blabberingEavesdropper);

When I catkin_make, the node compiles without errors, but then when I start up the turtlebot (turn it on as well as run minimal.launch and 3dsensor.launch), I get the following error (at least for the /odom part): [ERROR] [1392750332.677269274]: Client [/subscriber] wants topic /odom to have datatype/md5sum [std_msgs/String/992ce8a1687cec8c8bd883ec73ca41d1], but our version has [nav_msgs/Odometry/cd5e73d190d741a2f92e81eda573aca7]. Dropping connection.

Since I get a similar error message for each topic, and they all say that the subscriber wants the topic to have the same data type (std_msgs/String/some_random_number), I think my problem is with the chatterCallBack functions (renamed blabberingEvasedropper). I can't figure out exactly what to put in the arguments that will not cause this error, and that won't cause errors when I try to catkin_make my program. My goal is just to have the blabberingEvasedropper function print out the message it received on the screen. Anyone know how to do this?


Originally posted by mysteriousmonkey29 on ROS Answers with karma: 170 on 2014-02-18

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

try this:

 void blabberingEavesdropper(nav_msgs::Odometry& msg)
    { 
          ROS_INFO("%f",msg.pose.position.x);
    }

for subscribe the laser scanner data:

void laser(const sensor_msgs::LaserScan& msg)
{
    for(int i=0;i<msg.ranges.size();i++)
        ROS_INFO("RANGES[%d]=%f",i,msg.range[i]);
}

Originally posted by Hamid Didari with karma: 1769 on 2014-02-19

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by mysteriousmonkey29 on 2014-02-20:
Ok cool, I did that and it worked. However, now I'm trying to extrapolate this solution to the others topics, and again I'm running into problems. Right now I have:

void blabberingEavesdropperLaserScan(const sensor_msgs::LaserScan scanner) { for (r=0;r++;r<=length(scan.ranges)) { ROS_INFO("Ranges[%d]: %f", r,scan.ranges(r); } for (i=0;i++;i<=length(scan.intensities)) { ROS_INFO("Intensities[%d]: %f", i,scan.intensities(i)); } }

(sorry, don't know how to use code tags here), but when I try to compile, ros tells me that 'sensor_msgs' does not name a type.

Comment by mysteriousmonkey29 on 2014-02-24:
Great, that worked again, thank you!

Comment by bit-pirate on 2014-03-30:
Looks like your problem has been solver. Hence, please select this answer (checker symbol) thereby marking your question as anwered.

$\endgroup$

Your Answer

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