roslaunch parameter has additional newlines when set using command=

asked 2015-10-01 03:08:45 -0600

Felix Duvallet gravatar image

I'm trying to set a ROS parameter in a launch file. The parameter is the file path to some resource, so that it can be used by the node later:

param.launch

<launch>
    <param name="filename"
     type="str"
     command="$(find param_pkg)/scripts/param.py"
     />
</launch>

The python script finds the file and prints its location:

param.py

#! /usr/bin/python
print('/path/to/file')

The python script works fine, and just prints the file location (with no additional whitespace):

$ rosrun param_pkg param.py:

/path/to/file

However, the parameter set by the launch file gets a trailing newline and some additional ticks:

$ rosparam get /filename

'/path/to/file

  '

(note the two lines.) If I set the parameter manually (value=), there are no additional ticks or whitespace: $ rosparam get filename_manual:

/path/to/file

Why is this whitespace present only when I set the roslaunch parameter by running a python command, and how can I get it to be the same value as manually setting the param value?

edit retag flag offensive close merge delete