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

How can I set several parameters with a single call of rosparam?

asked 2018-05-18 10:42:33 -0500

thinwybk gravatar image

updated 2018-05-18 11:04:57 -0500

I would like to set several ROS parameters via a single call of rosparam (run in a docker container means loading from .yaml with rosparam load dump.yaml is no option for me). Can I use rosparam set <...> to get this done somehow? (The wiki cli docs probably lack something which I could use.)

I tired a single line invocation like follows but got an yaml.scanner.ScannerError:

$ rosparam set /gains "p: 1.0 i: 1.0 d: 1.0"
...
yaml.scanner.ScannerError: mapping values are not allowed here
  in "<string>", line 1, column 9:
    p: 1.0 i: 1.0 d: 1.0
        ^
edit retag flag offensive close merge delete

Comments

run in a docker container means loading from .yaml [..] is no option for me

can you explain this? As long as the master is accessible you could even run rosparam outside your container and load entire dumps.

gvdhoorn gravatar image gvdhoorn  ( 2018-05-18 11:31:52 -0500 )edit

can you explain this? I could do so. But I prefer to have the docker environment completely separated from my local workstation OS environment. And if I'd like to load dumps I'd need to handle docker volumes/mounts which I don't like to do in this case.

thinwybk gravatar image thinwybk  ( 2018-05-18 12:15:05 -0500 )edit

rosparam set /gains "{p : 1.0, i : 1.0, d : 1.0}" works just fine btw. If you post it as answer I'll accept it...

thinwybk gravatar image thinwybk  ( 2018-05-18 12:17:04 -0500 )edit

And if I'd like to load dumps I'd need to handle docker volumes/mounts which I don't like to do in this case.

use one container to run rosparam and target another container? Only volume mount (-v) would be the .yaml file containing the parameters?

gvdhoorn gravatar image gvdhoorn  ( 2018-05-18 12:29:46 -0500 )edit

Btw: you could also use rospy.set_param(..). As it's an XMLRPC call, it can be used without creating a ROS node.

I would not be surprised if you could use a bare XMLRPC call with the yaml dictionary directly. No ROS needed in that case (but I haven't tried it).

gvdhoorn gravatar image gvdhoorn  ( 2018-05-18 12:30:28 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-05-18 11:29:34 -0500

gvdhoorn gravatar image

updated 2018-05-18 12:38:00 -0500

I tired a single line invocation like follows but got an yaml.scanner.ScannerError

Probably because you're providing invalid markup: abbreviated yaml dictionaries (ie: key-val on a single line) should be structured like so:

{ p : 1.0, i : 1.0, d : 1.0 }

Note the accolades ({}) and item separators (,).


Edit: Btw: you could also use rospy.set_param(..). As it's an XMLRPC call, it can be used without creating a ROS node.

I would not be surprised if you could use a bare XMLRPC call with the yaml dictionary directly. No ROS needed in that case (but I haven't tried it). See wiki/ROS/Technical Overview - Parameter Server and wiki/ROS/Parameter Server API.

edit flag offensive delete link more

Comments

Edit: Btw: you could also use rospy.set_param(..). As it's an XMLRPC call, it can be used without creating a ROS node.

Thx. I already thought about using rospy.set_param_raw for [rospbt](https://github.com/ros-testing

thinwybk gravatar image thinwybk  ( 2018-05-18 12:48:47 -0500 )edit

I would not be surprised if you could use a bare XMLRPC call with the yaml dictionary directly.

The docs in the wiki are wrong about this. Probably I'll take the time to fix it.

thinwybk gravatar image thinwybk  ( 2018-05-22 02:43:53 -0500 )edit

I don't understand? What are they wrong about?

Note that the "Setting an entire namespace of parameters using a YAML dictionary" bit is correct: you can do it like that, but the newlines are required.

gvdhoorn gravatar image gvdhoorn  ( 2018-05-22 02:54:04 -0500 )edit

Right. sry, Had a typo when I tried it.

thinwybk gravatar image thinwybk  ( 2018-05-22 03:29:45 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2018-05-18 10:42:33 -0500

Seen: 848 times

Last updated: May 18 '18