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

Passing msg data from Python to C++

asked 2013-12-19 10:09:22 -0500

Phorce gravatar image

updated 2014-01-28 17:18:52 -0500

ngrennan gravatar image

Hey,

I have a topic written in Python, inside that workspace I have two message files:

Msg1

Header header
geometry_msgs/Vector3 direction
geometry_msgs/Vector3 normal
geometry_msgs/Point palmpos
geometry_msgs/Vector3 ypr

Msg2

Header header

float64[3] hand_direction
float64[3] hand_normal
float64[3] hand_palm_pos
float64 hand_pitch
float64 hand_roll
float64 hand_yaw

If I therefore do: std_msgs/Header header I get the information. The problem being is that now I'm using C++ to write another topic to subscribe to this. I don't know what to put inside of the callback function, for example:

void callback(const [here]& msg)
{

}

Since when I'm using the Point2Cloud I can use the following:

void callback(const sensor_msgs::PointCloud2Ptr& msg)
{
    // Blah
}

COuld anyone please tell me what I should therefore use?

edit retag flag offensive close merge delete

Comments

1

Have you tried your_package::Msg1Ptr?

demmeln gravatar image demmeln  ( 2013-12-19 10:32:21 -0500 )edit

Why do you have two different messages that seem to contain the same data?

dornhege gravatar image dornhege  ( 2013-12-20 00:07:14 -0500 )edit

1 Answer

Sort by » oldest newest most voted
3

answered 2013-12-21 01:11:17 -0500

demmeln gravatar image

If messages are defined in the package my_package, then you would use

void callback(const my_package::Msg1ConstPtr& msg)

and ensure that you have a

#include <my_package/Msg1.h>

at the beginning.

Those look like the leap_motion messages; to use those include "leap_motion/leap.h" and "leap_motion/leapros.h" and the use leap_motion::leapConstPtr or leap_motion::leaprosConstPtr.

edit flag offensive delete link more

Comments

I know that using a Nodelet would be more memory efficient, but it's not supported for nodes written in Python. Do you believe to that writing the point cloud data to disk (as a binary file) and just passing a simple message flag for the receiver node to read such a file is any better (speed/mem)?

ubuntuslave gravatar image ubuntuslave  ( 2016-10-28 16:47:41 -0500 )edit

Is this related to the above question or my answer? I guess you should open a new question. My answer to you: You will probably have to measure it to find out which is more efficient. But I would first make sure that this is actually a bottleneck for you...

demmeln gravatar image demmeln  ( 2016-10-31 06:35:53 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2013-12-19 10:09:22 -0500

Seen: 900 times

Last updated: Jan 28 '14