Skip to content

Commit 588f93a

Browse files
mfaferek93bburda
authored andcommitted
fix: address review findings from PR #331
- Populate fault timestamps (first/last_occurred) from JSON response - Fix TODO reference (removed stale #332 link) - Add README.md for sovd_service_interface plugin - Move test domain range from 230-232 to 1-9 (avoid collision with peer_aggregation secondary domains at 230)
1 parent 002b8b2 commit 588f93a

4 files changed

Lines changed: 47 additions & 7 deletions

File tree

src/ros2_medkit_cmake/cmake/ROS2MedkitTestDomain.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
# non-overlapping domain ID ranges to prevent DDS cross-contamination.
2020
#
2121
# Allocated ranges:
22+
# ros2_medkit_sovd_service_iface: 1 - 9 (9 slots)
2223
# ros2_medkit_fault_manager: 10 - 29 (20 slots)
2324
# ros2_medkit_gateway: 30 - 89 (60 slots)
2425
# ros2_medkit_diagnostic_bridge: 90 - 99 (10 slots)
@@ -27,7 +28,7 @@
2728
# ros2_medkit_graph_provider: 120 - 129 (10 slots)
2829
# ros2_medkit_linux_introspection: 130 - 139 (10 slots)
2930
# ros2_medkit_integration_tests: 140 - 229 (90 slots)
30-
# ros2_medkit_sovd_service_iface: 230 - 232 (3 slots, max domain ID is 232)
31+
# multi-domain tests (secondary): 230 - 232 (3 slots, reserved for peer_aggregation etc.)
3132
#
3233
# To add a new package: pick the next free range and update this comment.
3334

src/ros2_medkit_plugins/ros2_medkit_sovd_service_interface/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ if(BUILD_TESTING)
9191
find_package(ament_cmake_gtest REQUIRED)
9292

9393
include(ROS2MedkitTestDomain)
94-
medkit_init_test_domains(START 230 END 232)
94+
medkit_init_test_domains(START 1 END 9)
9595

9696
ament_add_gtest(test_sovd_service_interface
9797
test/test_sovd_service_interface.cpp
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# ros2_medkit_sovd_service_interface
2+
3+
Gateway plugin exposing medkit entity data via ROS 2 services. Enables ROS 2 nodes (e.g. VDA 5050 agent, BT.CPP, PlotJuggler) to access SOVD diagnostics without HTTP.
4+
5+
## Services
6+
7+
| Service | Type | Description |
8+
|---------|------|-------------|
9+
| `/medkit/list_entities` | `ros2_medkit_msgs/srv/ListEntities` | List all discovered entities (apps, components, areas) |
10+
| `/medkit/list_entity_faults` | `ros2_medkit_msgs/srv/ListFaultsForEntity` | Get faults for a specific entity |
11+
| `/medkit/get_entity_data` | `ros2_medkit_msgs/srv/GetEntityData` | Get entity topic data (not yet implemented) |
12+
| `/medkit/get_capabilities` | `ros2_medkit_msgs/srv/GetCapabilities` | Get SOVD capabilities for an entity |
13+
14+
Service prefix is configurable via `plugins.sovd_service_interface.service_prefix` parameter (default: `/medkit`).
15+
16+
## Usage
17+
18+
Load as a gateway plugin:
19+
20+
```bash
21+
ros2 run ros2_medkit_gateway gateway_node --ros-args \
22+
-p "plugins:=[\"sovd_service_interface\"]" \
23+
-p "plugins.sovd_service_interface.path:=/path/to/libsovd_service_interface.so" \
24+
-p "plugins.sovd_service_interface.service_prefix:=/medkit"
25+
```
26+
27+
## Tests
28+
29+
```bash
30+
colcon test --packages-select ros2_medkit_sovd_service_interface
31+
```

src/ros2_medkit_plugins/ros2_medkit_sovd_service_interface/src/sovd_service_interface.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,16 @@ void SovdServiceInterface::handle_list_entity_faults(
179179
fault.description = fault_json.value("description", std::string{});
180180
fault.status = fault_json.value("status", std::string{});
181181
fault.occurrence_count = fault_json.value("occurrence_count", static_cast<uint32_t>(0));
182+
if (fault_json.contains("first_occurred") && fault_json["first_occurred"].is_number()) {
183+
double ts = fault_json["first_occurred"].get<double>();
184+
fault.first_occurred.sec = static_cast<int32_t>(ts);
185+
fault.first_occurred.nanosec = static_cast<uint32_t>((ts - static_cast<int32_t>(ts)) * 1e9);
186+
}
187+
if (fault_json.contains("last_occurred") && fault_json["last_occurred"].is_number()) {
188+
double ts = fault_json["last_occurred"].get<double>();
189+
fault.last_occurred.sec = static_cast<int32_t>(ts);
190+
fault.last_occurred.nanosec = static_cast<uint32_t>((ts - static_cast<int32_t>(ts)) * 1e9);
191+
}
182192
if (fault_json.contains("reporting_sources") && fault_json["reporting_sources"].is_array()) {
183193
for (const auto & src : fault_json["reporting_sources"]) {
184194
if (src.is_string()) {
@@ -209,11 +219,9 @@ void SovdServiceInterface::handle_get_entity_data(
209219
return;
210220
}
211221

212-
// TODO(#332): Implement data retrieval via PluginContext::get_entity_data()
213-
// when the method is added. Currently PluginContext exposes entity metadata
214-
// and faults but not live topic data. The VDA 5050 agent should use the
215-
// HTTP REST API (/api/v1/apps/{id}/data) as the primary data source until
216-
// this service is fully implemented.
222+
// TODO: Implement data retrieval when PluginContext gains data access.
223+
// Currently PluginContext exposes entity metadata and faults but not live
224+
// topic data. Use HTTP REST API (/api/v1/apps/{id}/data) as alternative.
217225
response->data_json = "{}";
218226
response->success = false;
219227
response->error_message = "GetEntityData not yet implemented - use HTTP REST API for topic data";

0 commit comments

Comments
 (0)