This node says Hello world every second. Then, without changing a single line of code, it says Hello earth. That's a ROS 2 parameter: a setting your node reads while it runs. Following the official ROS 2 Jazzy "Using parameters in a class (Python)" tutorial on Ubuntu 24.04, we give our own Python node its own parameter, change it from the terminal with ros2 param set, and set it from a launch file.
Along the way: parameter or topic (which one when?), declare_parameter and why the default value sets the type, reading it with get_parameter, the set_parameters reset that puts it back to world (and how to make your value stick), an optional ParameterDescriptor, the setup.py entry point and data_files for launch files, ros2 param list / get / dump, several parameters and YAML files, and the three mistakes beginners hit most.
⏱️ Chapters
0:00 Intro: Hello world → Hello earth, no code change
0:20 Why parameters?
0:46 Parameter or topic?
1:14 The plan
1:32 Create the python_parameters package
2:00 package.xml
2:15 The node: imports and class
2:37 declare_parameter (the default sets the type)
3:02 The timer
3:13 Read the parameter: get_parameter
3:31 Log it
3:44 Reset with set_parameters
4:04 main
4:15 Optional: ParameterDescriptor
4:42 setup.py entry point
5:03 Build
5:24 Run it
5:38 Change it from the console: ros2 param set
6:04 ros2 param get and dump
6:33 Why does it go back to world?
6:51 Make earth stick
7:19 Way 2: the launch file
7:48 Install the launch file (data_files)
8:13 Build and launch
8:36 Many parameters and YAML files
9:01 Three common mistakes
9:29 Recap + what's next
🔗 Official page used in this video
Using parameters in a class (Python): https://docs.ros.org/en/jazzy/Tutorials/Beginner-Client-Libraries/Using-Parameters-In-A-Class-Python.html
Previous video: implementing custom interfaces (our first C++ node).
Next video: using ros2doctor to check your setup when something goes wrong.
If you want more videos on robotics and IoT, subscribe to the channel so you don't miss the next one. 🤖
#ROS2 #ROS #Robotics #Python #JazzyJalisco #RoboticsForBeginners #IoT