From 1f46f8dd3a8c593a76fd9da6bb57c6fc3f98e57d Mon Sep 17 00:00:00 2001 From: openhands Date: Tue, 25 Aug 2026 00:05:24 +0000 Subject: [PATCH] Document node parameters and switch to config-file based launch - Convert the parameter test launch file to load parameters from a YAML configuration file (config_file launch argument) instead of an inline parameter dict. - Add config/config.yaml with one block keyed by the effective node name 'sas_common_ros2_parameter_test', documenting all eight vector parameters (the four EMPTY_LIST markers and four representative non-empty vectors). - Add a 'ROS 2 Nodes & Parameters' README section with a parameter table. - Install the config/ directory into the package share directory. - Preserve the launch filename and node name to avoid breaking downstream references. Co-authored-by: openhands --- CMakeLists.txt | 11 +++ README.md | 38 +++++++++-- config/config.yaml | 67 +++++++++++++++++++ .../sas_common_ros2_parameter_test_launch.py | 41 ++++++++---- 4 files changed, 137 insertions(+), 20 deletions(-) create mode 100644 config/config.yaml diff --git a/CMakeLists.txt b/CMakeLists.txt index b903184..12da689 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -223,6 +223,17 @@ install(DIRECTORY # Launch Block [END] # ###################### +######################### +# Config Block [BEGIN] # +# vvvvvvvvvvvvvvvvvvvvv # +install(DIRECTORY + config + DESTINATION share/${PROJECT_NAME}/ +) +# ^^^^^^^^^^^^^^^^^^^ # +# Config Block [END] # +####################### + ######################### # Scripts Block [BEGIN] # # vvvvvvvvvvvvvvvvvvvvv # diff --git a/README.md b/README.md index 77865ad..db2730e 100644 --- a/README.md +++ b/README.md @@ -4,20 +4,44 @@ > Repository for this module: https://github.com/SmartArmStack/sas_common.
> More information about SmartArmStack is available in https://smartarmstack.github.io/. -## ROS 2 Nodes +## ROS 2 Nodes & Parameters Example implementations are located in the `src/examples/` directory. The package also includes a Python wrapper test script in the `scripts/` directory. +The `sas_common_ros2_parameter_test_node` is launched through `sas_common_ros2_parameter_test_launch.py`, which loads parameters from `config/config.yaml` (pass a different file with `config_file:=/path/to/config.yaml`). + ```bash -docker run --rm murilomarinho/sas:jazzy bash -c "ros2 run sas_common sas_object_test_node" +ros2 run sas_common sas_object_test_node ``` -### sas_common_ros2_parameter_test_node +### Node: `sas_common_ros2_parameter_test_node` + +| Property | Value | +|---|---| +| **Executable** | `sas_common_ros2_parameter_test_node` | +| **ROS node name** | `sas_common_ros2_parameter_test` (set by the `name` launch argument of `sas_common_ros2_parameter_test_launch.py`) | +| **Description** | Example/test node demonstrating the behaviour of `sas::get_ros_parameter`. It validates ROS 2 parameter parsing, including the package-specific handling of empty lists encoded as `["EMPTY_LIST"]`. | + +#### Parameters + +All eight parameters are optional — an absent vector parameter defaults to an empty list. -This example and test node demonstrates the behaviour of `sas::get_ros_parameter`. It is intended to validate ROS 2 parameter parsing, including the package-specific handling of empty lists encoded as `["EMPTY_LIST"]`. +| Parameter | Type | Mandatory / Optional | Default | Purpose | +|---|---|---|---|---| +| `empty_string_vector` | string array | Optional | `[]` (empty) | Exercises the `["EMPTY_LIST"]` marker for an empty string vector | +| `empty_integer_vector` | integer array | Optional | `[]` (empty) | Exercises the `["EMPTY_LIST"]` marker for an empty integer vector | +| `empty_double_vector` | double array | Optional | `[]` (empty) | Exercises the `["EMPTY_LIST"]` marker for an empty double vector | +| `empty_bool_vector` | boolean array | Optional | `[]` (empty) | Exercises the `["EMPTY_LIST"]` marker for an empty boolean vector | +| `string_vector` | string array | Optional | `[]` (empty) | A non-empty string vector to test parsing | +| `integer_vector` | integer array | Optional | `[]` (empty) | A non-empty integer vector to test parsing | +| `double_vector` | double array | Optional | `[]` (empty) | A non-empty double vector to test parsing | +| `bool_vector` | boolean array | Optional | `[]` (empty) | A non-empty boolean vector to test parsing | -> [!NOTE] -> Use `sas_common_ros2_parameter_test_launch.py` to evaluate this node. +#### Sample launch + +```bash +ros2 launch sas_common sas_common_ros2_parameter_test_launch.py +``` ### sas_object_test_node @@ -53,7 +77,7 @@ docker run --rm murilomarinho/sas:jazzy bash -c "ros2 launch sas_common sas_comm ### sas_common_ros2_parameter_test_launch.py -This launch file starts `sas_common_ros2_parameter_test_node` with a predefined set of parameters. It is designed to test ROS 2 parameter parsing, including the handling of empty lists encoded as `["EMPTY_LIST"]`. +This launch file starts `sas_common_ros2_parameter_test_node`, loading its parameters from `config/config.yaml` (or a file of your choice via `config_file:=/path/to/config.yaml`). It is designed to test ROS 2 parameter parsing, including the handling of empty lists encoded as `["EMPTY_LIST"]`. ```bash ros2 launch sas_common sas_common_ros2_parameter_test_launch.py diff --git a/config/config.yaml b/config/config.yaml new file mode 100644 index 0000000..fe3fbb6 --- /dev/null +++ b/config/config.yaml @@ -0,0 +1,67 @@ +# Parameters for the sas_common nodes. +# +# Each top-level block is keyed by the ROS node name and is loaded by the +# corresponding launch file via its `config_file` argument. + +# sas_common_ros2_parameter_test (example/test node) +# +# Demonstrates the behaviour of `sas::get_ros_parameter`, including the +# package-specific handling of empty lists encoded as `["EMPTY_LIST"]`. +# All eight parameters are optional: an absent vector parameter defaults to an +# empty list. +sas_common_ros2_parameter_test: + ros__parameters: + empty_string_vector: + - EMPTY_LIST + empty_integer_vector: + - EMPTY_LIST + empty_double_vector: + - EMPTY_LIST + empty_bool_vector: + - EMPTY_LIST + string_vector: + - a + - b + - c + - d + - e + - f + integer_vector: + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + - 10 + double_vector: + - 11.0 + - 12.0 + - 13.0 + - 14.0 + - 15.0 + - 16.0 + - 17.0 + - 18.0 + - 19.0 + - 20.0 + bool_vector: + - false + - true + - true + - false + - true + - true + - true + - true + - false + - true + - true + - false + - true + - false + - true + - true diff --git a/launch/sas_common_ros2_parameter_test_launch.py b/launch/sas_common_ros2_parameter_test_launch.py index fe153d7..eb19d32 100644 --- a/launch/sas_common_ros2_parameter_test_launch.py +++ b/launch/sas_common_ros2_parameter_test_launch.py @@ -1,30 +1,45 @@ """Launch file used to run the ros2 parameter test node for sas_common. This launch description starts the `sas_common_ros2_parameter_test_node` with -pre-configured parameters used to exercise the special EMPTY_LIST handling for -vector parameters. +parameters loaded from a YAML configuration file. The parameters exercise the +special EMPTY_LIST handling for vector parameters. + +Pass a different file with ``config_file:=/path/to/config.yaml``. """ +import os.path + +from ament_index_python.packages import get_package_share_directory from launch import LaunchDescription +from launch.actions import DeclareLaunchArgument +from launch.substitutions import LaunchConfiguration from launch_ros.actions import Node + def generate_launch_description(): + """Launch the sas_common ROS2 parameter test node. + + Parameters are loaded from a YAML configuration file. Pass a different + file with ``config_file:=/path/to/config.yaml``. + """ + name = LaunchConfiguration('name') + config_file = LaunchConfiguration('config_file') + return LaunchDescription([ + DeclareLaunchArgument( + 'name', + default_value='sas_common_ros2_parameter_test' + ), + DeclareLaunchArgument( + 'config_file', + default_value=os.path.join(get_package_share_directory('sas_common'), 'config', 'config.yaml') + ), Node( package='sas_common', executable='sas_common_ros2_parameter_test_node', - name='sas_common_ros2_parameter_test', + name=name, output='screen', - parameters=[{ - "empty_string_vector": ["EMPTY_LIST"], - "empty_integer_vector": ["EMPTY_LIST"], - "empty_double_vector": ["EMPTY_LIST"], - "empty_bool_vector": ["EMPTY_LIST"], - "string_vector": ["a","b","c","d","e","f"], - "integer_vector": [1,2,3,4,5,6,7,8,9,10], - "double_vector": [11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0], - "bool_vector": [False,True,True,False,True,True,True,True,False,True,True,False,True,False,True,True], - }] + parameters=[config_file] ) ])