Where safety actually lives
You will: Name every layer that enforces a limit, what each one survives, and why none is a safety system.
Builds on Limits come from the datasheet, Integration tests without physics and Decide how it fails before it fails.
The description declares a limit on every joint. The controller configuration declares a minimum and maximum on every command. It is natural to assume something enforces them.
Measured early in this project: nothing did. Commanding a joint far past its limit drove it there under the mock: on the SO-101, with the check below turned off, the pan went to 200° against its 110° limit. Gazebo only looked safe because its physics joint has a hard stop — a property of the simulator, not of the software. The first limit-checking scenario passed in simulation and failed on the mock, against identical robot software. It had been testing the simulator.
Three layers can clamp, and each covers a failure the others cannot:
| layer | how it behaves | survives |
|---|---|---|
| the robot client | rejects before sending, naming the joint | a programmer's mistake, loudly |
| the controller manager | clamps every command, below the seam | any caller, even one bypassing the client |
| the servo itself | clamps to angle limits stored in its own memory | the host crashing — not set up yet |
They are not redundant. The client tells you — a mistake surfaces
where the intent was expressed. The controller manager prevents it,
silently — and remember that a clamped goal still reports
SUCCEEDED, which is exactly why the loud layer is still wanted. The
servo's own limits are the only layer still standing when the computer
above it is not, and on this arm they are the one layer not yet in
place: an STS3215 keeps a minimum and maximum angle in its memory, and
this project's hardware interface does not write them yet.
And none of them is a safety system. Software cannot stop a servo that has failed, a brownout, a stripped gear or a collision. The most trustworthy limit is a physical hard stop the mechanism cannot exceed, and software cannot add one. The real emergency stop is a switch in the servo power line, and the arm's bill of materials does not include one. Until you add it: keep the power switch within reach before you power on.
The transferable habit is the one you already have about input validation: do not assume a lower layer enforces a constraint because the constraint is written down near it. Find out.
In the simulation
Drag a slider past a joint's end and the simulation clamps it there silently, as the controller manager does. Read where the clamp leaves a joint, the count a servo's own angle-limit register would hold, and then find what no software layer here stops at all.
Kinematic: joints move at their real speed limit, but there is no gravity, no load and no physics. That is what the steps below are for.
The SO-101 loads as you reach it.
make drive keysIn this lesson
- Open Inspect, then /joint_states, and drag
shoulder_pan's slider as far as it will go. It stops at 1.9199, its 110° limit, and nothing complains. (A jog would say "at its limit"; the controller manager's clamp would not.) - Switch to servo bus and take
shoulder_panto its other limit. Predict its count first: this is the number a minimum-angle register would need. - Now drive the arm into the bench. Every joint is inside its limits, and no layer stops it.
Joints · SO-101 follower
1–5 joint · , . jog · [ ] jaw · - + step · h home · f frames
the keys of make drive
The buttons do what the keys do: hold one to repeat.
Limits from the description; speed capped at 1.7434 rad/s, the servo's datasheet derated. Poses from the profile.
Inspector
Code
The repository's own code behind what you do here appears once you move the arm.
Do it
Start the mock and run the safety scenario against it.
make mock make scenario NAME=safety_limitExpect:
PASS— on the mock, where only software can make it pass.In another terminal, send a goal of 180° on the pan directly to the action server, bypassing the client, and read where the joint ends up.
make shell ros2 action send_goal /arm_controller/follow_joint_trajectory \ control_msgs/action/FollowJointTrajectory \ "{trajectory: {joint_names: [shoulder_pan, shoulder_lift, elbow_flex, wrist_flex, wrist_roll], points: [{positions: [3.14159, 0.0, 0.0, 0.0, 0.0], time_from_start: {sec: 2}}]}}" ros2 topic echo /joint_states --onceExpect:
SUCCEEDED— andshoulder_panat 1.9199, its 110° limit, not 3.14.Look for the third layer in the registers the hardware interface knows about, and notice that it is not there.
grep -n "constexpr uint8_t k" src/threevn_hardware/include/threevn_hardware/feetech_protocol.hppExpect: The registers this project uses: id, torque, goal and present position, speed, load, voltage and temperature. No angle limit. The servo has one, in its own memory; nothing here writes it yet.
SUCCEEDED, and you can say which layer catches which failure, and which one the SO-101 does not have yet.When it goes wrong
A limit test passes in Gazebo and fails on the mock.
Why: The test is relying on the simulator's physical joint stop, not on any software.
Fix: Run limit tests on the mock, where nothing physical can stand in for enforcement.
Every goal reports success, and the arm is not where it was told to be.
Why: A clamp below the seam changed the motion and reported success anyway.
Fix: Validate above the seam as well, loudly, so a bad goal fails where it was written.
Terms
- Defence in depth
- Several independent layers enforcing one constraint, each covering a failure the others cannot.
- Command validation
- Rejecting an out-of-range request before it is acted on. Useful; not a safety system.
- Hard stop
- A physical feature of the mechanism that prevents motion beyond a limit — the most trustworthy limit there is.
Every term in the course: glossary.
Check yourself
Answer in your head first, then open it.
Which layer still enforces limits if the host computer crashes?
The servo's own angle limits, stored in its memory. On the SO-101 they are not written yet, so today none of the three does.
The controller manager already clamps everything. Why keep the client-side check?
The clamp is silent and the goal still reports SUCCEEDED. The client rejects loudly, naming the joint, at the point the mistake was made.
Why is none of these a safety system?
All three are software, and depend on software running correctly, even the servo's. A failed servo, a brownout or a collision consults none of them. Safety is the power switch and the hard stop.
Stretch
Design the missing layer. Where in the stack should the servos' angle limits be written: at every start-up, or once, at calibration? From which numbers, given that the servo counts and the profile speaks radians? And what test would prove they were written before the first motion?
Hint
The simulated bus already renumbers a servo when its id register is written, as a real one does. Teaching it two more registers is how the test would run with no arm attached.