Parameters will allow you to provide run-time settings for your nodes.

A parameter is specific to a node. (if node dies, then no parameter available.)

Parameter types: Boolean, Int, Double, String, Lists, ...

Untitled

Explore parameters

ros2 param list # give you a list of nodes and parameters per node
ros2 param get {/number_publisher} {/use_sim_time} # what is the parameter?
ros2 topic echo /number_publisher

Declare parameters

super().__init__("number_publisher")

        self.declare_parameter("test123") ## declare

It’s only declared, but there is no value yet.

ros2 run my_py_pkg number --ros-args -p test123:=3.14
# We can declare it in cli.
ros2 run my_py_pkg number_publisher --ros-args -p number_to_publish:=5 -p publish_frequency:=4.5
# Multiple arguments
ros2 param get /number test123
# Double value is: 3.14

Get parameters

super().__init__("number_publisher")

        self.declare_parameter("number_to_publish", 2) ## declare ## 2 is default.

				self.number_ = self.get_parameter("number_to_publish").value