Media is too big
VIEW IN TELEGRAM
Working with Parameters in ROS2: A Quick Example
1️⃣ Defining Parameters:
Using
- Type: PARAMETER_DOUBLE
- Description: "Focal length in mm"
- Range: 1.0 to 100.0, step 0.1
2️⃣ Access & Modify Parameters:
- Use the CLI with commands like ros2 param get/set.
- Alternatively, use a GUI to adjust values in real time for better flexibility and usability.
3️⃣ Error Handling:
ROS2 comes with built-in methods to validate parameters based on their descriptors. For example, if you try setting focal_length to 40.44 (which doesn't match the step size of 0.1), you get a precise error:
#ROS #knowledge #example
1️⃣ Defining Parameters:
Using
ParameterDescriptor
, we define parameters like focal_length
with details such as:- Type: PARAMETER_DOUBLE
- Description: "Focal length in mm"
- Range: 1.0 to 100.0, step 0.1
2️⃣ Access & Modify Parameters:
- Use the CLI with commands like ros2 param get/set.
- Alternatively, use a GUI to adjust values in real time for better flexibility and usability.
3️⃣ Error Handling:
ROS2 comes with built-in methods to validate parameters based on their descriptors. For example, if you try setting focal_length to 40.44 (which doesn't match the step size of 0.1), you get a precise error:
"Setting parameter failed: The value is not close enough to a valid step."❗️This means ROS2 ensures parameters strictly follow the defined constraints—like ranges, step increments, and types—without requiring custom validation logic in your code.
#ROS #knowledge #example
⚡1