Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 #
Expand Down
38 changes: 31 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,44 @@
> Repository for this module: https://github.com/SmartArmStack/sas_common. <br/>
> 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

Expand Down Expand Up @@ -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
Expand Down
67 changes: 67 additions & 0 deletions config/config.yaml
Original file line number Diff line number Diff line change
@@ -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
41 changes: 28 additions & 13 deletions launch/sas_common_ros2_parameter_test_launch.py
Original file line number Diff line number Diff line change
@@ -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]
)
])