Skip to content

Commit 91e8e75

Browse files
QA ROS 2 adapter (#37)
* Qos documentation (#31) * Add QoS to readme * Add links to profile details * Add example profile, remove debug prints * Add section to readme * Test service calls (#32) * Add examples in tests folder * Update README.md * Update README.md * Dedicated config examples folder * Rename config examples * Start subscribers test * Query for subscribers test * Config for subscribers test * Test subscribers with message paths * Add config for QoS test * Organize files * Change name of topics and streams * Add more configs * Add config for service call tests * Point to example config in readme * Add testing instructions to readme * Add tf bag and config * Add config for localization test * Update localization config * Add localization bag * Add readme for tf test * Add readme for localization test * Add helper script that sends command * Add readme for publisher test * Combine subscribers test config * Delete config_test_subscribers_message_paths.json * Create readme for subscriber test * Change topic names * Create readme for QoS test * Change message name and type in publisher test * Update publisher test readme * Update tf readme * Update localization readme * Change test publisher to test teleop * Update teleop test config * Update teleop test readme * Add button to teleop config * Add button to teleop test readme
1 parent e826582 commit 91e8e75

File tree

72 files changed

+1248
-114
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+1248
-114
lines changed

README.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ The `subscribers` section defines a list of ROS 2 topics that the adapter will s
2424
| `ros2_message_paths` | The list of paths configurations to ingest data from |
2525
| `ros2_message_paths/path` | The path within the ROS 2 message |
2626
| `ros2_message_paths/tags` | The tag set to ingest data with |
27+
| `ros2_qos_profile` | The Quality of Service profile for the messages |
2728

2829
#### Example
2930

@@ -41,7 +42,8 @@ The `subscribers` section defines a list of ROS 2 topics that the adapter will s
4142
"example_key": "example_value"
4243
}
4344
}
44-
]
45+
],
46+
"ros2_qos_profile": "SYSTEM_DEFAULT"
4547
}
4648
]
4749
}
@@ -63,6 +65,7 @@ In either of these cases, the name of the configured Formant control input must
6365
| `formant_stream` | The name of the Formant stream to publish data from |
6466
| `ros2_topic` | The name of the ROS 2 topic to publish data to |
6567
| `ros2_message_type` | The type of ROS 2 topic to publish data to |
68+
| `ros2_qos_profile` | The Quality of Service profile for the messages |
6669

6770
#### Example
6871

@@ -73,6 +76,7 @@ In either of these cases, the name of the configured Formant control input must
7376
"formant_stream": "example.stream",
7477
"ros2_topic": "/example_topic",
7578
"ros2_message_type": "example_msgs/msg/ExampleType",
79+
"ros2_qos_profile": "SYSTEM_DEFAULT"
7680
}
7781
]
7882
}
@@ -264,6 +268,28 @@ Topics will automatically be ingested as their corresponding Formant type:
264268

265269
Stream name will be automatically configured from the topic if it is not set. (e.g. "/base/cmd_vel" -> "base.cmd_vel") The `"stream"` configuration can be set to change the stream name of ingested datapoints manually.
266270

271+
### Quality of Service profiles
272+
273+
The adapter currently supports selecting from a set of predefined Quality of Service profiles for publishers and subscribers, based on these default profiles: https://docs.ros.org/en/rolling/Concepts/About-Quality-of-Service-Settings.html#qos-profiles
274+
275+
The possible configuration options are:
276+
277+
- SYSTEM_DEFAULT
278+
279+
- SENSOR_DATA
280+
281+
- SERVICES_DEFAULT
282+
283+
- PARAMETERS
284+
285+
- PARAMETER_EVENTS
286+
287+
- ACTION_STATUS_DEFAULT (reliable reliability, transient local durability)
288+
289+
- EXAMPLE_CUSTOM (keep all history)
290+
291+
The EXAMPLE_CUSTOM option shows how additional custom profiles can be created in the code of the adapter.
292+
267293
## Running the adapter
268294

