0
$\begingroup$

Rosanswers logo

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.


Originally posted by Orhan on ROS Answers with karma: 856 on 2016-04-27

Post score: 0


Original comments

Comment by mgruhler on 2016-04-27:
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?

Comment by naveedhd on 2016-04-27:
kindly also post the line from your source file where you are loading this param.

Comment by Orhan on 2016-04-27:
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);

Comment by naveedhd on 2016-04-27:
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.

Comment by Orhan on 2016-04-27:
Thanks! I'm trying, Please write as answer to let me marking correct answer.

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

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


Originally posted by mgruhler with karma: 12390 on 2016-04-27

This answer was ACCEPTED on the original site

Post score: 3

$\endgroup$
0
$\begingroup$

Rosanswers logo

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>

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)


Originally posted by naveedhd with karma: 161 on 2016-04-27

This answer was NOT ACCEPTED on the original site

Post score: 1


Original comments

Comment by Orhan on 2016-04-27:
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.

Comment by naveedhd on 2016-04-27:
your parameter should be /parameter_analyzer/increment

Comment by mgruhler on 2016-04-27:
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.

Comment by Orhan on 2016-04-27:
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.

Comment by Orhan on 2016-04-27:
It's getting positive values succesfully. Why? :) I'm really confused.

Comment by mgruhler on 2016-04-27:
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_sandbox/tree/test there is an example python and cpp package where this works...

Comment by Orhan on 2016-04-27:
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.

Comment by Orhan on 2016-04-27:
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.

Comment by Orhan on 2016-04-27:
Other nodes hasn't got ROS_INFO() line for looking parameter without launching amcl.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.