feat: add beacon mode switch to sensor diagnostics demo#47
Open
feat: add beacon mode switch to sensor diagnostics demo#47
Conversation
Add BEACON_MODE environment variable (none/topic/param) that controls entity enrichment via gateway beacon plugins. Sensor nodes conditionally publish MedkitDiscoveryHint messages (topic mode) or declare ros2_medkit.discovery.* parameters (param mode) with sensor-specific metadata (entity_id, display_name, component, function membership, sensor type, data topic, frame ID). Shared BeaconHelper class avoids code duplication across 4 sensor nodes. Launch file resolves the appropriate beacon plugin based on mode. Docker-compose passes BEACON_MODE through to the container. Closes #41
There was a problem hiding this comment.
Pull request overview
Adds an optional “beacon mode” to the sensor_diagnostics demo so sensor nodes can enrich gateway entities via either topic-published discovery hints or ROS 2 parameters, controlled by BEACON_MODE.
Changes:
- Introduces a shared
BeaconHelperused by all four sensor simulator nodes to enable topic/param beacons based on thebeacon_modeparameter. - Updates the demo launch file to read
BEACON_MODE, conditionally load the matching gateway beacon plugin, and passbeacon_modeto sensor nodes. - Plumbs
BEACON_MODEthrough Docker Compose and documents usage + endpoints in the demo README.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| demos/sensor_diagnostics/src/lidar_sim_node.cpp | Instantiates BeaconHelper with LiDAR-specific metadata. |
| demos/sensor_diagnostics/src/imu_sim_node.cpp | Instantiates BeaconHelper with IMU-specific metadata. |
| demos/sensor_diagnostics/src/gps_sim_node.cpp | Instantiates BeaconHelper with GPS-specific metadata. |
| demos/sensor_diagnostics/src/camera_sim_node.cpp | Instantiates BeaconHelper with camera-specific metadata. |
| demos/sensor_diagnostics/src/beacon_helper.hpp | New helper implementing topic beacon publishing + parameter beacon declarations. |
| demos/sensor_diagnostics/launch/demo.launch.py | Reads BEACON_MODE, loads beacon plugin, passes beacon_mode to sensor nodes. |
| demos/sensor_diagnostics/docker-compose.yml | Passes BEACON_MODE into demo and CI containers (default none). |
| demos/sensor_diagnostics/README.md | Documents the three beacon modes, usage, and API endpoints. |
| demos/sensor_diagnostics/CMakeLists.txt | Adds ros2_medkit_msgs dependency needed for beacon hint messages. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Address self-review findings: - Warn and fall back to 'none' for invalid BEACON_MODE values - Warn and fall back to 'none' when beacon plugin .so is not found - Cache pid and hostname in constructor instead of calling syscalls on every publish - Add explicit <chrono> include - Null-terminate hostname buffer to prevent truncation UB
Accept case-insensitive input (e.g., BEACON_MODE=Topic).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add configurable beacon mode (
BEACON_MODEenv var) to the sensor diagnostics demo with three options:MedkitDiscoveryHintmessages to/ros2_medkit/discoveryevery 5sros2_medkit.discovery.*parameters, gateway polls every 5sEach sensor node uses a shared
BeaconHelperclass that reads thebeacon_modeparameter and conditionally activates the appropriate mechanism with sensor-specific metadata (entity_id, display_name, component_id, function membership, sensor type, data topic, frame ID).Changes:
src/beacon_helper.hpp- New shared helper encapsulating topic/param beacon logicCMakeLists.txt- Addedros2_medkit_msgsdependency to sensor node targetslaunch/demo.launch.py- ReadsBEACON_MODE, resolves beacon plugin, passes to nodesdocker-compose.yml- PassesBEACON_MODEenv var through to containerREADME.md- New "Beacon Mode" section documenting all 3 modesTested all 3 modes via Docker:
none: No beacon plugins loaded, no beacon endpoints (404), all 21 smoke tests passtopic: topic_beacon plugin loaded, beacon data visible via/x-medkit-topic-beaconfor all 4 sensorsparam: parameter_beacon plugin loaded, beacon data visible via/x-medkit-param-beaconfor all 4 sensorsRelated Issue
closes #41
Checklist