Ask Your Question

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

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


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

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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


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

Seen: 5,670 times

Last updated: Mar 28 '15