Set node parameter in launch file
Hi
I was trying to run a node through launch file and set its node parameter. The correspond launch file code:
<node pkg="hector_quadrotor_demo" type="uav1_pathplan" name="uav1_pathplan" args="-d $(find hector_quadrotor_demo)/src/uav1_pathplan.cpp">
<param name="ref.x" type="double" value="7.0" />
<param name="ref.y" type="double" value="-8.0"/>
<param name="ref.z" type="double" value="4.0" />
When I start the launch file, the node just didn't receive parameter values.
In my node files,
ros::init(argc, argv, "uav1_pathplan");
ros::NodeHandle n;
destination[1]=ref.x;
destination[2]=ref.y;
destination[3]=ref.z;
I just want the node can read "ref" to "destination[]". Then I can do further calculation. I'm not sure what's wrong.
Any advice appreciated. Glen
Do "rosparam list" - can you see the parameters? The NodeHandle might just be looking in the wrong namespace.
yes, I can read the parameter values through "rosparam list". Then, should I modify anything in my .cpp file?
Whenever you load them in with your NodeHandle you need to include their namespace. If in "rosparam list" it says "uav1_pathplan/ref.x" you need to do loadParam("uav1_pathplan/ref.x").
No you should use a private node handle instead.
Do you mean use: loadParam("uav1_pathplan/ref.x") in .cpp file? But function loadParam() is not declared yet.