rosparam: Different output format on vectors
When running the same ros package on different machines, I'm facing an issue with the rosparam get
output syntax.
In most cases, I get the vector syntax, but on one machine I get the list syntax as described here.
Machine 1 (List)
user@machine1:~/foo$ rosparam get /my_grp/my_var
- 1.5
- 2.5
- 2.8
- 2.5
Machine 2 (Vector)
user@machine2:~/foo$ rosparam get /my_grp/my_var
[1.5, 2.5, 2.8, 2.5]
Since I'm parsing the output in a bash script, this difference raises further issues.
I'm running the same version of python-yaml on both machines
python-yaml/xenial,now 3.11-3build1 amd64 [installed,automatic]
ROS-kinetic-rosparam is the same:
ros-kinetic-rosparam/xenial,now 1.12.17-1xenial-20201103-022214+0000 amd64 [installed,automatic]
Furthermore, when setting a parameter on machine 1, I get a yaml warning:
user@machine1:~/foo$ rosparam set /my_grp/my_var_scalar 2
/opt/ros/kinetic/lib/python2.7/dist-packages/rosparam/__init__.py:375: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
set_param_raw(param, yaml.load(value), verbose=verbose)
What's the reason for different outputs of rosparam
? Thanks in advance
Update 2020-12-08
I've further checked the yaml by running following piece of python code on both machines
import yaml as y
print(y.__version__)
Which returns 3.11 on machine 2 and 5.1.1 on machine 2. As mentioned above the apt package is 3.1.1 on both machines. Furthermore, on machine 2, there is PyYAML installed within pip.
So, i would like to rephrase the question: Whats the correct way to define the version of python-yaml (resp. PyYAML) to be used within ROS kinetic?
just a question, why do you need to use a bash script, and cannot use a simple ROS (python) node? There it would be easy to do...
Already thought in this way, in my case running a bash script seems beneficial as I want to iterate over different parameter sets and record rosbags with them.
Added an update to the question
If you have a
pip
installed version ofPyYAML
, then it would seem to be expected the output is different between the two.If that
pip
installed version is present on thePYTHONPATH
your interpreter is going to find it.python-yaml (installed by apt) is installed in /usr/lib/python2.7/dist-packages/yaml (Location found via dpkg -L python-yaml) So putting this path at the start of PYTHONPATH helped:
Thanks.