Reaching a point is only the beginning. A useful manipulator must follow a moving reference, correct its errors and avoid the objects around it. This follow-up turns our 3-DOF arm into a trajectory tracker—and asks what we can actually prove about its behaviour.
In the first tutorial, we derived forward and inverse kinematics. Here we keep the same yaw–pitch–pitch geometry, derive its Jacobian, build a velocity controller and examine Lyapunov stability. Then we introduce spherical obstacles and a control-barrier safety filter.
Follow a path, then put something in the way
Press Run simulation. The dashed curve is the desired tool path; the solid trace is what the robot achieves. The default sphere intersects the reference path, so perfect tracking and clearance cannot both be satisfied. Turn Obstacle avoidance off to compare the same starting state and reference.
Explore the workspace: drag the background to orbit the 3D camera, scroll or pinch to zoom, and use Shift-drag or right-drag to pan. The camera controls remain available while the arm moves. Drag a sphere to reposition it; choose View, XY, XZ or YZ as the drag plane. On touchscreens, two fingers zoom and pan.
Lengths in metres, angles in radians internally. The simulator commands joint velocities. It does not model motor torque, inertia, joint flexibility, ground collision or self-collision. Obstacles are static while the arm runs. Editing an obstacle pauses at the current pose and reference time; Run resumes there after a valid placement. Path and controller changes reset the experiment.
1. See the safety–tracking trade-off
Run the default circle with avoidance on, then off. Compare the minimum clearance with the dashed 6 cm threshold. Observe when V increases as the desired point moves through the obstacle.
2. Test the Lyapunov prediction
Select no obstacles and Hold a fixed target. Set damping to zero. With the default speed limit, the initial error decays close to the predicted exponential; small integration errors remain.
3. Explain tracking lag
Select a moving path, no obstacles, and turn velocity feedforward off. Feedback must create an error before it can command motion. Re-enable feedforward and compare the residual error.
4. Stress the assumptions
Choose the figure eight, shorten the period and lower the joint speed limit. More constraints become active. A larger feedback gain cannot make an infeasible reference feasible.
Differentiate the arm geometry
Let \(\mathbf q=[q_1,q_2,q_3]^T\) contain the base yaw, shoulder pitch and elbow pitch. The two links have lengths \(L_1,L_2\), and the shoulder height is \(h\). Define the signed radial reach \(r\) and vertical offset \(z_r\):
For this laboratory, \(L_1=1.4\) m, \(L_2=1.1\) m and \(h=0.45\) m. The coordinate and positive-angle conventions follow Part 1.
A small joint motion produces a Cartesian motion through the position Jacobian, \(J=\partial f/\partial\mathbf q\). For example, \(\partial r/\partial q_2=-z_r\) and \(\partial r/\partial q_3=-L_2\sin(q_2+q_3)\). Differentiate all three position coordinates to obtain:
Its determinant is \(\det J=-rL_1L_2\sin q_3\). The position map loses rank when the tool lies on the yaw axis, \(r=0\), or when the planar links are fully extended or folded, \(\sin q_3=0\). A Cartesian request in a missing velocity direction cannot be recovered by simply increasing the controller gain. Haviland and Corke's differential-kinematics tutorial develops this velocity-level viewpoint in more general manipulators.
A trajectory has both a position and a velocity
A path describes a geometric curve. A trajectory also specifies where to be at each time. For a horizontal circle with centre \(\mathbf c\), radius \(a\), period \(T\) and angular frequency \(\omega=2\pi/T\), we choose:
The lab uses \(\mathbf c=(1.35,0,1.00)\) m. Path size changes \(a\); period changes the speed without changing the geometric curve.
The 3D figure eight uses offsets \([a\cos\omega t,\;0.7a\sin2\omega t,\;0.16\sin\omega t]^T\). The smooth sweep uses \([a\cos\omega t,\;0.15\sin\omega t,\;0.20\sin\omega t]^T\); Hold fixes the offset at \([a,0,0]^T\). Their velocities are the analytical time derivatives. No finite-difference estimate of reference velocity is needed.
Combine feedforward with error correction
Define position error as actual minus desired: \(\mathbf e=\mathbf p-\mathbf p_d\). If Cartesian velocity were directly available, a natural command would be \(\mathbf v_c=\dot{\mathbf p}_d-k\mathbf e\), with \(k>0\). Feedforward supplies the planned motion; feedback corrects deviations. This is the velocity-control setting discussed in Modern Robotics.
This calculation assumes an invertible Jacobian, an accurate model and joint drives that execute the requested velocities. It also assumes the trajectory can be followed without violating constraints. A three-joint arm controlling three position coordinates has no spare joint velocity at a regular configuration: \(J^{-1}\mathbf v_c\) already uses all three degrees of freedom.
Regularise the inverse near a singularity
The implemented nominal command uses a damped least-squares inverse. It solves a small regularised velocity-matching problem:
With metres and radians as used here, \(J\) and \(\lambda\) carry compatible length scaling. The numerical value of \(\lambda\) is tied to these units. At \(\lambda=0\), the formula requires full rank.
Positive damping reduces large joint commands but introduces velocity mismatch. Joint speed and position limits are enforced separately by the optimisation described below. If damping is zero and the matrix cannot be reliably solved, the simulation pauses and asks for more damping.
Prove the ideal tracking error decays
Lyapunov's direct method studies a scalar function along closed-loop solutions. It lets us establish stability without first solving every nonlinear trajectory; Tedrake's Lyapunov notes explain this framework. For our position error, choose
Here \(V>0\) for nonzero error and \(V=0\) exactly at zero error. With the exact unconstrained controller, integrating the scalar equation gives
Stability means a sufficiently small initial error stays small. Asymptotic stability additionally requires that the error tends to zero. This equation establishes exponential convergence of the position error while the assumptions remain valid. It does not establish global stability of every joint configuration: inverse branches are nonunique, joint limits exist and singularities can interrupt the feedback law.
Check a numerical point by hand
Take \(L_1=1.4\) m, \(L_2=1.1\) m and \(\mathbf q=(0,\pi/4,-\pi/2)\). Then \(r\approx1.7678\) m and \(z_r\approx0.2121\) m. For \(\mathbf e=(0.04,-0.03,0.02)\) m, \(\dot{\mathbf p}_d=(0,0.10,0)\) m/s and \(k=3\) s\(^{-1}\):
Turn obstacle clearance into a velocity constraint
A collision-free tool position does not imply a collision-free arm. Model each moving link as a capsule: a line segment thickened by radius \(r_\ell=0.045\) m. For an obstacle sphere of centre \(\mathbf o\) and radius \(R_o\), find the closest centreline point on each link:
The endpoints are shoulder–elbow for the upper link and elbow–tool for the forearm. Inflate the obstacle by the link radius and the requested clearance \(d_s=0.06\) m. Define one barrier value for each obstacle–link pair:
For the squared closest-distance derivative, use \(J_s=(1-\tau)J_A+\tau J_B\). The extra term involving \(\dot\tau\) drops out: at an interior closest point, \((\mathbf s-\mathbf o)^T(\mathbf B-\mathbf A)=0\); at a persistent endpoint optimum, \(\tau\) is fixed. This gives the distance gradient without differentiating the clip operation explicitly.
The shoulder Jacobian is zero. The elbow Jacobian follows by differentiating its coordinates, exactly as for the tool:
The fixed base capsule uses radius 0.08 m. It cannot move to escape an obstacle; an overlap with its required margin is rejected at the start. The moving-link constraints include the tool endpoint automatically.
Dragging edits a static scene while the arm is paused. The new placement is checked against the current complete arm before it is accepted; an overlap is rejected and the previous obstacle position restored. Each accepted edit starts a fresh diagnostic-history segment, preserving the robot pose and reference clock. Physically moving obstacles during execution would require their velocity in the barrier derivative.
Why the barrier condition preserves clearance
In the continuous-time model, \(\dot b\ge-\alpha b\) implies \(b(t)\ge b(0)e^{-\alpha t}\). Starting from \(b(0)\ge0\), the state remains in the safe set if the condition can be enforced throughout the motion and the closed-loop solution is well defined. The CBF quadratic-program framework of Ames and coauthors formalises this forward-invariance idea. This argument is a clearance statement, not a proof that the robot reaches its goal.
Project the tracker onto feasible joint velocities
At each simulation step, solve a three-variable quadratic programme. Its objective is to change the nominal joint-velocity command as little as possible while satisfying obstacle constraints and joint bounds:
Here \(\mathbf a_j^T=2(\mathbf s_j-\mathbf o_j)^TJ_{s_j}\), \(\beta=4\) s\(^{-1}\), and the joint intervals in degrees are \([-150,150]\), \([-20,140]\), and \([-160,-10]\). Obstacles stay fixed during each run.
For a valid safe state with static obstacles, zero joint velocity satisfies all these inequalities. That provides a feasible fallback in the mathematical QP; it may mean stopping instead of tracking. The small solver checks the Karush–Kuhn–Tucker conditions by enumerating up to three independent active constraint normals. All computations stay inside the article; the simulator downloads no control library.
A three-DOF position tracker cannot generally keep its tool on an obstacle-crossing reference and also maintain clearance. This filter has no global route search. It can slow, deviate, or wait; it can also become stuck at a configuration from which local admissible motions do not make progress. A collision-free global path and time parameterisation are separate planning problems.
What damping and obstacles change in the proof
Let \(P_\lambda=JJ^T(JJ^T+\lambda^2I)^{-1}\), and write the executed velocity as \(\dot{\mathbf q}=\dot{\mathbf q}_{\mathrm{nom}}+\delta\mathbf u\). The correction includes the safety filter, joint limits and any swept-step reduction. With feedforward enabled, the actual error dynamics are
The first term reduces error. The other terms can oppose it. With a moving target, damping can create tracking lag. An obstacle can force the arm to move away from the desired point. The lab therefore displays actual \(\dot V=\mathbf e^T(J\dot{\mathbf q}-\dot{\mathbf p}_d)\) alongside the ideal value \(-2kV\); it does not impose a hard Lyapunov-decrease constraint in the QP.
For a more precise bound, suppose the Jacobian's smallest singular value stays at least \(\sigma_*>0\) in the region visited, damping is fixed, and \(\|\dot{\mathbf p}_d\|\le v_*\), \(\|J\delta\mathbf u\|\le d_*\). Then
Under those uniform assumptions, the bound is strictly negative outside the error ball \(\|\mathbf e\|\le\eta/(k\mu)\). This supports an ultimate-bound argument while the solution remains in that regular region. The simulator does not compute a certified \(\sigma_*\) or \(d_*\), so the formula is an analytical condition rather than an automatically certified performance radius.
A temporary positive \(\dot V\) does not by itself prove instability. It tells us that this error measure is increasing at that instant. For an obstacle-crossing reference, nonzero error is unavoidable; the original zero-error exponential proof no longer applies to the constrained motion.
Check the motion between samples
The integrator uses a fixed step \(\Delta t=1/120\) s and \(\mathbf q_{n+1}=\mathbf q_n+\Delta t\,\mathbf u_n\). A continuous-time barrier inequality checked only at sample times is not, by itself, a sampled-data collision guarantee.
The lab adds a conservative geometric check along the linearly interpolated joint motion. For any corresponding point on either moving centreline, an angular increment \(\Delta\mathbf q\) gives the displacement bound
At the midpoint of an interval, if every obstacle–capsule clearance exceeds the requested margin by at least \(B/2\), the entire interpolated interval is certified clear by this bound. Otherwise the check bisects the interval, up to six levels. Uncertainty rejects the candidate step; the commanded motion is halved and checked again. If no candidate can be certified after ten attempts, the run pauses.
This check applies to the specified capsules, fixed spheres and joint interpolation, within numerical tolerance. It does not cover unmodelled geometry, moving obstacles or hardware dynamics. Turning avoidance off deliberately disables this check so that the baseline can demonstrate collisions.
| Observation | Interpretation |
|---|---|
| V decays close to an exponential | The exact-tracking assumptions are approximately satisfied. |
| Clearance holds while tracking error grows | The constrained tracker is prioritising separation from obstacles. |
| V settles above zero | Check damping, missing feedforward, speed limits and reference feasibility. |
| The arm pauses or stalls | A local feasible velocity or a certifiable integration step may not provide progress. |
| The tool is clear but a link collides in the baseline | End-effector-only checks would have missed a whole-arm collision. |
Use Export recent CSV to inspect up to the last 120 seconds of sampled positions, joint angles, executed velocities, error, V, actual V̇, clearance and command corrections. The curves show recent history; they are diagnostics from one numerical run, not a stability certificate.
From local tracking to planned motion
We now have a complete velocity-level loop: differentiate the geometry, track a timed reference, measure its error and constrain motion near obstacles. A useful next step is to plan a feasible path before tracking it, then add acceleration limits and a torque-level robot model. Each extension changes the assumptions required by the stability argument.
- Haviland & Corke, Manipulator Differential Kinematics: Part 1 — Jacobians and velocity-level control.
- Lynch & Park, Modern Robotics, motion control with velocity inputs — feedforward and feedback.
- Tedrake, Underactuated Robotics: Lyapunov Analysis — stability reasoning and its assumptions.
- Ames, Xu, Grizzle & Tabuada, Control Barrier Function Based Quadratic Programs for Safety Critical Systems — safety constraints and forward invariance.

Comments
Ask a question, share a result, or add something useful.
Be the first to comment.Start the conversation below.
Post a Comment