The article directories

    • (1) background
    • (2) the premise
    • (3) task
      • Ⅰ preparation
      • ⅱ ros2 param command
        • ros2 param list
        • ros2 param get
        • ros2 param set
          • Dashing version
          • Eloquent version
        • Ros2 param dump (Dashing does not have this command)
        • Loading the configuration file (currently not successfully in Dashing version…)
    • (4) summarize

(1) background

Parameters are the configuration values of each node. Configuration files are in the format of YAML. They can be integers, floats, booleans, strings, and lists. All parameters are dynamically reconfigurable and are built on ROS 2 services.

(2) the premise

  • Install ros2
  • Configure the environment
  • Put the turtle

(3) task

Ⅰ preparation

Start the turtle command:

ros2 run turtlesim turtlesim_node
ros2 run turtlesim turtle_teleop_key
Copy the code

ⅱ ros2 param command

ros2 param list

Display parameter List

usage: ros2 param list [-h] [--spin-time SPIN_TIME] [--include-hidden-nodes]
                       [--param-prefixes PARAM_PREFIXES [PARAM_PREFIXES ...]]
                       [node_name]

Output a list of available parameters

positional arguments:
  node_name             Name of the ROS node

optional arguments:
  -h, --help            show this help message and exit
  --spin-time SPIN_TIME
                        Spin time in seconds to wait fordiscovery (only applies when not using an already running daemon) --include-hidden-nodes Consider hidden nodes as well --param-prefixes PARAM_PREFIXES [PARAM_PREFIXES ...]  Only list parameters with the provided prefixesCopy the code

The command

ros2 param list
Copy the code

ros2 param get

Gets the value of the specified argument

Command:ros2 param get <node_name> <parameter_name>

Example:ros2 param get /turtlesim background_g

ros2 param set

To set the values of specified parameters, run the ros2 param set

command. Ros2 param set/turtlesim background_r 150 dashing version now no, set the color did not change, the value is changed eloquent version can be change color

Dashing version

Eloquent version

Ros2 param dump (Dashing does not have this command)

Use the Eloquent version command

ros2 param dump <node_name>
Copy the code

To save the current /turtlesim configuration, run:

ros2 param dump /turtlesim
Copy the code

Loading the configuration file (currently not successfully in Dashing version…)

Use the eloquent version command:

ros2 run <package_name> <executable_name> --ros-args --params-file <file_name>
Copy the code

Example:

ros2 run turtlesim turtlesim_node --ros-args --params-file ./turtlesim.yaml
Copy the code

(4) summarize

The node parameters can be GET and set, but the Dasing version is a bit problematic, eloquent as well