the last task of the rosject for the course is to call an action client node this way:
ros2 run nav2_project go_to_pose --ros-args --params-file spot-list.yaml -p spot_name:=corner1
I’ve tried to search it and I tried many codes but I wasn’t able to do it correctly, this topic is neither covered in this course material nor in the prerequisites
The basic way to create parameters for a ROS2 node will be as follows:
# this is a yaml document - this line can be removed #
ros2_node_name: # this is the name of your ros2 program's node
ros__parameters: # this is a necessary line - it has 2 underscores
param1: value # direct parameter
param2: value # direct parameter
param3: # parameter with sub-parameters
param3param1: value # sub-parameter
param3param2: value # sub-parameter
You need to make sure that this yaml config file is called in your launch program when the node starts.
Once the node has started and the parameters file is loaded, You can then do: ros2 param list on a terminal. You should then see the following in your output:
. # other ros2 nodes
/your_ros2_node_name:
param1
param2
param3
. # other ros2 nodes
Let me know if this helped you and/or if you need more assistance.
To pass ROS2 arguments to a program and access them, you need to add two lines for each of the parameter.
So, in your program go_to_pose, inside the __init__ function, you need to add the following lines:
self.declare_parameter(name="your-param-name")
self.param = self.get_parameter(name="your-param-name").value
# so the lines for "params-file" and "spot-name" will be
self.declare_parameter(name="params-file")
self.params_file = self.get_parameter(name="params-file").value
self.declare_parameter(name="spot-name")
self.spot_name = self.get_parameter(name="spot-name").value
Add these lines after calling the super class, that is, after the line super().__init__("node_name").
I hope this helps. Let me know if you need more clarity.