Skip to content

feat: add beacon mode switch to sensor diagnostics demo#47

Open
bburda wants to merge 3 commits intomainfrom
feat/41-beacon-mode-sensor-demo
Open

feat: add beacon mode switch to sensor diagnostics demo#47
bburda wants to merge 3 commits intomainfrom
feat/41-beacon-mode-sensor-demo

Conversation

@bburda
Copy link
Contributor

@bburda bburda commented Mar 21, 2026

Description

Add configurable beacon mode (BEACON_MODE env var) to the sensor diagnostics demo with three options:

  • none (default) - No beacon plugins, current behavior unchanged
  • topic - Topic beacon: sensor nodes push MedkitDiscoveryHint messages to /ros2_medkit/discovery every 5s
  • param - Parameter beacon: sensor nodes declare ros2_medkit.discovery.* parameters, gateway polls every 5s

Each sensor node uses a shared BeaconHelper class that reads the beacon_mode parameter 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 logic
  • 4 sensor nodes - BeaconHelper integration with sensor-specific config
  • CMakeLists.txt - Added ros2_medkit_msgs dependency to sensor node targets
  • launch/demo.launch.py - Reads BEACON_MODE, resolves beacon plugin, passes to nodes
  • docker-compose.yml - Passes BEACON_MODE env var through to container
  • README.md - New "Beacon Mode" section documenting all 3 modes

Tested all 3 modes via Docker:

  • none: No beacon plugins loaded, no beacon endpoints (404), all 21 smoke tests pass
  • topic: topic_beacon plugin loaded, beacon data visible via /x-medkit-topic-beacon for all 4 sensors
  • param: parameter_beacon plugin loaded, beacon data visible via /x-medkit-param-beacon for all 4 sensors

Related Issue

closes #41

Checklist

  • Tested locally
  • README updated (if needed)

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
Copilot AI review requested due to automatic review settings March 21, 2026 20:48
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 BeaconHelper used by all four sensor simulator nodes to enable topic/param beacons based on the beacon_mode parameter.
  • Updates the demo launch file to read BEACON_MODE, conditionally load the matching gateway beacon plugin, and pass beacon_mode to sensor nodes.
  • Plumbs BEACON_MODE through 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.

bburda added 2 commits March 21, 2026 22:02
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).
@bburda bburda self-assigned this Mar 21, 2026
@bburda bburda requested a review from mfaferek93 March 21, 2026 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable plugins per demo

2 participants