Skip to content

improvement: auto-add OpenLoopPositionEstimator in simulation mode#30

Merged
jimsynz merged 1 commit intomainfrom
improvement/auto-position-estimator-simulation
Jan 9, 2026
Merged

improvement: auto-add OpenLoopPositionEstimator in simulation mode#30
jimsynz merged 1 commit intomainfrom
improvement/auto-position-estimator-simulation

Conversation

@jimsynz
Copy link
Contributor

@jimsynz jimsynz commented Jan 9, 2026

Summary

  • Automatically creates OpenLoopPositionEstimator sensors for actuators in simulation mode
  • Fixes OpenLoopPositionEstimator to handle PubSub message format

Problem

When using bb_liveview with a robot that has actuators defined (like bb_example_wx200), moving joint sliders in simulation mode didn't update the 3D visualisation. This was because:

  1. Simulated actuators (BB.Sim.Actuator) publish BeginMotion messages, not JointState
  2. JointState messages are needed for the visualisation to update
  3. Users had to manually add OpenLoopPositionEstimator sensors to convert BeginMotionJointState

Solution

When a robot starts with simulation: :kinematic, the JointSupervisor now automatically creates OpenLoopPositionEstimator sensors for each actuator that doesn't already have one. The auto-generated sensors are named :{actuator_name}_position_estimator.

This ensures simulation mode works out of the box without requiring manual sensor configuration.

Changes

lib/bb/joint_supervisor.ex

  • Add build_auto_position_estimators/4 to create sensors for actuators without existing position feedback
  • Add has_position_sensor_for_actuator?/2 to check if an actuator already has position feedback

lib/bb/sensor/open_loop_position_estimator.ex

  • Add handle_info/2 clause for {:bb, path, message} tuple format from PubSub

test/bb/sim/simulation_test.exs

  • Add tests for automatic position estimator creation
  • Test that auto estimator is not added when manual one exists
  • Test that auto estimator publishes JointState messages
  • Test that auto estimator is not added in hardware mode

Test plan

  • All existing tests pass
  • New tests for auto position estimator pass
  • mix check --no-retry passes (except pre-existing flaky test)
  • Manual test with bb_example_wx200 in simulation mode

When a robot starts with `simulation: :kinematic`, the `JointSupervisor`
now automatically creates `OpenLoopPositionEstimator` sensors for each
actuator that doesn't already have one.

This ensures that simulated actuators publish `JointState` messages
without requiring manual sensor configuration, making simulation mode
work out of the box with tools like `bb_liveview`.

Changes:
- `JointSupervisor`: Add `build_auto_position_estimators/4` to create
  sensors named `:{actuator_name}_position_estimator` for actuators
  without existing position feedback sensors
- `OpenLoopPositionEstimator`: Handle `{:bb, path, message}` tuple
  format from PubSub subscriptions
@jimsynz jimsynz merged commit 10a55ef into main Jan 9, 2026
14 checks passed
@jimsynz jimsynz deleted the improvement/auto-position-estimator-simulation branch January 9, 2026 07:02
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.

1 participant