Skip to content

Conversation

@jimsynz
Copy link
Contributor

@jimsynz jimsynz commented Dec 20, 2025

Summary

  • Add BB.Safety.report_error/3 API for controllers and actuators to report hardware errors
  • Add auto_disarm_on_error setting (default: true) to control automatic disarm on error
  • Add BB.Safety.HardwareError message type published to [:safety, :error]
  • Update safety documentation with hardware error reporting section and examples

Motivation

Controllers monitoring hardware (like servo drivers) need a way to report hardware errors to the safety system. By default, hardware errors should trigger a safe shutdown, but advanced users may want custom error handling.

Changes

New files:

  • lib/bb/safety/hardware_error.ex - Message type for error events

Modified files:

  • lib/bb/dsl.ex - Added auto_disarm_on_error setting
  • lib/bb/dsl/info.ex - Exposed new setting
  • lib/bb/safety.ex - Added report_error/3 API
  • lib/bb/safety/controller.ex - Implemented error reporting logic
  • documentation/topics/safety.md - Added documentation section
  • test/bb/safety/controller_test.exs - Added tests

Test plan

  • Tests for report_error/3 publishing error messages
  • Tests for auto-disarm when auto_disarm_on_error is true
  • Tests for no auto-disarm when setting is false
  • All existing tests pass
  • mix check --no-retry passes

Add `BB.Safety.report_error/3` API for controllers and actuators to
report hardware errors. By default, reported errors automatically
disarm the robot for safety.

New features:
- `auto_disarm_on_error` setting (default: true) in DSL settings
- `BB.Safety.report_error/3` publishes `HardwareError` message and
  optionally triggers disarm based on setting
- `BB.Safety.HardwareError` message type for error events
- Comprehensive documentation with custom error handler examples

Users can disable auto-disarm and implement custom error handling:

    settings do
      auto_disarm_on_error false
    end

    # Then subscribe to [:safety, :error] for custom handling
@jimsynz jimsynz merged commit 6afff1f into main Dec 20, 2025
14 checks passed
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.

2 participants