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

ROS errors while exchanging messages with Stage

asked 2012-11-08 04:35:23 -0500

ubisum gravatar image

updated 2014-04-20 14:09:39 -0500

ngrennan gravatar image

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

edit retag flag offensive close merge delete


Can you edit your question and add the exact error that you're getting?

jbohren gravatar image jbohren  ( 2012-11-08 04:48:49 -0500 )edit

Done. And I corrected which is the error I got

ubisum gravatar image ubisum  ( 2012-11-08 04:57:31 -0500 )edit

Sorry for disorder

ubisum gravatar image ubisum  ( 2012-11-08 04:57:45 -0500 )edit

2 Answers

Sort by » oldest newest most voted

answered 2012-11-08 04:58:31 -0500

mmedvede gravatar image


geometry_msgs::Pose robot_pose = mes.pose;


geometry_msgs::Pose robot_pose = mes.pose.pose;

Check the definition of nav_msg/Odometry carefully - mes.pose is PoseWithCovariance.

edit flag offensive delete link more

answered 2012-11-08 05:13:04 -0500

ubisum gravatar image

Thanks, it worked. It was my fault ;)

edit flag offensive delete link more

Question Tools


Asked: 2012-11-08 04:35:23 -0500

Seen: 469 times

Last updated: Nov 08 '12