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

param server C++ lists

asked 2012-01-13 01:20:03 -0500

narcispr gravatar image

updated 2014-01-28 17:11:07 -0500

ngrennan gravatar image

I'm defining config vectors through the param server using yaml files:

sample: velocity_controller/velocity_max: [0.3, 0.2, 0.2, 0.0, 0.0, 0.5]

If I want to parse these vectors from a python node I use this code:

_velocity_max = array( rospy.get_param("velocity_controller/velocity_max") )

However, in C++, using the ros::param::getCached() I'm only able to parse the following types: string, int, double, bool or XmlRpcValue.

How I can import my values into a std::vector<double> ?

Thank you!

edit retag flag offensive close merge delete

4 Answers

Sort by ยป oldest newest most voted
4

answered 2012-01-13 01:50:57 -0500

AHornung gravatar image

You need to convert the lists yourself from XmlRpcValue, see http://www.ros.org/wiki/roscpp/Overview/Parameter%20Server#Retrieving_Lists

edit flag offensive delete link more

Comments

Thank you! I can't understand how I skip this example :)
narcispr gravatar image narcispr  ( 2012-01-16 02:19:09 -0500 )edit
5

answered 2014-05-21 09:35:40 -0500

jbohren gravatar image

updated 2014-05-21 09:56:43 -0500

In ROS groovy and forward you can now get vectors and dictionaries of primitives and strings without having to use the XmlRpc API: https://github.com/ros/ros_comm/pull/279

See the unit tests for examples, but it works like you'd expect it to work: https://github.com/ros/ros_comm/blob/...

I've updated the wiki doc here: http://wiki.ros.org/roscpp/Overview/P...

edit flag offensive delete link more

Comments

Thanks for updating the wiki Jon. This API addition never got publicized enough, and addresses an important pain point in the roscpp API.

Adolfo Rodriguez T gravatar image Adolfo Rodriguez T  ( 2014-05-21 22:01:26 -0500 )edit
1

answered 2012-01-13 01:51:21 -0500

dornhege gravatar image

Specifically for lists the param server documentation has a code example.

edit flag offensive delete link more
1

answered 2012-01-13 01:25:09 -0500

DimitriProsser gravatar image

Give my answer to this question a look. It allows you to look up parameters into a map. I use it to build an array of strings, but you could easily just use doubles instead.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-01-13 01:20:03 -0500

Seen: 7,948 times

Last updated: May 21 '14