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

topic_tools transform works in console but not in launch file

asked 2020-04-16 13:47:43 -0600

Hein Wessels gravatar image

updated 2021-10-12 09:47:06 -0600

lucasw gravatar image

Hello all!

I'm still quite new to ROS, and is getting stuck at something that is most likely a syntax error. I have a /imu topic, and I want to send the imu.orientation.y into a pid. I cannot remap the pid to look at the imu's y field. Therefore, I want to use topic_tools transform function. I can get it to work by typing it into the console, but when I attempt to put it in a launch file the 'transform' dies immediately.

I created a minimal example showing the case where it works, and where it doesn't.


Working example using console

For this case I run the following launch file

<launch>
    <node name="pub" pkg="rostopic" type="rostopic" args="pub /foo std_msgs/Float64 0.5 -r 1" />
</launch>

and then run the following command to start the transform node:

rosrun topic_tools transform /foo /bar std_msgs/Float64 'm'

To prove this works I ran the command rostopic echo \bar and the value 0.5 is printed once per second as expected.


Broken example using launch file

I run the following launch file

<launch>
    <node name="pub" pkg="rostopic" type="rostopic" args="pub /foo std_msgs/Float64 0.5 -r 1" />
    <node name="foobar" pkg="topic_tools" type="transform" args="/foo /bar std_msgs/Float64 'm'"/>
</launch>

This then throws an error upon launching showing that the foobar node died:

... logging to /home/hein/.ros/log/97930396-806f-11ea-85fc-84c5a6fcae4a/roslaunch-hein-Latitude-5500-4511.log
Checking log directory for disk usage. This may take a while.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://hein-Latitude-5500:39487/

SUMMARY
========

PARAMETERS
 * /rosdistro: melodic
 * /rosversion: 1.14.5

NODES
  /
    foobar (topic_tools/transform)
    pub (rostopic/rostopic)

auto-starting new master
process[master]: started with pid [4522]
ROS_MASTER_URI=http://localhost:11311

setting /run_id to 97930396-806f-11ea-85fc-84c5a6fcae4a
process[rosout-1]: started with pid [4533]
started core service [/rosout]
process[pub-2]: started with pid [4536]
process[foobar-3]: started with pid [4537]
ERROR: Wrong input topic (or topic field): /foo
[foobar-3] process has died [pid 4537, exit code 1, cmd /opt/ros/melodic/lib/topic_tools/transform /foo /bar std_msgs/Float64 m __name:=foobar __log:=/home/hein/.ros/log/97930396-806f-11ea-85fc-84c5a6fcae4a/foobar-3.log].
log file: /home/hein/.ros/log/97930396-806f-11ea-85fc-84c5a6fcae4a/foobar-3*.log

Looking at the log file shows the following:

[rospy.client][INFO] 2020-04-16 19:49:16,485: init_node, name[/foobar], pid[2211]
[xmlrpc][INFO] 2020-04-16 19:49:16,485: XML-RPC server binding to 0.0.0.0:0
[xmlrpc][INFO] 2020-04-16 19:49:16,486: Started XML-RPC server [http://hein-Latitude-5500:37033/]
[rospy.init][INFO] 2020-04-16 19:49:16,486: ROS Slave URI: [http://hein-Latitude-5500:37033/]
[rospy.impl.masterslave][INFO] 2020-04-16 19:49:16,486: _ready: http://hein-Latitude-5500:37033/
[rospy.registration][INFO] 2020-04-16 19:49:16,486: Registering with master node http://localhost:11311
[xmlrpc][INFO] 2020-04-16 19:49:16,486: xml rpc node: starting XML-RPC server
[rospy.init][INFO] 2020-04-16 19:49:16,586: registered with master
[rospy.rosout][INFO] 2020-04-16 19:49:16 ...
(more)
edit retag flag offensive close merge delete

Comments

It's likely there are more lines to the error you show, as what we see here is only the summary (as in: the process exited unexpectedly). It'd be very helpful to see those additional lines.

gvdhoorn gravatar image gvdhoorn  ( 2020-04-16 14:06:21 -0600 )edit

@gvdhoorn, now that you mention it, it does say ERROR: Wrong input topic (or topic field): /foo. Updated the question, and I will do some more research.

Hein Wessels gravatar image Hein Wessels  ( 2020-04-17 00:54:40 -0600 )edit

Please post a verbatim copy-paste of the entire output that appears when you roslaunch your .launch file.

gvdhoorn gravatar image gvdhoorn  ( 2020-04-17 02:03:05 -0600 )edit

Updated the question as per your request.

Hein Wessels gravatar image Hein Wessels  ( 2020-04-17 02:08:14 -0600 )edit

It's most likely related to the transform namespace bug. Link

Hein Wessels gravatar image Hein Wessels  ( 2020-04-17 02:51:56 -0600 )edit

Where are the namespaces in your example .launch files?

gvdhoorn gravatar image gvdhoorn  ( 2020-04-17 03:06:36 -0600 )edit

I didn't define any namespaces. What's shown in the question is the complete .launch file. Could that be a problem?

Hein Wessels gravatar image Hein Wessels  ( 2020-04-17 04:10:13 -0600 )edit

what is the solution?

Kansai gravatar image Kansai  ( 2021-04-14 19:20:42 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-10-11 09:29:13 -0600

lucasw gravatar image

updated 2021-10-11 09:30:38 -0600

There is a race condition that fails when roslaunching with a fresh roscore, but there is an option to avoid it --wait_for_start

https://github.com/ros/ros_comm/issue...

(it's the same code in relay_field and transform)

<?xml version="1.0"?>
<launch>
  <node name="pub" pkg="rostopic" type="rostopic" args="pub /foo std_msgs/Float64 0.5 -r 1" />
  <node name="foobar" pkg="topic_tools" type="transform" args="/foo /bar std_msgs/Float64 'm' --wait-for-start"/>
</launch>

That option really ought to be true by default.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2020-04-16 13:47:43 -0600

Seen: 934 times

Last updated: Oct 12 '21