Solve the kinematics, and find out what the arm cannot do
You will: Turn a position into joint angles for a five-joint arm, and map the arm's real workspace.
Builds on A robot is a tree.
Forward kinematics — joint angles in, tool position out — is matrix multiplication down the tree. Inverse kinematics is the question you actually have: the cube is there; what angles put the jaw on it?
For a simple arm it has a closed form, a formula, and this project wrote one. On the SO-101 that formula refuses to run, and the refusal is the first result worth having: it needs exactly four driven joints with the shoulder turning about one particular axis, and this arm has five, with its axes written in rotated frames. A closed form applied to an arm it does not fit does not fail — it returns angles that are wrong. A guard that refuses, with the true reason, is worth more than one that passes.
So the SO-101 is solved numerically: start from a guess, compute where the tool is, and step the joints to shrink the error, until it is small enough or clearly cannot be. That needs a stopping rule, a way to choose among the many answers a five-joint arm has for one position — its wrist roll is free for most of them — and a way to say "out of reach" rather than "nearly".
Then the useful map: sweep the bench and record, for every point, whether the jaw can reach it pointing down. The SO-101's elbow bends both ways and its links are longer than many small arms', so its top-down workspace should be larger. Should is not a measurement; this lesson makes it one.
In the simulation
Game mode is the same idea as this lesson's solver, felt by hand: each frame, a small damped-least-squares step towards where the keys ask. Reach the cube that way, then type in the answer the solver gives for it: a different set of five angles, the same point. Then find the two kinds of no: under the bench, and past the side.
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
- Click the 3D view, press
G, and bring the jaw down onto the cube, within 6 cm of the bench. - Now the solver's answer for the cube, jaw straight down, from the steps below. In Joints, set shoulder_pan to −23.7°, shoulder_lift +36.7°, elbow_flex −34.0°, wrist_flex +87.4° and wrist_roll −94.8° (the solver prints radians: −0.414, +0.640, −0.594, +1.525, −1.654). Other angles, the same point.
- Under the bench is the solver's "no solution found": drive the tool down until a link turns red.
- Past the side is the other no. Swing
shoulder_panto its upper limit, with the tool more than 25 cm to the arm's right: the edge of the map.
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
Ask the closed form first, and map where the jaw can point straight down. It refuses, says why, and the numerical solver maps it instead. The map takes about a minute and a half.
make workspaceExpect:
closed form refuses: closed-form IK needs exactly 4 driven joints between 'base_link' and 'gripper_frame_link'; this chain has 5. Then the map, andat 180 deg: radius 60-280 mm, height -40 to +80 mmand17% of the reachable area can be picked from at 180 deg.The same question for the arm the closed form was written for.
make workspace PROFILE=threevn_arm_v1Expect:
at 180 deg: radius 200-200 mm, height -50 to -40 mmand1%: one ring below its own base. The SO-101's top-down workspace is larger, as the body predicted, and now it is a measurement.Read the solver's contract, and its stopping rule.
sed -n '/^def solve/,/^ chain = /p' src/threevn_control/threevn_control/kinematics.pyExpect: Converged means within
tolerancemetres, and the jaw withinangle_tolerancewhenpointingis given; anything else raisesUnreachablewith the closest the tool got.Solve the cube's position, three centimetres up, jaw down and position only.
make workspace AT="0.27 0.11 0.03"Expect: Two answers for one point: jaw at 180 deg,
shoulder_pan -0.414 ... wrist_roll -1.654, and position only, a different five,shoulder_pan -0.444 ... wrist_roll -0.012. Many answers, and the solver picks the one nearest where it started.Ask for two points it cannot reach, and read how differently it refuses.
make workspace AT="0.6 0 0.2" make workspace AT="0.05 0 -0.2"Expect: The first:
578 mm from 'shoulder_pan'; the arm reaches at most 478 mm, a proof, without iterating. The second:no solution found: the closest was 7.9 mm away, evidence from every start tried, and it says so.Run the solver's tests.
make shell cd /ws/src/threevn_control python3 -m pytest test/test_numerical_ik.py -qExpect:
23 passed: round trips on every arm profile, with and without the jaw's direction, the nearest-answer rule, both refusals, and the closed form refusing the SO-101.
make workspace reports the closed form's refusal and the SO-101's top-down map, make workspace AT="0.27 0.11 0.03" gives two different answers for one point, and the solver's 23 tests pass.When it goes wrong
make workspace sits there for a minute or more.
Why: The map solves every cell twice, numerically, and a cell with no answer costs every restart before the solver gives up on it.
Fix: Wait for it; AT="x y z" solves one point in a moment.
The tests say skipped, or make workspace says the description is not fetched.
Why: The SO-101's description is upstream's, fetched rather than committed.
Fix: make so101-fetch, once.
The sliders are set to the solver's answer and the jaw is not on the cube.
Why: A sign dropped, or radians read as degrees. The solver prints radians, the sliders show degrees; −1.654 rad is −94.8°.
Fix: Check each slider against the five values, signs first.
Terms
- Inverse kinematics (IK)
- Finding the joint angles that put the tool at a given position and orientation. Closed form when a formula exists, numerical when it does not.
- Workspace
- Every position the tool can reach, often only with some orientations. Measured, not assumed.
- Structural guard
- A check that a method's assumptions hold before it runs — here, that an arm has the joints a closed form was derived for.
Every term in the course: glossary.
Check yourself
Answer in your head first, then open it.
Why does the closed form refuse the SO-101 instead of returning an answer?
It was derived for four driven joints with the shoulder turning about Z. On five joints it would not fail; it would return angles that are wrong. The guard checks the structure first and refuses, with the reason.
Why are "578 mm from shoulder_pan" and "no solution found" different kinds of answer?
The first is a proof, the links laid end to end cannot get there. The second is a numerical solver failing to find an answer from every start it tried, which is evidence, not proof, and the message says which it is.
The solver returns one answer for a point that has many. Which one, and why that one?
The one nearest where it started, because each damped-least-squares step takes the smallest joint change. On a robot, that is the answer that moves the arm least from where it is.
Stretch
Find what the solver does when a descent ends with a joint pressed against its limit, and why. Then pick a point near the cube and solve it with make workspace AT=... from the default start and from a seed of your choice in the shell, and compare the two answers.
Hint
Search kinematics.py for pressed; the wrist roll is the joint it is usually about.