๐ Learning Objectives
By the end of this week, you will master:
- Parameter server configuration for intelligent robot behavior
- Dynamic reconfiguration at runtime without restarting nodes
- Python launch files for complex multi-node systems
- Multi-node orchestration and coordination
- RQT tools for parameter visualization and management
โ๏ธ 1. Parameter Server for Intelligent Robot Configuration
What are ROS2 Parameters?
Parameters are configuration values that can be set for ROS2 nodes without recompiling code. They enable dynamic behavior modification and are essential for creating flexible, configurable robotic systems.
Parameter Types in ROS2
| Type | Description | Example |
|---|---|---|
bool |
Boolean values | enable_safety: true |
int |
Integer numbers | detection_threshold: 100 |
double |
Floating-point numbers | max_speed: 2.5 |
string |
Text values | robot_name: "MyRobot" |
array |
Lists of values | waypoints: [1.0, 2.0, 3.0] |
Step-by-Step: Building Your First Parameterized Node
- Step 1: Simple node with one parameter
- Step 2: Add multiple parameters
- Step 3: Add parameter validation
- Step 4: Add runtime reconfiguration
๐ Step 1: Your First Parameter
Let's start with the simplest possible parameterized node - a robot that can change its speed.
๐งช Test Step 1
Run with default value:
Expected output:
Run with custom value:
Expected output:
๐ Step 2: Multiple Parameters with Descriptions
Now let's add more parameters and make them self-documenting.
๐งช Test Step 2
Run with multiple parameters:
Check parameter descriptions:
Expected output:
๐ Step 3: Add Parameter Validation
Let's add validation to prevent invalid values that could damage the robot.
๐งช Test Step 3 - Validation
Test 1: Try to set invalid speed (should fail)
Expected output:
Test 2: Set valid speed (should succeed)
Expected output:
๐ Step 4: Complete Robot with Runtime Reconfiguration
Finally, let's create a complete robot that responds to sensor data and runtime parameter changes.
Setting Parameters via Command Line
Using YAML Configuration Files
๐ฏ Practice Exercise
Create a node with the following parameters:
- Robot name (string)
- Maximum speed (double, 0.1 to 5.0 m/s)
- Turn rate (double, in rad/s)
- Enable autonomous mode (boolean)
Test changing parameters at runtime using ros2 param set
๐ 2. Python Launch Files for Complex Systems
Why Launch Files?
Launch files allow you to start multiple nodes with specific configurations in a single command. They're essential for complex robotic systems that require coordination between many components.
Benefits of Launch Files:
- Start multiple nodes simultaneously
- Set parameters for each node
- Configure remappings and namespaces
- Manage node dependencies and lifecycle
- Create reusable system configurations
Benefits of Launch Files:
- Start multiple nodes simultaneously
- Set parameters for each node
- Configure remappings and namespaces
- Manage node dependencies and lifecycle
- Create reusable system configurations
- Step 1: Launch a single node
- Step 2: Launch with parameters
- Step 3: Launch multiple nodes
- Step 4: Use YAML configuration files
- Step 5: Add launch arguments for flexibility
๐ Step 1: Your First Launch File
Let's create the simplest possible launch file that starts one node.
๐งช Test Step 1
Expected output:
๐ Step 2: Launch with Parameters
Now let's add parameters to configure the node at startup.
๐งช Test Step 2
Expected output:
๐ Step 3: Launch Multiple Nodes
Let's launch multiple nodes that work together.
๐งช Test Step 3
Expected output:
๐ Step 4: Using YAML Configuration Files
For complex configurations, it's better to use YAML files.
๐งช Test Step 4
Important: First, install the config file in your package's setup.py:
Then rebuild and launch:
๐ Step 5: Launch Arguments for Flexibility
The most powerful feature: allow users to customize the launch without editing files.
๐งช Test Step 5
Test 1: Use default values
Test 2: Override with custom values
Test 3: See available arguments
Expected output:
Basic Python Launch File Structure
Advanced Multi-Node Launch File
Launch File with Environment Configurations
Running Launch Files
basic_launch.py- Simple single-node launchessystem_launch.py- Complete system with multiple nodessimulation_launch.py- Simulator + robot systemhardware_launch.py- Real robot deployment
External Lab 1
External Lab 3
External Lab 4
๐ 3. Dynamic Reconfiguration at Runtime
What is Dynamic Reconfiguration?
Dynamic reconfiguration allows you to change node parameters while the system is running, without restarting nodes. This is crucial for tuning robot behavior in real-time.
- Tuning PID controller gains while robot is running
- Adjusting sensor thresholds based on environment
- Enabling/disabling features on-the-fly
- Switching between operational modes
Implementing Parameter Callbacks
Parameter Services
ROS2 provides services for parameter manipulation that can be called programmatically:
๐๏ธ 4. RQT Tools for Parameter Management
What is RQT?
RQT is a Qt-based framework for GUI development in ROS. It provides various plugins for visualization, debugging, and runtime parameter management.
What is RQT?
RQT is a Qt-based framework for GUI development in ROS. It provides various plugins for visualization, debugging, and runtime parameter management.
- Step 1: Launch and explore rqt_reconfigure
- Step 2: Visualize data with rqt_plot
- Step 3: Monitor system with rqt_graph
- Step 4: Debug with rqt_console
- Step 5: Create a custom dashboard
๐ Step 1: Dynamic Reconfiguration with rqt_reconfigure
Scenario: You have a robot running and want to tune its speed in real-time without restarting.
What You'll See:
- Left Panel: List of nodes with parameters (look for /simple_robot)
- Right Panel: Interactive controls for each parameter:
- Speed: Slider (0.1 - 5.0)
- Robot Name: Text field
- Enable Safety: Checkbox
๐ฏ Try This:
- Move the speed slider to 3.0
- Watch the robot's terminal - you should see:
[INFO] โ Speed updated to 3.0 m/s - Try setting speed to 10.0 (should fail validation)
- You'll see an error:
[ERROR] Speed must be between 0.1 and 5.0
๐ Step 2: Plotting Data with rqt_plot
Scenario: You want to visualize how your robot's speed changes over time.
First, let's create a simple node that publishes data to plot:
How to Use rqt_plot:
- In the topic field at the top, type:
/robot_speed/data - Click the + button (or press Enter)
- You should see a real-time sine wave graph!
- Tip: Right-click the graph for options like auto-scroll and zoom
๐ฏ Experiment:
- Add multiple topics to compare them
- Pause the plot to examine specific values
- Save the plot as an image
๐ Step 3: System Visualization with rqt_graph
Understanding the Graph:
- Circles/Ovals: Represent nodes
- Arrows: Show topic connections (publishers โ subscribers)
- Rectangles: Represent topics
๐ฏ Try Different Views:
- Nodes only: Shows simplified node connections
- Nodes/Topics (all): Shows complete system topology
- Nodes/Topics (active): Shows only active connections
Debugging Tip: If your nodes aren't communicating, use this to verify:
- Are both nodes visible?
- Is there an arrow connecting them?
- Are the topic names correct?
๐ Step 4: Debugging with rqt_console
Using rqt_console Effectively:
Filter by Severity:
- DEBUG: Detailed diagnostic information
- INFO: Normal operational messages
- WARN: Warning messages (not errors)
- ERROR: Error conditions
- FATAL: Critical failures
๐ฏ Practice Exercise:
- Set severity filter to "WARN" or higher
- In another terminal, try to set an invalid parameter:
ros2 param set /simple_robot speed 100.0
- Watch the ERROR message appear in rqt_console
- Click on the message to see full details
Search Feature:
- Use the search box to filter messages by keyword
- Example: Search for "speed" to see all speed-related logs
๐ Step 5: Create Your Custom Dashboard
Building Your Dashboard:
Step-by-Step:
- Add Parameter Plugin:
- Plugins โ Configuration โ Dynamic Reconfigure
- Add Console:
- Plugins โ Logging โ Console
- Add Plot:
- Plugins โ Visualization โ Plot
- Add Node Graph:
- Plugins โ Introspection โ Node Graph
- Arrange Windows:
- Drag plugin tabs to split the screen
- Resize each panel as needed
- Save Your Layout:
- Perspectives โ Save Perspective โ "my_robot_dashboard"
Load Saved Layout:
โ Complete RQT Workflow Example
Here's how professionals use RQT for robot development:
- Launch your robot system
- Open your custom RQT dashboard with all plugins
- Monitor logs in rqt_console (bottom left)
- Watch system topology in rqt_graph (bottom right)
- Tune parameters with rqt_reconfigure (top right)
- Visualize results in rqt_plot (top left)
- Debug issues by correlating logs, parameters, and data
Key RQT Tools for Parameters
The most important tool for runtime parameter adjustment with a user-friendly GUI.
Features:
- Real-time parameter adjustment with sliders and input fields
- Automatic detection of parameter types and constraints
- Visual feedback of parameter changes
- Save/load parameter configurations
Plot parameter values and topic data in real-time.
Visualize the ROS2 computation graph showing nodes, topics, and their connections.
Useful for understanding system architecture and debugging communication issues.
View and filter log messages from all nodes in one place.
Features:
- Filter messages by severity (DEBUG, INFO, WARN, ERROR, FATAL)
- Search and filter by node name or message content
- Highlight specific message patterns
- Export logs to file
GUI for manually controlling robot movement.
Provides sliders for linear and angular velocity control, publishing to /cmd_vel topic.
Complete RQT Interface
Perspectives โ Save Perspective โ "my_robot_debug"
Creating Custom RQT Plugin (Advanced)
๐ฏ Hands-on Project 6.1: Configurable Intelligent Robot System
Project Overview
Build a complete configurable robot system with multiple nodes, runtime parameter tuning, and environment-specific configurations.
๐ฏ Hands-on Project 6.1: Configurable Intelligent Robot System
Project Overview
Build a complete configurable robot system with multiple nodes, runtime parameter tuning, and environment-specific configurations.
๐ Complete Step-by-Step Guide
Follow this detailed walkthrough to complete the project successfully. Each step builds on the previous one.
๐จ Detailed Implementation Walkthrough
Phase 1: Project Setup (15 minutes)
Step 1.1: Create ROS2 Package
Step 1.2: Create Directory Structure
Step 1.3: Update setup.py
Edit setup.py and add:
Phase 2: Main Robot Node (30 minutes)
Step 2.1: Create robot_node.py
This is your main navigation node with full parameter support.
Step 2.2: Test the Robot Node
Phase 3: Configuration Files (20 minutes)
Step 3.1: Create Indoor Configuration
Step 3.2: Create Other Environment Configs
Create similar files for each environment:
outdoor_config.yaml- Higher speeds, larger distanceswarehouse_config.yaml- Medium settings, optimized for structured environmentcompetition_config.yaml- Maximum performance, minimal safety
Phase 4: Launch Files (25 minutes)
Step 4.1: Create Main Launch File
Step 4.2: Test the Launch File
Phase 5: Testing & Validation (20 minutes)
๐งช Complete Testing Checklist
Test 1: Basic Functionality
Test 2: Parameter Changes
Test 3: RQT Integration
Test 4: Environment Switching
Requirements
1. Parameterized Robot Node
Create a robot node with the following configurable parameters:
- max_speed (double): Maximum linear velocity (0.1 - 5.0 m/s)
- safety_distance (double): Minimum obstacle clearance (0.1 - 2.0 m)
- detection_threshold (int): Sensor detection sensitivity (0 - 255)
- turn_rate (double): Maximum angular velocity (0.1 - 3.0 rad/s)
- enable_safety (bool): Enable/disable safety features
- robot_name (string): Robot identifier
2. Multi-Node Launch System
Implement a launch file that starts:
- Main robot navigation node
- Sensor processing node
- Safety monitor node
- Telemetry publisher node
All nodes should load parameters from a centralized YAML configuration file.
3. Runtime Parameter Tuning
- Implement parameter validation callbacks
- Support dynamic reconfiguration without node restart
- Log all parameter changes with timestamps
- Provide parameter bounds checking
4. Configuration Profiles
Create configuration files for different environments:
- Indoor: Low speed, high safety
- Outdoor: Medium speed, moderate safety
- Warehouse: Optimized for structured environment
- Competition: Maximum performance
Implementation Steps
Create intelligent_robot/robot_node.py with full parameter support and validation.
Include:
- Parameter declarations with descriptors
- Parameter callback with validation
- Sensor data processing using parameters
- Velocity command publishing
Create YAML files in config/ directory:
indoor_config.yamloutdoor_config.yamlwarehouse_config.yamlcompetition_config.yaml
Create in launch/ directory:
single_robot.launch.py- Basic single nodemulti_node_system.launch.py- Full systemenvironment_launch.py- Environment-specific
Use RQT tools to verify functionality:
- Launch your robot system
- Open
rqt_reconfigurefor parameter tuning - Use
rqt_consoleto monitor logs - Visualize with
rqt_graph - Plot data with
rqt_plot
๐ Deliverables
โ 1. Parameterized Robot Node
- Complete Python node with all required parameters
- Parameter validation and error handling
- Runtime reconfiguration support
- Comprehensive logging
โ 2. Launch File System
- Multi-node launch file
- Environment-specific launch configurations
- Parameter file loading
- Launch arguments for flexibility
โ 3. Configuration Documentation
- README.md with project overview
- Parameter descriptions and valid ranges
- Launch file usage instructions
- Environment configuration guide
- Troubleshooting section
Testing Checklist
๐งช Verify Your Implementation
- โ All parameters can be set via command line
- โ Parameters load correctly from YAML files
- โ Runtime parameter changes work without restart
- โ Invalid parameters are rejected with clear errors
- โ All four environment configs produce different behaviors
- โ Launch files start all nodes successfully
- โ RQT tools can connect and modify parameters
- โ Documentation is clear and complete
Bonus Challenges ๐
- Parameter Presets: Implement a service to switch between predefined parameter sets
- Auto-Tuning: Create a node that automatically adjusts parameters based on sensor feedback
- Parameter History: Log and visualize parameter changes over time
- Custom RQT Plugin: Build a custom GUI for your robot's parameters
- Cloud Config: Load parameters from a remote server or database
๐ Additional Resources
Official Documentation:
Best Practices:
- Always provide parameter descriptors with meaningful descriptions
- Use YAML files for complex configurations
- Implement parameter validation to prevent invalid states
- Document parameter ranges and units clearly
- Use namespaces to organize parameters logically
- Test parameter changes thoroughly before deployment
๐ง Troubleshooting Common Issues
Problem 1: "Package not found"
Error: Package 'my_package' not found
Solution:
Problem 2: YAML Parameters Not Loading
Common Mistake: Wrong YAML format
Also check setup.py:
Problem 3: Parameters Won't Change at Runtime
Checklist - All 4 items required:
- โ Declare:
self.declare_parameter('speed', 1.0) - โ Add callback:
self.add_on_set_parameters_callback(self.parameter_callback) - โ Update in callback:
self.speed = param.value - โ Use member var:
twist.linear.x = self.speed
โ Quick Debug Commands
๐ Summary
In this week, you learned:
- โ How to create fully parameterized ROS2 nodes
- โ Parameter types, declaration, and validation
- โ Building complex launch files with Python
- โ Multi-node orchestration and coordination
- โ Dynamic reconfiguration at runtime
- โ Using RQT tools for parameter management
- โ Creating environment-specific configurations
Next Week: We'll explore advanced topics including TF transformations, URDF robot descriptions, and robot state publishers!