Decide how it fails before it fails
You will: Decide, and test on a laptop, what the arm does when a servo, the bus or the host goes wrong.
Builds on Somebody else's protocol, tested on your laptop.
A robot's failure behaviour should be a decision written down before the failure, not a discovery made during it. For a bus of six servos, these are the failures worth deciding in advance, and what this arm does about each:
| failure | what happens | how you know |
|---|---|---|
| a servo does not answer at start-up | the interface refuses to configure, naming the joint and its id | you run it in this lesson |
| the bus connection closes while running | the next write fails, and the controller manager takes the hardware and every controller out of service in that cycle | you run it in this lesson |
| a servo is connected but silent | one missed reply is a glitch and the last state stands; half a second of silence is an error | the Link tests |
| a reply arrives corrupted | its checksum fails, it is dropped, and the parser keeps looking for the next header | the Parse tests |
| the stack is stopped | the hardware is deactivated, and torque is released: the arm goes limp | you run it in this lesson |
| the host stops: a crash, a hang | the servos keep torque on and hold the last goal | not decided yet |
The last row is the hard one, and it is honest to leave it open rather than pretend. A bus servo holds its last goal for as long as it has power. If the computer above it hangs, the arm stays rigid wherever it was. Whether that is safe depends on what it was doing: an arm holding itself up should certainly not let go; an arm pressing into something, or into someone, perhaps should.
The stopped row was wrong until this lesson was written, and how it was
wrong is the point of the lesson. The decision had been made — release
the servos on stop, the safer failure for a person near the arm — and
the hardware interface implemented and tested it. But make stop
killed the stack with -9, which gives the interface no chance to run,
so the decided behaviour only happened on Ctrl-C. Measured on the
simulated bus: after make stop, all six servos still had torque on.
make stop now asks first, with SIGINT, and only forces what has not
exited a few seconds later. A decision is only as good as the paths
that reach it.
And it is still true that the arm goes limp where it is when the stack
stops. That is why the course drives it to rest, a pose it can be left
in, before stopping anything.
In the simulation
The simulation cannot pull a bus or crash a host, but it shows the two rows that decide what the arm does: the last goal written is what a servo holds if the host stops, and when the stack stops the arm goes limp where it is, which is why it is driven to rest first.
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 servo bus, and send the arm to
readywith its button. - Read the six goals. If the host hung now, these are the counts the servos would go on holding, rigid, in the air. Then send the arm to
rest, the pose it can be left in limp. - Press
4forwrist_flex, jog it once with., and watch only its goal and the checksum change. Then press rest again before you would stop anything.
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 a bus with one servo missing: no id 3, the elbow.
make fake-bus IDS=1,2,4,5,6Expect:
fake Feetech bus: 5 servos (ids 1,2,4,5,6) on 127.0.0.1:6560.In a second terminal, try to bring the arm up.
make robot BUS=fakeExpect:
no answer on 127.0.0.1:6560 from: elbow_flex (id 3). Check power, the bus cable, and that each servo was given its id.Then the controller manager exits with code -6. That is the refusal, not a crash: five servos answering out of six is an arm with one joint nobody controls.Stop the bus with Ctrl-C. Start a full one, bring the arm up against it, and from a third terminal check that it moves.
make fake-bus make robot BUS=fake make scenario NAME=homeExpect: Three terminals: the bus, the arm, and
PASSfrom the scenario.Now pull the bus away while the arm is running: Ctrl-C in the bus terminal. Then look, from a shell.
make shell ros2 control list_hardware_components | grep state ros2 control list_controllersExpect:
state: id=1 label=unconfigured, and all three controllersinactive. The arm's log saysDeactivating following hardware components as their write cycle resulted in an error: [ so101_follower ]. One failed write took the whole arm out of service, in one cycle.A bus that stays connected but goes quiet takes a slower path, and the unit tests show it. Run them, in the same shell.
cd /ws/build/threevn_hardware ./test_feetech_system_interface --gtest_filter='Link.*:Shutdown.*'Expect: Five tests: one missed reply is a glitch, a servo that stays quiet is an error, the link recovers when it comes back, deactivation releases the servos, cleanup closes the bus.
Read how
make stopnow stops things: asked first, then told.grep -n -B8 -A4 "^stop: up" Makefile
When it goes wrong
terminate called after throwing an instance of 'std::runtime_error' and exit code -6.
Why: It looks like a crash. It is how the controller manager reacts when hardware refuses to configure.
Fix: Read the FeetechSystemInterface line just above it: it names the servo, or says why the bus could not be opened.
You restarted the bus, and the arm did not come back.
Why: Once a write has failed, the controller manager deactivated the hardware, and it stays down until the stack is restarted. Recovering by itself is only for a servo that went quiet briefly, inside the half second.
Fix: Ctrl-C the arm's terminal and start make robot BUS=fake again.
On the real arm, the joints are stiff after the computer froze.
Why: The host-crash row: the servos hold their last goal with torque on, and nothing told them otherwise.
Fix: Power the servos off at the switch, holding the arm, because it will drop. Deciding what should happen instead is this lesson's exercise.
Terms
- Link lost
- The hardware interface's verdict that the servos have stopped answering, reached after half a second of silence rather than on the first missed reply.
- Safe failure state
- What a machine does when it can no longer be controlled. For an arm there is rarely one right answer: limp drops what it holds, rigid holds whatever it was doing.
- Graceful shutdown
- Asking a process to stop so it can run its own clean-up, before forcing it. For this arm, the clean-up is releasing the servos.
Every term in the course: glossary.
Check yourself
Answer in your head first, then open it.
Why does the interface wait for half a second of silence before calling the link lost, instead of failing on the first missed reply?
A single missed reply happens on any real bus: noise, a slow servo. Failing on one would stop the arm for glitches. Half a second is long enough to mean something is wrong, and short enough that the controllers stop acting on stale positions quickly.
make stop used to kill everything with -9. Why did that matter for the real arm?
-9 gives the hardware interface no chance to deactivate, so torque was never released: the arm stayed rigid, holding its last goal, though the decided behaviour on stop was to let go.
When the host crashes, the arm stays rigid. Why is that not simply wrong?
Rigid is right for an arm holding itself up, or holding something over a bench. It is wrong for an arm pressing into something. The right answer depends on what it was doing, which is why it is a decision to make, not a bug to fix.
Stretch
Decide the last row. Write down what the SO-101 should do when the host has sent nothing for one second, for each of: resting, holding a pose in the air, and gripping an object. Then say where that behaviour could live, given that the thing that failed is the host itself.
Hint
Anything that runs on the host has failed along with it. Look for what is still running when it is not: the servos themselves, or something between them and their power supply.