BB.Ufactory.Sensor.Collision (bb_ufactory v0.1.0)

Copy Markdown View Source

Collision detection sensor for xArm arms.

Configures the arm's firmware collision detection on init/1 and subscribes to BB.Ufactory.Message.ArmStatus events from the controller. When an ArmStatus message carrying a collision-related error code arrives, it is re-published to this sensor's own pubsub path so application code can subscribe to a stable, sensor-scoped topic.

Detected Error Codes

CodeMeaning
22Self-collision error (arm would collide with itself)
31Collision caused abnormal current (external contact)
35Safety boundary limit (TCP exited the workspace fence)

Configuration

sensor :collision, {BB.Ufactory.Sensor.Collision,
  controller: :xarm,
  sensitivity: 3,
  rebound: false,
  self_collision_check: true
}

Sensitivity Scale

LevelBehaviour
0Collision detection disabled
1Lowest sensitivity (hardest to trigger)
3Balanced — recommended default
5Highest sensitivity (easiest to trigger)

Subscribing to Collision Events

When a collision is detected, this sensor publishes the originating BB.Ufactory.Message.ArmStatus message (with non-zero error_code) to [:sensor | sensor_path]:

BB.subscribe(MyRobot, [:sensor, :collision])

receive do
  {:bb, [:sensor, :collision], %BB.Message{payload: %BB.Ufactory.Message.ArmStatus{
    error_code: code
  }}} ->
    IO.puts("Collision detected, error_code: #{code}")
end

Disarm

Collision detection settings are persistent in the arm's firmware NVRAM. No hardware action is taken on disarm.

Summary

Functions

No-op. Collision detection settings are persisted in firmware NVRAM and do not need to be reset on disarm.

Functions

disarm(opts)

No-op. Collision detection settings are persisted in firmware NVRAM and do not need to be reset on disarm.