Kinematics says where the robot should go. This course explains what it takes to really get there: the forces and torques (dynamics), the motors and gearboxes that produce them, the sensors that measure the result, and the control laws that close the loop, from a simple PID to force control and trajectory generation. It also covers the imperfections of real robots: friction, backlash, vibration.
The big picture
A robot is a feedback machine. Every millisecond the same cycle runs:
Plan: the trajectory generator says where each joint should be now (lesson 7).
Sense: encoders, current and force sensors measure what happened (lesson 3).
Compute: the control law turns the error into a torque request (lessons 4, 5, 6) using the dynamic model (lesson 1).
Act: the drive sends current to the motor, the gearbox multiplies the torque (lesson 2).
Lessons 8 and 9 show how all this is organised in a real controller and what the real world adds.
1
Dynamics: forces, torques and the equation of a robot
14 min
You will learn
why a robot needs torque to hold still and to accelerate, and how this is written in one equation.
1.1 Kinematics is not enough
Kinematics ignores mass: it says “joint 2 must be at 40° at time 0.5 s”. But a motor does not produce an angle, it produces a torque. To know which torque is needed we need dynamics: the relation between torques and motions. Without it, a robot cannot be sized (which motor?), simulated, or controlled well at high speed.
1.2 One link, by hand
A link of mass m whose centre of mass is at distance l from the joint, turning in a vertical plane (θ is measured from the horizontal). Newton for rotation: the torque of the motor, minus the torque of gravity, minus friction, equals inertia times angular acceleration.
τ = Iθ̈ + bθ̇ + mgl cos θ
Worked example
A 2 kg point mass at the end of a weightless 0.5 m arm: I = m·l² = 2 × 0.25 = 0.5 kg·m². To hold it horizontally: τ = mgl = 2 × 9.81 × 0.5 = 9.81 N·m, with no motion at all. To also accelerate it at 10 rad/s²: add Iθ̈ = 0.5 × 10 = 5 N·m, so 14.8 N·m. Hold it vertical (θ = 90°): gravity needs 0.
1.3 The equation of a robot
For a robot with n joints the same idea gives the dynamic model, found with the Lagrange method (energies) or the Newton–Euler method (forces, link by link):
M(q) q̈ + C(q, q̇) q̇ + g(q) + f(q̇) = τ
Term
Name
Meaning
M(q) q̈
Inertia
Torque to accelerate. M depends on the pose: an arm stretched out is much harder to turn than a folded one.
C(q, q̇) q̇
Coriolis and centrifugal
Torques caused by the velocities of the other joints. Small at low speed, large when fast.
g(q)
Gravity
Torque to hold the robot still. Depends only on the pose and the payload.
f(q̇)
Friction
Viscous (proportional to speed), Coulomb (constant, opposite to the motion) and the Stribeck bump at very low speed.
The two-joint arm (point masses at the ends of the links)
M11 = (m1+m2)L1² + m2L2² + 2m2L1L2 cos θ2, M12 = m2L2² + m2L1L2 cos θ2, M22 = m2L2²
With h = m2L1L2 sin θ2, the Coriolis and centrifugal terms are −h(2θ̇1θ̇2 + θ̇2²) on joint 1 and +hθ̇1² on joint 2. Note the coupling: moving joint 2 produces a torque on joint 1.
1.4 Using the model
Sizing: find the peak and RMS torques of a task and choose motors and gearboxes (lesson 2).
Simulation: integrate the equation to test a controller before touching the robot.
Control: compute feedforward torques (lesson 5).
Identification: the masses, centres of mass and friction are rarely known exactly; they are measured by running test motions and fitting the equation (it is linear in the inertial parameters).
Payload check: a heavier tool changes M and g; the controller must be told the payload data.
Key terms
dynamics
torque
inertia
Lagrange / Newton–Euler
Coriolis
gravity compensation
friction
payload
Check yourself
A 4 kg point mass is at the end of a weightless 0.3 m arm, horizontal. What torque holds it?
τ = m g l = 4 × 9.81 × 0.3 ≈ 11.8 N·m.
Why is a stretched arm harder to accelerate than a folded one?
The inertia grows with the square of the distance of the masses to the joint (I = m l²), so M(q) is largest when stretched.
What is the difference between the gravity term and the Coriolis term?
Gravity exists at rest and depends only on the pose. Coriolis exists only when joints move (velocity products).
the main kinds of actuators, why a gearbox is almost always needed, and how to choose a motor for a joint.
2.1 The kinds of actuators
Actuator
Strengths
Weaknesses
Typical use
Brushless motor (BLDC / PMSM)
High torque density, efficient, long life, precise with an encoder.
Needs an electronic drive (commutation).
Almost every modern robot joint.
Brushed DC motor
Simple, cheap, easy to drive.
Brushes wear out, noise, lower power density.
Toys, small educational robots.
Stepper motor
Position without a sensor (open loop), cheap, holds position.
Loses steps if overloaded, vibrates, low speed torque only, heats.
3D printers, gantries, small arms.
Hobby servo
Motor + gearbox + sensor + electronics in one box.
Low precision and speed control, plastic gears.
Education, RC models.
Hydraulic cylinder
Huge force, compact, robust.
Pump, oil, leaks, noise, hard to control precisely.
Excavators, heavy legged robots, forging.
Pneumatic cylinder
Cheap, fast, clean, naturally compliant.
Air is compressible: poor position control.
Grippers, pick and place between two stops.
Series elastic actuator (SEA)
A spring between motor and load measures and softens the torque.
Lower bandwidth, extra mechanics.
Cobots, exoskeletons, legged robots.
Artificial muscles, shape-memory alloys, piezo
Light, silent, bio-inspired, or nanometre precise.
Low force or stroke, hysteresis, special drives.
Soft robots, micro-positioning.
2.2 Why a gearbox?
An electric motor is fast and weak (for example 3000 rpm and 0.1 N·m); a robot joint is slow and strong (for example 30 rpm and 10 N·m). A gearbox with ratio N turns one into the other:
τjoint = N · η · τmotor, ωjoint = ωmotor / N, Jreflected = N² · Jmotor
The efficiency η (0.6 to 0.95) accounts for the losses. The last relation matters a lot: the motor inertia seen from the joint is multiplied by N². With a high ratio, the motor inertia dominates the arm inertia, and the joints are almost independent of each other (lesson 5), but the robot is hard to back-drive (to push by hand) and forces cannot be felt through the gearbox.
Gearbox
Ratio
Backlash
Notes
Spur / planetary
3 – 100
small to medium
Robust, cheap, back-drivable at low ratio.
Harmonic drive (strain wave)
50 – 160
almost zero
Compact and precise; flexible, so it adds elasticity. Very common in robot wrists and cobots.
Cycloidal / RV
30 – 200
very small
Stiff and shock-resistant: base and shoulder of industrial robots.
Belt, cable, tendon
2 – 10
small
Light, allows the motor to sit near the base. Elastic.
Direct drive (no gearbox)
1
none
Very accurate and back-drivable, but large and heavy motors for the torque.
Worked example: choose a motor for a joint
A joint must give 10 N·m (peak) at 2 rad/s (19 rpm). Gearbox: N = 100, η = 0.8.
Motor speed: 2 × 100 = 200 rad/s ≈ 1910 rpm.
Motor torque: 10 / (100 × 0.8) = 0.125 N·m.
Mechanical power at the joint: 10 × 2 = 20 W; at the motor: 0.125 × 200 = 25 W.
Check: the motor must give 0.125 N·m continuously (RMS) and about 2 to 3 times that at peak, at 1910 rpm, without overheating. A 50 to 100 W BLDC motor with margin is fine. Also check that the reflected inertia 100² × Jmotor is not more than a few times the load inertia.
Remember
The torque that matters for heating is the RMS torque over the whole cycle, not the peak.
Torque is proportional to current: τmotor = Kt · I. The drive controls the current.
Brakes: a robot arm falling when power is cut is dangerous, so most joints that carry gravity have a spring-applied brake.
Key terms
brushless motor
stepper
gear ratio
harmonic drive
backlash
reflected inertia
RMS torque
brake
Check yourself
A motor gives 0.2 N·m at 3000 rpm. With a 50:1 gearbox of efficiency 0.8, what do you get at the output?
A gearbox of ratio 100 is used and the motor inertia is 2·10⁻⁵ kg·m². What inertia does the joint feel?
N² × J = 10 000 × 2·10⁻⁵ = 0.2 kg·m².
Why do most robot arms use harmonic or cycloidal gearboxes rather than ordinary gears?
They combine a high ratio, compactness and almost no backlash, which is needed for precise positioning.
3
Joint sensors: how the robot knows what it is doing
12 min
You will learn
the sensors inside a robot (proprioception) and what resolution, accuracy and noise really mean.
Sensors that measure the robot itself are proprioceptive (like your sense of where your limbs are with your eyes closed). Those that measure the world are exteroceptive (cameras, lidar…; see the “Perception” course).
Sensor
Measures
How it works
Notes
Incremental encoder
Angle changes
A disc with slits and a light sensor: counts pulses (two channels A and B give the direction).
Cheap. Forgets the position when switched off: needs a homing move.
Absolute encoder
Angle
Each position has a unique code (optical or magnetic), often multi-turn with a small battery or gears.
Robot knows its pose at power-on. Standard in modern arms.
Resolver
Angle
A small rotating transformer, analogue.
Very robust to heat, shock and dirt.
Potentiometer / Hall sensor
Angle (coarse)
Variable resistance or magnetic field.
Cheap; used in hobby servos.
Motor current sensor
Torque (estimated)
The torque is proportional to the current (Kt).
Free, but friction in the gearbox blurs the estimate. Used to detect collisions.
Joint torque sensor
Torque (measured)
Strain gauges on a flexible part of the joint.
Needed for precise force control and safe cobots.
6-axis force / torque sensor
Force (3) and moment (3) at the wrist
Strain gauges on a small elastic body.
Assembly, polishing, hand guiding (lesson 6).
IMU (accelerometer + gyroscope)
Acceleration, angular rate
MEMS sensors.
Mobile and legged robots, drones, vibration monitoring.
Limit switch, proximity sensor
End of travel
Mechanical or inductive contact.
Homing and safety.
3.1 Resolution, accuracy, repeatability
Resolution: the smallest change that the sensor can show. A 17-bit encoder gives 217 = 131 072 counts per turn, i.e. 0.0027° per count.
Accuracy: how close the reading is to the true value. A good encoder can have a high resolution but a poor accuracy (eccentric disc, temperature).
Repeatability: how close the readings are when the same situation is repeated. Industrial robots are very repeatable (±0.02 mm) but less accurate (a fraction of a millimetre, until calibrated).
Noise and quantisation: differentiating an encoder to get the speed amplifies both; speed is filtered (or estimated with an observer).
Worked example: resolution at the tool
A 17-bit encoder on the motor, with a 100:1 gearbox: one count is 360° / (131 072 × 100) = 0.0000275° at the joint (0.48 µrad). At the end of a 1 m arm this is 0.48 µm: the sensor is far finer than the mechanics. In practice the limit is the elasticity and the backlash of the gearbox: that is why robots often add a second encoder on the output side (dual encoder) to measure the real joint angle.
Remember
Absolute encoders remove the homing step; incremental ones need it.
Motor-side measurement is precise but does not see the gearbox elasticity; output-side measurement does.
Current is a free, rough torque sensor; strain gauges are a true torque sensor.
Key terms
proprioceptive
encoder
homing
resolution
accuracy
repeatability
force / torque sensor
IMU
Check yourself
What is the angular resolution of a 12-bit absolute encoder?
360° / 4096 ≈ 0.088° per count.
A robot is switched on and does not know its pose until it makes a small calibration move. What sensor type does it have?
Incremental encoders: they only count changes and need homing.
An industrial robot is repeatable to ±0.02 mm but 0.5 mm off the programmed point. Which word describes each fact?
Repeatability ±0.02 mm; accuracy 0.5 mm. Calibration improves accuracy, not repeatability.
4
Feedback and PID control
14 min
You will learn
how a feedback loop works, what P, I and D each do, and how to tune a joint controller.
4.1 Open loop and closed loop
Open loop: send a command and hope (a stepper motor, an oven timer). Closed loop (feedback): measure the result, compute the errore = wanted − measured, and correct. Feedback fights the things that the model does not know: friction, payload changes, a push. Almost all robot joints are closed loops.
4.2 The PID law
u(t) = Kpe(t) + Ki ∫ e(t) dt + Kdė(t)
Term
What it does
If too large
If too small
P (proportional)
Pushes in proportion to the error now: like a spring pulling to the target.
Overshoot, oscillation, instability.
Slow, large remaining error.
I (integral)
Accumulates the error over time: removes the permanent error (against gravity or friction).
Overshoot, slow oscillation, windup.
Error stays forever.
D (derivative)
Reacts to the speed of the error: a damper that brakes before the target.
Amplifies sensor noise, buzzing.
Overshoot and ringing.
Worked example: a joint with inertia
Joint inertia J = 0.5 kg·m², no friction. With a PD law, Jθ̈ + Kdθ̇ + Kpθ = Kpθd: a mass-spring-damper with natural frequency ωn = √(Kp/J) and damping ratio ζ = Kd / (2√(KpJ)). To get ωn = 10 rad/s and ζ = 1 (no overshoot): Kp = Jωn² = 50 N·m/rad and Kd = 2 × 1 × √(50 × 0.5) = 10 N·m·s/rad.
Now add gravity: a 2 kg mass at 0.5 m needs 9.81 N·m to be held. With P only, the arm settles where Kpe = 9.81, that is e = 9.81 / 50 ≈ 0.2 rad ≈ 11°. That is the steady-state error. Cures: add the integral term, or better, add the gravity torque g(q) as feedforward (lesson 5).
4.3 Tuning and good practice
Manual tuning: start with Ki = Kd = 0, raise Kp until it is fast but starts to overshoot, add Kd to damp it, add a little Ki to remove the remaining error.
Ziegler–Nichols (closed loop): with P only, raise Kp until the output oscillates steadily: you get the ultimate gain Ku and the period Tu. Then Kp = 0.6 Ku, Ti = Tu/2, Td = Tu/8, i.e. Ki = Kp/Ti and Kd = KpTd. For Ku = 20 and Tu = 0.2 s: Kp = 12, Ki = 120, Kd = 0.3. It is a starting point, usually a bit aggressive.
Anti-windup: when the actuator saturates (maximum current), stop integrating, otherwise the integral grows and causes a big overshoot afterwards. Try the saturation switch in the widget.
Derivative on the measurement (not on the error) avoids a spike at each change of target; filter it to limit noise.
Feedforward: add to the output the torque that the model predicts (speed, acceleration, friction, gravity). The feedback then only has small errors to correct.
4.4 Three nested loops
A servo drive does not use a single loop but three, from the fastest to the slowest: the current loop (torque, 10 to 20 kHz), the velocity loop (1 to 4 kHz), the position loop (0.5 to 1 kHz). Each loop is about 5 to 10 times slower than the one inside it, so that the inner loop looks “instant” to the outer one. Tune from the inside to the outside.
Key terms
feedback
error
PID
overshoot
steady-state error
windup
cascaded loops
feedforward
Check yourself
An arm under gravity is controlled by P only and stops 5° from the target. Which term removes this error?
The integral term (or a gravity feedforward). It accumulates the error until the motor torque balances gravity.
J = 2 kg·m². You want ωn = 5 rad/s and ζ = 1. What Kp and Kd?
The electrical dynamics are the fastest; and each outer loop needs the inner one to be much faster so that it behaves like an ideal torque source.
5
Controlling a whole robot: gravity compensation and computed torque
12 min
You will learn
why independent PIDs work on geared robots, and how the model makes the control much better.
5.1 Independent joint control
The simplest controller gives each joint its own PID and ignores the others. In the dynamic model the coupling between joints is in M(q) and C. With a large gear ratio the motor inertia (N² Jm) is much bigger than the variation of the arm inertia, so each joint almost behaves like an isolated one and the other joints are small disturbances for the feedback. This is how most industrial robots are controlled at moderate speed.
5.2 PD plus gravity compensation
τ = Kp (qd − q) − Kdq̇ + g(q)
The model is used only for the gravity term. This removes the steady-state error without any integral, and it can be proved that the robot converges to any target (Takegaki and Arimoto). The price: g(q) must be accurate (payload data!). This is the standard way to hold a robot still and to make a cobot light to hand-guide.
5.3 Computed torque (inverse dynamics control)
To follow a fast trajectory (qd, q̇d, q̈d) the model is used completely:
Put this torque in the robot equation: the terms C, g cancel exactly and M multiplies the bracket on both sides, leaving a linear error equation, the same for every joint and every pose:
ë + Kdė + Kpe = 0
Worked example
Choose ωn = 20 rad/s and ζ = 1: Kp = ωn² = 400 and Kd = 2 ζωn = 40. The error dies out like e−20t (a time constant of 50 ms), reaching 2 % in about 0.3 s, whatever the pose and the speed. That is what independent PIDs cannot promise.
Watch out
The cancellation is perfect only if the model is perfect. Real masses, friction and gearbox elasticity are never exactly known, and the computation must run in the fast loop. In practice the model is used as a feedforward (computed from the desired trajectory) with PD/PID feedback on top: robust, and no problem if the model is 10 % wrong.
5.4 Beyond: robust, adaptive, optimal, learning
Method
Idea
Robust / sliding-mode control
Add a term that dominates the worst-case model error; very robust, may chatter.
Adaptive control
Estimate the unknown parameters (payload) online and update the model.
Model predictive control (MPC)
Optimise the next second of motion under limits (torque, joints, obstacles) at each step. Used for legged and fast robots.
Iterative learning control
For a repeated task, correct the command a little after each cycle, using the previous errors.
Operational-space control
Control the tool directly with a Cartesian force F = Kp(xd − x) − Kdẋ converted by τ = JTF (careful near singularities, lesson 5 of the previous course).
Key terms
independent joint control
gravity compensation
computed torque
inverse dynamics
adaptive control
MPC
operational space
Check yourself
In the computed-torque law, what linear equation does the error obey?
ë + Kd ė + Kp e = 0, the same for all joints and poses.
Why can a high gear ratio make independent PID control good enough?
The reflected motor inertia N²·Jm dominates the arm inertia changes, so joints are almost decoupled.
Why do real controllers use the model as feedforward and not as a pure cancellation?
Because the model is never exact: the feedback loop corrects what the feedforward gets wrong, so the result is robust.
6
Touching the world: force, compliance and impedance control
12 min
You will learn
why a robot that only controls position is dangerous in contact, and how force and impedance control solve it.
6.1 The problem of contact
Position control is a very stiff spring pulling towards the target. When the tool touches a rigid surface, a tiny position error becomes a huge force: with a surface of stiffness ke = 10⁶ N/m (steel), an error of only 0.1 mm gives F = 10⁶ × 0.0001 = 100 N. Polishing, inserting a part, screwing, working next to humans: all need to control the force, not just the position.
6.2 Passive and active compliance
Passive: soft pads, springs, a remote-centre-compliance (RCC) device for peg-in-hole, series elastic actuators. Fast, simple, but fixed.
Active: the controller makes the robot behave as if it had springs, by measuring forces (wrist sensor, joint torque sensors, or motor current) and modifying the motion. Flexible and tunable.
6.3 Impedance and admittance
Impedance control (Hogan) makes the tool behave like a virtual mass-spring-damper around the target xd:
Mdë + Ddė + Kde = Fext, e = x − xd
With Kd = 500 N/m, a push that moves the tool by 10 mm costs 5 N: soft and safe. With Kd = 50 000 N/m the same 10 mm costs 500 N: stiff, precise. You choose the stiffness in each direction by software.
Impedance control
Admittance control
Input / output
Measures motion, outputs a force (torque).
Measures force, outputs a motion.
Needs
A torque-controlled robot (good back-drivability).
A position-controlled robot with a force sensor (most industrial robots).
Good at
Soft, fast contact, free motion, cobots.
Stiff environments, hand guiding with a wrist sensor, precise assembly.
6.4 Hybrid position / force control
A task often has directions of motion and directions of contact. Wiping a table: force control along the normal (press with 10 N) and position control in the plane (follow the path). A selection matrix S (diagonal with 0 or 1) chooses, direction by direction, which law applies (Raibert and Craig). The force loop is slow and has a low gain, because with a stiff surface a fast force loop easily becomes unstable.
Link with singularities
The Cartesian stiffness of a robot with joint stiffness Kq is Kx = J−TKqJ−1. In a direction where the Jacobian is small (almost singular), the robot is very stiff and cannot be made soft by control: the structure carries the force (lesson 5 of the previous course). Compliant tasks are placed in well-conditioned poses.
Applications
Hand guiding: admittance with a wrist or joint sensors; you push, the arm follows (programming by demonstration).
Assembly: peg in hole with a spiral search while pushing with a small force, or insertion with compliance.
Polishing, sanding, deburring: constant normal force whatever the surface shape.
Collision reaction: if the measured torque differs from the model, stop or become soft.
Key terms
compliance
stiffness
impedance control
admittance control
hybrid position/force control
hand guiding
RCC
Check yourself
A virtual stiffness of 2000 N/m is set. The tool is pushed 15 mm. What force does the robot oppose?
F = K x = 2000 × 0.015 = 30 N.
Why does pure position control fail when pressing on a steel plate?
Steel is very stiff: a tiny position error gives a huge force (F = k e).
In hybrid control of a robot wiping a table, which direction is force-controlled?
The direction normal to the table; the two directions in the table plane are position-controlled.
7
Trajectories in practice: PTP, linear, circular, splines
13 min
You will learn
the motion types of a robot program, smooth polynomial profiles, and how to choose between them.
The speed laws (trapezoid) were seen in the other courses. Here is the practical side: what a robot programmer really chooses.
Motion
Path of the tool
Computed in
Use
PTP / MoveJ (point to point)
Not controlled: a curve, the result of the joint motion.
Joint space. All joints start and stop together (synchronised).
Free-space moves: fastest, no inverse kinematics along the way, crosses singularities.
LIN / MoveL (linear)
A straight line, constant tool orientation change.
Operational space; inverse kinematics at every cycle.
Gluing, welding, approach and retract of a part. Sensitive to singularities.
CIRC / MoveC (circular)
An arc through a via point.
Operational space.
Round welds, circles.
Spline
A smooth curve through many points.
Joint or operational space.
Painting, sealing, scanning a freeform surface.
7.1 Corners: blending (zones)
Stopping exactly at every programmed point wastes time. With a blending radius (called zone, approximation, CNT or smoothing depending on the brand) the robot starts the next segment before reaching the corner and cuts it with a round curve. Large zone = faster and smoother, but the tool does not touch the point. “Fine / exact stop” means no blending.
7.2 Polynomial profiles
To go from q0 to qf in a time T with zero speed at both ends, with τ = t/T and Δq = qf − q0:
Profile
Formula
Peak speed
Peak acceleration
Property
Cubic
q0 + Δq (3τ² − 2τ³)
1.5 Δq / T
6 Δq / T²
Acceleration jumps at the ends (a jerk, a shock).
Quintic
q0 + Δq (10τ³ − 15τ⁴ + 6τ⁵)
1.88 Δq / T
5.77 Δq / T²
Zero acceleration at the ends: smooth start and stop.
Trapezoid
piecewise
chosen (Vmax)
chosen (a)
Fastest for given limits, but infinite jerk at the corners.
S-curve (jerk-limited)
7 phases
chosen
chosen
Limits the jerk: less vibration, less wear. The industrial standard for fast, smooth moves.
Worked example
A joint turns by 90° (Δq = 1.571 rad) in 1 s. Cubic: peak speed 1.5 × 1.571 = 2.36 rad/s, peak acceleration 6 × 1.571 = 9.42 rad/s². Quintic: 1.88 × 1.571 = 2.95 rad/s and 5.77 × 1.571 = 9.06 rad/s². Make the move last 2 s instead of 1: all speeds are halved and accelerations divided by 4 (the torque follows acceleration, so the motor sees four times less).
7.3 Time-optimal and orientation
Time-optimal trajectory along a given path (TOPP): go as fast as the torque and speed limits allow at every point, using the dynamic model. Cycle-time winners in packaging use it.
Orientation: interpolate with quaternions (SLERP), never with Euler angles (lesson 6 of the course on singularities).
Synchronisation: in PTP the slowest joint decides the duration and the other joints are slowed to arrive together.
Speed override: the operator scales the speed by 10 %, 50 %, 100 %: the whole profile is stretched in time.
Key terms
PTP
linear / circular move
blending
spline
quintic
S-curve
jerk
time-optimal
Check yourself
Which motion type can pass through a singularity: PTP or LIN?
PTP: it works in joint space and does not invert the Jacobian.
You double the duration of a cubic move. By what factor does the peak acceleration change?
It is divided by 4 (6 Δq / T²).
Why do S-curves reduce vibrations compared with trapezoids?
The acceleration changes progressively, so there is no instantaneous jump of force to excite the elastic modes of the robot.
The control stack: from the program to the motor current
10 min
You will learn
the layers of a real robot controller, their speeds, and the vocabulary of the electronics around them.
Layer
Typical period
Runs on
Real time?
Program / planning
10 ms to seconds
Controller PC, cloud, PLC
Soft
Interpolator + kinematics
1 – 8 ms
Real-time OS on the controller
Hard
Position / speed loops
0.25 – 1 ms
Servo drive (DSP, FPGA)
Hard
Current loop and PWM
50 – 100 µs
Drive power stage
Hard
Why “real time” matters
Hard real time means that a late result is a wrong result: if the position loop is delayed by a few milliseconds the robot can vibrate or leave its path. That is why the controller uses a real-time operating system (RTOS, or Linux with PREEMPT_RT) and why a normal desktop computer is not enough to close fast loops.
8.1 Servo drive and fieldbus
Servo drive: converts the command to the three-phase current of a brushless motor (FOC, field-oriented control), reads the encoder, runs the current, speed and often position loops, and protects the motor (over-current, over-temperature).
Command modes: torque (current), velocity or position mode. A research robot or a cobot often uses torque mode; an industrial robot uses position mode with the controller closing the outer loop.
Fieldbus: the digital link between the controller and the drives: EtherCAT (very common, cycles of 250 µs to 1 ms, all axes synchronised), CANopen, PROFINET, Ethernet/IP. It replaces dozens of wires.
Safety layer: a separate, certified circuit (safe torque off, safe limited speed, emergency stop) that does not rely on the normal software.
Where the open source world fits
Research and education robots are often built with a PC running ROS 2 for the high layers (planning, perception), and a microcontroller or a drive running the fast loops, linked by CAN, USB or EtherCAT. The “ros2_control” framework gives a common interface between controllers and hardware (see the course “Robots in the real world”).
Key terms
interpolator
servo drive
FOC
fieldbus
EtherCAT
hard real time
safe torque off
Check yourself
What is the role of the interpolator?
It generates, every few milliseconds, the target position of each joint along the planned trajectory.
Why is the current loop in the drive and not in the robot controller?
It runs at 10-20 kHz and must be right next to the power electronics: a bus would be too slow.
What does “hard real time” mean?
A result that comes after its deadline is wrong, so the system must guarantee the deadline.
9
The imperfect robot: friction, backlash, flexibility, vibration
12 min
You will learn
the real-world effects that the rigid-body model ignores, and the usual cures.
Effect
What happens
Cure
Friction
Static friction holds the joint until the torque exceeds it, then the joint jumps (stick-slip). Visible as jerky very slow motion and as a small error that “sticks”.
Friction feedforward (identify Coulomb + viscous), dither, integral term, torque sensors at the joint.
Backlash
Free play in the gearbox: when the load reverses, the motor turns a little without moving the joint. The load can hit the teeth and oscillate.
Zero-backlash gearboxes (harmonic, preloaded), dual encoders, always approach a point from the same side, reduce the gain near zero speed.
Flexibility
Gearboxes, belts and links are springs. The robot is a set of masses and springs that vibrate at natural frequencies (a few to a few tens of Hz). The motor sees one position, the tool another.
Limit jerk (S-curves), notch filters, input shaping, output-side measurement (dual encoder), lower the loop gain below the resonance.
Delay and sampling
Each delay (sensor filter, bus, computation) removes stability margin: a gain that works in simulation oscillates on the real robot.
Fast loops, short pipelines, compensate known delays, keep the bandwidth well below the sampling rate.
Thermal limits
Motors heat as I²: a robot can do a peak move once but not every second. Gearbox grease changes with temperature.
Size with the RMS torque of the whole cycle, duty cycle, cooling, temperature monitoring.
Joint limits and saturation
Torque, current and speed are limited; the integral can wind up; the arm can hit its end stops.
Anti-windup, speed scaling, software limits before the mechanical stops.
9.1 A first look at vibration
Model a joint with a flexible gearbox as two masses linked by a spring: the motor mass Jm and the load mass Jl, with a stiffness k. It resonates at:
f = (1 / 2π) √( k (1/Jm + 1/Jl) )
For k = 10 000 N·m/rad, Jm = 0.2 and Jl = 0.5 kg·m² (both seen at the joint): f = (1/2π) √(10 000 × (5 + 2)) = (1/2π) √70 000 ≈ 42 Hz. The position loop bandwidth must stay well under this frequency, or the controller will excite the resonance. A trajectory whose acceleration changes abruptly every 24 ms (about 42 Hz) would excite it: this is what a jerk-limited profile avoids.
Input shaping
If you know the vibration frequency f, send each command as two half-size commands separated by half a period (1/(2f)). The vibrations created by the two halves cancel each other. This “zero-vibration shaper” is used on cranes, 3D printers and long robot arms, and costs only a delay of half a period.
9.2 Calibration of the dynamic parameters
To use the model of lesson 1 and 5, run an identification: move every joint with a rich, safe excitation trajectory, record positions and motor currents, and fit the parameters (masses, centres of mass, inertias, friction) by least squares. Also identify the payload: most controllers have a “load identification” routine. A wrong payload setting is a classic cause of poor tracking, protective stops on cobots, and shorter gearbox life.
Key terms
stick-slip
backlash
flexibility
resonance
notch filter
input shaping
identification
duty cycle
Check yourself
A joint has k = 20 000 N·m/rad, Jm = 0.1 and Jl = 0.4 kg·m². What is its resonance frequency?
f = (1/2π) √(20 000 × (10 + 2.5)) = (1/2π) √250 000 ≈ 80 Hz.
Why does a robot sometimes jerk when moving very slowly?
Stick-slip: static friction is higher than moving friction, so the joint alternately sticks and jumps.
Why can a controller tuned in simulation oscillate on the real robot?
The real robot has delays, flexibility and sensor filters that remove stability margin.
Glossary
All the words of the course in one place.
Term
Meaning
Dynamics
The relation between joint torques and joint accelerations: M(q) q̈ + C(q, q̇) q̇ + g(q) = τ.
Inertia matrix M(q)
How hard it is to accelerate each joint; it changes with the pose.
Coriolis and centrifugal
Torques that appear because other joints are moving (velocity products).
Gear ratio N
The motor turns N times faster than the joint and has N times less torque.
Reflected inertia
The motor inertia seen from the joint: N² · Jm.
BLDC / PMSM
Brushless motor, the standard of modern robot joints.
Harmonic drive
A strain-wave gearbox with no backlash and a high ratio, very common in robots.
Encoder
A sensor that measures an angle: incremental (counts) or absolute (gives the angle at power on).
PID
Proportional-Integral-Derivative controller.
Windup
The integral term grows without limit while the actuator is saturated.
Feedforward
A command computed from the model, before any error appears.
Computed torque
Control law that cancels the dynamics with the model, leaving a linear error equation.
Impedance control
The robot behaves like a virtual mass-spring-damper when it touches something.
Hybrid position / force control
Position control in some directions, force control in the others.
PTP / LIN / CIRC
Point-to-point (joint), linear and circular motions of a robot program.
Jerk
The derivative of the acceleration; limiting it gives smooth S-curve profiles.
Backlash
The free play between the teeth of a gearbox.
Input shaping
Pre-filtering the command so that it does not excite a vibration mode.
You can now make a robot move for real!
Next step: perception, planning and AI, how the robot senses the world, finds a path and learns.