269295
The repo can either be zipped and configured as an adapter in Formant with "Exec command" `./start.sh`, or can be run manually.
@@ -292,4 +318,4 @@ source install/setup.bash
292318
ros2 run formant_ros2_adapter main.py
293319
```
294320
NOTE: This is untested with ROS 2 Humble
295-
NOTE: This is untested with fastdds
321+
NOTE: This is untested with fastdds

formant_ros2_adapter/scripts/config_example_small.json

Lines changed: 0 additions & 112 deletions
This file was deleted.
File renamed without changes.

tests/test_localization/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Test Localization
2+
3+
1. Set adapter config to `config_test_localization.json`
4+
2. Run the adapter
5+
3. Run `ros2 bag play rosbag2_turtlebot3_localization`
6+
7+
You should see localization data appear in Formant.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"ros2_adapter_configuration": {
3+
"localization": {
4+
"formant_stream": "turtlebot3.localization",
5+
"base_reference_frame": "map",
6+
"odometry_subscriber_ros2_topic": "/odom",
7+
"map_subscriber_ros2_topic": "/local_costmap/costmap_raw",
8+
"point_cloud_subscriber_ros2_topics": [{"ros2_topic": "/scan"}]
9+
}
10+
}
11+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
rosbag2_bagfile_information:
2+
version: 5
3+
storage_identifier: sqlite3
4+
duration:
5+
nanoseconds: 51638487753
6+
starting_time:
7+
nanoseconds_since_epoch: 1680817048427117683
8+
message_count: 1849
9+
topics_with_message_count:
10+
- topic_metadata:
11+
name: /odom
12+
type: nav_msgs/msg/Odometry
13+
serialization_format: cdr
14+
offered_qos_profiles: "- history: 3\n depth: 0\n reliability: 1\n durability: 2\n deadline:\n sec: 9223372036\n nsec: 854775807\n lifespan:\n sec: 9223372036\n nsec: 854775807\n liveliness: 1\n liveliness_lease_duration:\n sec: 9223372036\n nsec: 854775807\n avoid_ros_namespace_conventions: false"
15+
message_count: 1506
16+
- topic_metadata:
17+
name: /local_costmap/costmap_raw
18+
type: nav2_msgs/msg/Costmap
19+
serialization_format: cdr
20+
offered_qos_profiles: "- history: 3\n depth: 0\n reliability: 1\n durability: 1\n deadline:\n sec: 9223372036\n nsec: 854775807\n lifespan:\n sec: 9223372036\n nsec: 854775807\n liveliness: 1\n liveliness_lease_duration:\n sec: 9223372036\n nsec: 854775807\n avoid_ros_namespace_conventions: false"
21+
message_count: 86
22+
- topic_metadata:
23+
name: /scan
24+
type: sensor_msgs/msg/LaserScan
25+
serialization_format: cdr
26+
offered_qos_profiles: "- history: 3\n depth: 0\n reliability: 1\n durability: 2\n deadline:\n sec: 9223372036\n nsec: 854775807\n lifespan:\n sec: 9223372036\n nsec: 854775807\n liveliness: 1\n liveliness_lease_duration:\n sec: 9223372036\n nsec: 854775807\n avoid_ros_namespace_conventions: false"
27+
message_count: 257
28+
compression_format: ""
29+
compression_mode: ""
30+
relative_file_paths:
31+
- rosbag2_2023_04_06-21_37_28_0.db3
32+
files:
33+
- path: rosbag2_2023_04_06-21_37_28_0.db3
34+
starting_time:
35+
nanoseconds_since_epoch: 1680817048427117683
36+
duration:
37+
nanoseconds: 51638487753
38+
message_count: 1849
2.57 MB
Binary file not shown.

tests/test_qos/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Test Quality of Service Settings
2+
### Subscriber
3+
Create a subscriber with "reliable" reliability (e.g. what's in `config_test_qos.json`).
4+
5+
Publish a message with "best effort" reliability:
6+
7+
`ros2 topic pub /my_string std_msgs/msg/String "data: {key: value}" --qos-profile sensor_data`
8+
9+
QoS is working correctly if you get this message:
10+
11+
`[WARN] [<timestamp>] [<ros2cli>]: New subscription discovered on topic '/my_string', requesting incompatible QoS. No messages will be sent to it. Last incompatible policy: RELIABILITY`
12+
13+
### Publisher
14+
Create a publisher with "best effort" reliability (e.g. what's in `config_test_qos.json`).
15+
16+
Echo that topic with "reliable" reliability:
17+
18+
`ros2 topic echo /my_command_for_publisher --qos-reliability reliable`
19+
20+
QoS is working correctly if you get this message:
21+
22+
`[WARN] [<timestamp>] [<ros2cli>]: New publisher discovered on topic '/my_command_for_publisher', offering incompatible QoS. No messages will be received from it. Last incompatible policy: RELIABILITY`
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"ros2_adapter_configuration": {
3+
"subscribers": [
4+
{
5+
"ros2_topic": "/my_string",
6+
"ros2_message_type": "std_msgs/msg/String",
7+
"formant_stream": "my.string",
8+
"ros2_qos_profile": "PARAMETERS"
9+
}
10+
],
11+
"publishers": [
12+
{
13+
"ros2_topic": "/my_command_for_publisher",
14+
"ros2_message_type": "std_msgs/msg/String",
15+
"formant_stream": "my.command.for.publisher",
16+
"ros2_qos_profile": "SENSOR_DATA"
17+
}
18+
]
19+
}
20+
}

tests/test_service_calls/README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Test ROS 2 services
2+
3+
This directory contains a set of ROS 2 interfaces and service servers that can be used to test the service call functionality of the Formant ROS 2 adapter. They can also easily be duplicated and modified for different uses. The instructions and examples are based on these tutorials:
4+
5+
https://docs.ros.org/en/humble/Tutorials/Beginner-Client-Libraries/Custom-ROS2-Interfaces.html
6+
https://docs.ros.org/en/humble/Tutorials/Beginner-Client-Libraries/Colcon-Tutorial.html
7+
8+
and use this as a template:
9+
10+
https://github.com/ros2/examples/tree/humble/rclpy/services/minimal_service
11+
12+
## Setup instructions
13+
14+
Set up a colcon workspace if you haven't already, and put the contents of "src" into the workspace's "src". Build all of the packages by running `colcon build`, or individual packages with `colcon build --packages-select {package name, e.g. formant_int}`.
15+
16+
Source the packages with source `{workspace}/install/setup.bash`.
17+
18+
Run `ros2 pkg list`, `ros2 pkg executables {package}`, `ros2 interface list`, and `ros2 interface show {interface}` to see the new services and how to use them ([this example config](https://github.com/FormantIO/ros2-adapter/blob/qa-adapter/tests/test_service_calls/config_test_service_calls.json) also shows the names of the services and interfaces).
19+
20+
## Testing
21+
1. Run the ROS 2 adapter with the service calls configured (e.g. [this example config](https://github.com/FormantIO/ros2-adapter/blob/qa-adapter/tests/test_service_calls/config_test_service_calls.json))
22+
2. Run the service server (e.g. `ros2 run formant_int service`)
23+
3. Send a command or publish to a topic from Formant whose name matches the `formant_stream` field in the config (e.g. `ros2_service_test_set_int`)
24+
25+
## Creating more examples
26+
27+
New interfaces can easily be created by following the "Custom-ROS2-Interfaces" tutorial mentioned above.
28+
29+
To create new service call servers, you can take a shortcut and copy/modify one of the existing examples. You will notice that they are all almost the same structurally, but there are a few things that need to be changed:
30+
31+
* "package.xml": `name` field, maybe `exec_depend` depending on the dependencies
32+
* "setup.py": `package_name`, `entry_points` fields
33+
* "setup.cfg": `script_dir` and `install_dir` fields
34+
* "resource" folder: change name of file inside to match packge
35+
* "service.py": what the service actually does

0 commit comments

Comments
 (0)