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
| Code | Meaning |
|---|---|
| 22 | Self-collision error (arm would collide with itself) |
| 31 | Collision caused abnormal current (external contact) |
| 35 | Safety 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
| Level | Behaviour |
|---|---|
0 | Collision detection disabled |
1 | Lowest sensitivity (hardest to trigger) |
3 | Balanced — recommended default |
5 | Highest 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}")
endDisarm
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.