0
$\begingroup$

Rosanswers logo

Is there a tool that can take a complex message from one topic, then compose a new message from some of its fields and publish it on another topic?

For instance, JTCartesianController exposes rather complex state, where I need only state/x field of type geometry_msgs::PoseStamped. So such magic tool should do something like:

$ rosmagic /jt_cart_controller/state/x /robot_pose

rostopic is able to echo 'subtopics', but there is no way to republish them.

topic_tools relay does not work with subtopics either.

Any ideas?

Thanks


Originally posted by Boris on ROS Answers with karma: 3060 on 2013-03-23

Post score: 2

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

I found the approach of writing echo "rostopic echo" output to yaml file, optionally changing it and republishing using "rostopic pub" to be fast and work very well. See the "YAML data file" section of the rostopic pub documentation. You can easily change data or also cut/paste submessages out of a composed message and republish them this way.


Originally posted by Stefan Kohlbrecher with karma: 24361 on 2013-03-23

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by Boris on 2013-03-23:
Thanks! It also works fine with the pipes, i.e. I can simply do rostopic echo /eef_pose/pose/position | rostopic pub /xyz_position geometry_msgs/Vector3. However I was unable to find any generic command-line tools for parsing YAML, so looks like the scripting is unavoidable...

$\endgroup$
0
$\begingroup$

Rosanswers logo

Here is my first attempt on Python code.

The recompose.py script allows to take a message of any(?) complexity and generate another message based on given format. The format of new message is specified by YAML string, where the values of elements are the paths (delimited by /) to a data in input message.

The most valuable use case for myself is to take a complex message like gazebo_msgs/ContactsState and combine geometry_msgs/WrenchStamped. Main problem here is that we need both std_msgs/Header and geometry_msgs/Wrench to be combined in a new message. However these fields are spread across the ContactsState.

So, this issue can be solve with the provided script as follows:

rostopic echo /gazebo_bumper | recompose.py "{header: header, wrench: 'states[0]/total_wrench'}"

Maybe I'm reinventing the wheel, but I was unable to find a ready to use solution so far.

Hope it can be useful for others.


Originally posted by Boris with karma: 3060 on 2013-04-04

This answer was NOT ACCEPTED on the original site

Post score: 3

$\endgroup$

Your Answer

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