Ask Your Question
0

Negative values in launch file arguments

asked 2016-04-27 05:37:09 -0600

Orhan gravatar image

updated 2016-04-27 05:45:07 -0600

Hello everyone,

roslaunch can't read negative argument.

I'm launching my node via this launch file:

<launch>
    <arg name="inc" default="-0.02"/>
    <node pkg="parameter_analyzer" type="kld_err" name="parameter_analyzer" output="screen">
        <param name="increment" value="$(arg inc)"/>
    </node>
</launch>

Output:

[ INFO] [1461752716.797017994, 13371.605000000]:  INCREMENT VALUE: 0

If parameter is set to positive, output:

[ INFO] [1461752338.872513841, 13012.430000000]: INCREMENT VALUE: 0.02

Any suggestions? Thanks.

edit retag flag offensive close merge delete

Comments

1

It works for me in both hydro and indigo. Could you check your code that you are not doing something wrong while retrieving the parameter?

mgruhler gravatar imagemgruhler ( 2016-04-27 05:57:37 -0600 )edit
1

kindly also post the line from your source file where you are loading this param.

naveedhd gravatar imagenaveedhd ( 2016-04-27 06:00:57 -0600 )edit

My roslaunch's version is 1.11.19 in indigo. And there is only 3 lines: double INC; and ros::param::get("parameter_analyzer/increment", INC); and ROS_INFO("INCREMENT VALUE: %lf", INC);

Orhan gravatar imageOrhan ( 2016-04-27 06:05:58 -0600 )edit
1

By using ros::param::get() I am also recieving 0 (very small value in exponent). Using:

ros::NodeHandle n("~"); double increment; n.param<double>("increment", increment, 5.0);

you can receive negative values.

naveedhd gravatar imagenaveedhd ( 2016-04-27 06:20:52 -0600 )edit

Thanks! I'm trying, Please write as answer to let me marking correct answer.

Orhan gravatar imageOrhan ( 2016-04-27 06:25:02 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
3

answered 2016-04-27 09:18:20 -0600

mgruhler gravatar image

Alright, so the problem is most probably in this line of your code.

You use dynamic_reconfigure for your parameters, and you limit the increment param to the range [0.0, 500]. Thus, setting to positive should work, but not to negative. However, I'm not quite sure how dynamic_reconfigure reacts to parameters being not properly set from the outside...

edit flag offensive delete link more
1

answered 2016-04-27 06:32:02 -0600

naveedhd gravatar image

updated 2016-04-27 06:33:05 -0600

In your launch file:

<launch>
<arg name="inc" default="-0.02"/>
<node pkg="parameter_analyzer" type="kld_err" name="parameter_analyzer" output="screen">
    <param name="increment" type="double" value="$(arg inc)"/>
</node>

</launch>

In your source file, use:

 ros::NodeHandle nodehandle("~");
 double INC = 0.0;
 nodehandle.param<double>("parameter_analyzer/increment", INC, INC);

make sure to pass default value as 3rd argument to param() (I'm not sure for what reason If I don't pass this a double/float value here, it gives me 0)

edit flag offensive delete link more

Comments

I've just tried. Sorry, but I think the problem isn't caused by getting parameter. Because I'm setting manually via rosparam set /parameter_analyzer -0.07 but the value in parameter server changes to 0.0 when I launching the node via roslaunch.

Orhan gravatar imageOrhan ( 2016-04-27 06:45:22 -0600 )edit
1

your parameter should be /parameter_analyzer/increment

naveedhd gravatar imagenaveedhd ( 2016-04-27 07:00:02 -0600 )edit
1

This is due to the fact that when you roslaunch the launch file, the argument specified therein is still set as the parameter. You need to commount the param line in the launch file to take the parameter which is already on the parameter server.

mgruhler gravatar imagemgruhler ( 2016-04-27 07:01:53 -0600 )edit

Thanks for an answers. I've tried /parameter_analyzer/increment before too. And commenting increment values in launch file isn't helped. I've setted manually to -0.7 and started commented-launch-file, it gave 0.0 too.

Orhan gravatar imageOrhan ( 2016-04-27 07:20:29 -0600 )edit

It's getting positive values succesfully. Why? :) I'm really confused.

Orhan gravatar imageOrhan ( 2016-04-27 07:25:33 -0600 )edit
1

There must be something wrong with your code then. Please post the full code in question, otherwise it is almost impossible to debug.

Check out https://github.com/ipa-mig/ros_sandbo... there is an example python and cpp package where this works...

mgruhler gravatar imagemgruhler ( 2016-04-27 07:51:06 -0600 )edit

Thank you very much for your code. I've just executed rosrun cpp_test cpp_test_node (tried roslaunch before). It doesn't output's anything. I also looked to code, It must be write something. Now I'm trying on different computer.

Orhan gravatar imageOrhan ( 2016-04-27 08:09:10 -0600 )edit

I accidentally clonned master branch before, It runs succesfully and gets parameter. And I've just uploaded code to repo. I'm running node via roslaunch parameter_analyzer laser_lambda_short.launch.

Orhan gravatar imageOrhan ( 2016-04-27 08:48:33 -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: 2016-04-27 05:37:09 -0600

Seen: 361 times

Last updated: Apr 27 '16