Skip to content

feat: add triggers showcase to all demos#52

Merged
bburda merged 16 commits intomainfrom
feat/triggers-showcase
Mar 24, 2026
Merged

feat: add triggers showcase to all demos#52
bburda merged 16 commits intomainfrom
feat/triggers-showcase

Conversation

@bburda
Copy link
Contributor

@bburda bburda commented Mar 22, 2026

Description

Add trigger examples to each demo showcasing the gateway's condition-based trigger system with SSE event delivery.

New files:

  • lib/triggers-api.sh - shared library for trigger REST API (create, list, delete, watch SSE, find active)
  • demos/*/setup-triggers.sh - creates OnChange fault trigger with idempotency guard
  • demos/*/watch-triggers.sh - connects to SSE event stream, auto-detects active trigger

Modified files:

  • demos/*/run-demo.sh - daemon output includes numbered trigger workflow
  • demos/*/README.md - Triggers section with setup guide, API usage, scripts table entries
  • demos/moveit_pick_place/README.md - em dashes cleaned up (style convention)

User workflow:

  1. ./setup-triggers.sh - creates trigger, prints ID
  2. ./watch-triggers.sh - SSE stream in new terminal (blocking)
  3. ./inject-*.sh - trigger fires, event appears in watch terminal

Key implementation detail: Trigger entity must match reporting_sources[0] from FaultEvent (ROS node name), not the manifest entity ID. Each demo targets the fault-reporting app:

  • sensor_diagnostics: apps/diagnostic_bridge
  • turtlebot3: apps/anomaly_detector
  • moveit: apps/manipulation_monitor

Related Issue

closes #43

Checklist

  • Tested locally
  • README updated (if needed)

Copilot AI review requested due to automatic review settings March 22, 2026 20:47
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 a “Triggers” showcase to each demo, demonstrating the gateway’s condition-based trigger mechanism and Server-Sent Events (SSE) delivery via shared host-side scripts.

Changes:

  • Introduces a shared lib/triggers-api.sh helper for trigger CRUD + SSE watching and “find active trigger” convenience.
  • Adds setup-triggers.sh and watch-triggers.sh to each demo and updates run-demo.sh output with a trigger workflow.
  • Updates each demo README with a new Triggers section and manual API examples (plus MoveIt README dash/style cleanups).

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
lib/triggers-api.sh Shared trigger REST/SSE helper functions used by all demos.
demos/sensor_diagnostics/setup-triggers.sh Creates an OnChange fault trigger for components/compute-unit with idempotency guard.
demos/sensor_diagnostics/watch-triggers.sh Watches trigger SSE stream (auto-detects an active trigger if no ID provided).
demos/sensor_diagnostics/run-demo.sh Prints a numbered triggers workflow in detach mode.
demos/sensor_diagnostics/README.md Documents triggers setup, behavior, and manual API usage.
demos/turtlebot3_integration/setup-triggers.sh Creates an OnChange fault trigger for components/nav2-stack with idempotency guard.
demos/turtlebot3_integration/watch-triggers.sh Watches trigger SSE stream (auto-detects an active trigger if no ID provided).
demos/turtlebot3_integration/run-demo.sh Prints a numbered triggers workflow in detach mode.
demos/turtlebot3_integration/README.md Documents triggers setup, behavior, and manual API usage.
demos/moveit_pick_place/setup-triggers.sh Creates an OnChange fault trigger for components/moveit-planning with idempotency guard.
demos/moveit_pick_place/watch-triggers.sh Watches trigger SSE stream (auto-detects an active trigger if no ID provided).
demos/moveit_pick_place/run-demo.sh Prints a numbered triggers workflow in detach mode.
demos/moveit_pick_place/README.md Documents triggers + manual API usage; replaces em-dashes with hyphen style in multiple sections.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Triggers must target the entity whose ROS node name appears in
reporting_sources[0] of the FaultEvent. The TriggerFaultSubscriber
extracts entity_id from this field.

- sensor_diagnostics: apps/diagnostic_bridge (was components/compute-unit)
- turtlebot3: apps/anomaly_detector (was components/nav2-stack)
- moveit: apps/manipulation_monitor (was components/moveit-planning)

Verified end-to-end: setup-triggers -> watch-triggers -> inject-nan
produces SSE events with fault payloads.
@bburda bburda requested a review from mfaferek93 March 23, 2026 15:37
@bburda bburda self-assigned this Mar 23, 2026
bburda added 3 commits March 23, 2026 23:02
…x curl error handling

- Extract common setup/watch logic to lib/setup-trigger.sh and lib/watch-trigger.sh;
  per-demo scripts are now thin wrappers setting ENTITY_TYPE/ENTITY_ID/INJECT_HINT
- Add trigger_id validation in delete_trigger and watch_trigger_events
- Fix curl error handling in create_fault_trigger: capture failure explicitly
  instead of swallowing with || true
The runtime-discovered entity (diagnostic_bridge with underscore) may not
exist in CI if the Docker image cache has an older gateway version. The
manifest entity (diagnostic-bridge with hyphen) always exists. Trigger
CRUD works on any entity - only SSE dispatch needs reporting_sources match.
@mfaferek93 mfaferek93 self-requested a review March 24, 2026 08:05
@bburda bburda merged commit c7b7495 into main Mar 24, 2026
4 checks passed
@bburda bburda deleted the feat/triggers-showcase branch March 24, 2026 08:06
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.

Add triggers showcase

3 participants