Ask Your Question

subscriber's callback never called in c++, using morse

asked 2014-05-16 05:29:13 -0500

Ruthven gravatar image

Hi, I am running a simulation with Morse. tryin to get data from the robot with a C++ program using ROS.

The simulation is simple: a Quadrotor publishes its pose on a topic, and receives a navigation waypoint. The Morse file is:

from morse.builder import *

bee = Quadrotor()

waypoint = RotorcraftWaypoint()

#The Quadrototor is called bee
beePose = Pose()
beePose.add_stream('ros', topic='/bee/pose')

env = Environment('land-1/trees')

In the C++ program, the chatterCallback(...) is never called, while it should print the position of the Quadrorotor:

#include "ros/ros.h"
#include "geometry_msgs/Pose.h"
#include <sstream>

void chatterCallback(const geometry_msgs::Pose& msg)
        geometry_msgs::Point coord = msg.position;
        ROS_INFO("Current position: (%g, %g, %g)", coord.x, coord.y, coord.z);

int main(int argc, char **argv)
        ros::init(argc, argv, "plan_node");

 * NodeHandle is the main access point to communications with the ROS system.
        ros::NodeHandle n;

 * The advertise() function is how you tell ROS that you want to
 * publish on a given topic name.
        ros::Publisher motion = n.advertise<geometry_msgs::Pose>("/bee/waypoint", 1000);

        // subscribes to stream
        ros::Subscriber sub = n.subscribe("/bee/pose", 1000, chatterCallback);


        return 0;

While calling roswtf, I get the following error:

Static checks summary:

Found 1 warning(s).
Warnings are things that may be just fine, but are sometimes at fault

WARNING ROS_HOSTNAME may be incorrect: ROS_HOSTNAME [localhost] resolves to [::1], which does not appear to be a local IP address ['', 'a.b.c'].
Beginning tests of your ROS graph. These may take awhile...
analyzing graph...
... done analyzing graph
running graph rules...
... done running graph rules

Online checks summary:

Found 1 error(s).

ERROR The following nodes should be connected but aren't:
 * /morse->/plan_node (/bee/pose)

The weird thing is that all the nodes are running on the same computer. No network connection problems... in theory.

Finally, I get the desired data when running on another terminal:

rostopic echo /bee/pose

Any advice?


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-05-16 05:52:07 -0500

Ruthven gravatar image

updated 2014-05-16 05:54:26 -0500

Finally I found the answer.

Looking at morse initialization, there was the following message:

[WARN] [WallTime: 1400249615.593493] Could not process inbound connection: topic types do not match: [geometry_msgs/Pose] vs. [geometry_msgs/PoseStamped]{'topic': '/bee/pose', 'tcp_nodelay': '0', 'md5sum': 'e45d45a5a1ce597b249e23fb30fc871f', 'type': 'geometry_msgs/Pose', 'callerid': '/plan_node'}

So I changed the callback method:

void chatterCallback(const geometry_msgs::PoseStamped& msg)
        geometry_msgs::Point coord = msg.pose.position;
        ROS_INFO("Current position: (%g, %g, %g)", coord.x, coord.y, coord.z);

and don't forget to include:

#include "geometry_msgs/PoseStamped.h"
edit flag offensive delete link more


How to run this program? 1) first part should be copied in 2)second part in C++ then run but it gives ma 32 error in C++ and Id for kit: "Desktop" "CMakeProjectManager.DefaultCMakeTool" 10000512 in terminal

Nazeer gravatar image Nazeer  ( 2015-02-10 04:05:10 -0500 )edit

Looks like a compiler error. Have you tried re/installing Catkin?

Ruthven gravatar image Ruthven  ( 2015-10-05 12:02:59 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2014-05-16 05:29:13 -0500

Seen: 1,311 times

Last updated: May 16 '14