ROS errors while exchanging messages with Stage
hello everyone I'm just trying to write a simple C++ client of Stage package. Just to make a test, i want to write a short code to receive some odometry data from /odom topic and print it onto screen:
#include "ros/ros.h" #include "nav_msgs/Odometry.h" #include "geometry_msgs/Pose.h" #include "geometry_msgs/Point.h" /* #include "geometry_msgs/Point" */ void chatter (const nav_msgs::Odometry mes){ geometry_msgs::Pose robot_pose = mes.pose; geometry_msgs::Point robot_point = robot_pose.position; float xCoord = robot_point.x; float yCoord = robot_point.y; float zCoord = robot_point.z; ROS_INFO("I received %f %f %f/n", xCoord, yCoord, zCoord); } int main(int argc, char **argv){ ros::init(argc,argv, "listener"); ros::NodeHandle n; ros::Subscriber sub = n.subscribe("/odom", 1000, chatter); ros::spin(); return 0; }
Sadly ROS compiler gives me an error:
/home/ubisum/fuerte_workspace/beginner/src/listener.cpp: In function ‘void chatter(nav_msgs::Odometry)’: /home/ubisum/fuerte_workspace/beginner/src/listener.cpp:8:39: error: conversion from ‘const _pose_type {aka const geometry_msgs::PoseWithCovariance_<std::allocator<void> >}’ to non-scalar type ‘geometry_msgs::Pose’ requested make[3]: *** [CMakeFiles/listener.dir/src/listener.o] Errore 1 make[3]: uscita dalla directory "/home/ubisum/fuerte_workspace/beginner/build" make[2]: *** [CMakeFiles/listener.dir/all] Errore 2 make[2]: uscita dalla directory "/home/ubisum/fuerte_workspace/beginner/build" make[1]: *** [all] Errore 2 make[1]: uscita dalla directory "/home/ubisum/fuerte_workspace/beginner/build" make: *** [all] Errore 2
Could you help me? I'm both a ROS and C++ newbie. Thanks
Can you edit your question and add the exact error that you're getting?
Done. And I corrected which is the error I got
Sorry for disorder