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

Arrays Ros Launch File

asked 2015-03-28 16:38:56 -0500

atp gravatar image

How can I get a list of values from a ROS launch file? My launch file includes the following line:

<param name="workspace" value="[0.55, 0.9, -0.4, 0.4, -0.25, 2]" />

In C++, I try loading that array, but it does not work (the variable workspace just always gets set to the constant WORKSPACE)

std::vector<double> workspace;
node.param("workspace", workspace, std::vector<double>(WORKSPACE, WORKSPACE + sizeof(WORKSPACE) / sizeof(WORKSPACE[0])));
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-03-28 17:34:17 -0500

aak2166 gravatar image

I assume node is your NodeHandle object? Why use that notation rather than node.getParam("workspace", workspace) ?

edit flag offensive delete link more

Comments

This is correct (as far as I know) -- vectors and maps both require the getParam call. See the Parameter Server Overview wiki.

kramer gravatar image kramer  ( 2015-03-28 17:40:29 -0500 )edit

I have tried getParam but it does not get the value from the launch file. Is the syntax in the launch file correct?

atp gravatar image atp  ( 2015-03-28 19:17:20 -0500 )edit
2

Can you query the parameter with rosparam get /workspace ? Otherwise another way to set the parameter is <rosparam param="workspace"> [0.55, 0.9, -0.4, 0.4, -0.25, 2]</rosparam>. The param tag will default any value that isn't obviously a boolean, int, or double to a string.

aak2166 gravatar image aak2166  ( 2015-03-28 19:31:25 -0500 )edit

Thanks, using rosparam made it work.

atp gravatar image atp  ( 2015-03-28 19:38:04 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2015-03-28 16:38:56 -0500

Seen: 7,074 times

Last updated: Mar 28 '15