0
$\begingroup$

Rosanswers logo

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()
bee.append(waypoint)
waypoint.add_stream('ros')

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

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

        ros::spin();

        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 ['127.0.0.1', '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?

Thanks


Originally posted by Ruthven on ROS Answers with karma: 26 on 2014-05-16

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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"

Originally posted by Ruthven with karma: 26 on 2014-05-16

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by Nazeer on 2015-02-10:
How to run this program?

  1. first part should be copied in file_name.py. 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

Comment by Ruthven on 2015-10-05:
Looks like a compiler error. Have you tried re/installing Catkin?

$\endgroup$

Your Answer

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