Ask Your Question
0

Arrays Ros Launch File

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

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 -0600

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 imagekramer ( 2015-03-28 17:40:29 -0600 )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 imageatp ( 2015-03-28 19:17:20 -0600 )edit
1

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 imageaak2166 ( 2015-03-28 19:31:25 -0600 )edit

Thanks, using rosparam made it work.

atp gravatar imageatp ( 2015-03-28 19:38:04 -0600 )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

Stats

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

Seen: 4,038 times

Last updated: Mar 28 '15