ROBOTICS.PRIMER / v1.0
← Back to Autonomy
An Interactive Primer · Updated 2026

Robotics,
by hand.

A working tour through the mathematics, mechanisms, and control loops that turn actuators into intent — with live demos you can poke.

By Majid Mazouchi

BASE JOINT · θ₂ EE
Sections
Seven
Live demos
Four interactive
Glossary terms
Twenty-four
Section 01 · Foundations

What is a robot?

At bottom, a robot is an embodied feedback loop. It senses the world, reasons about it, and acts on it — then does it again, fast enough that the world still looks the way it expected.

A useful working definition: a robot is a programmable machine that perceives, plans, and acts to accomplish tasks in the physical world. The word "programmable" is doing real work here — a washing machine is not a robot, because its behavior is fixed at manufacture. A robot arm is, because its behavior at runtime is a function of sensor data.

The canonical breakdown of a robotic system is the sense–plan–act loop. Sensors turn physical phenomena into numbers (encoder counts, pixel intensities, IMU rates). A planner or controller turns those numbers into desired actions (joint torques, wheel velocities). Actuators turn commands back into physical phenomena (motion, force). Close the loop fast enough and you have autonomy.

Robots are commonly grouped by morphology — manipulators (robot arms, fixed or mobile), mobile bases (wheeled, tracked, legged), aerial vehicles (quadrotors, fixed-wing), underwater vehicles, and humanoids, which combine several of these. Each morphology comes with its own kinematic and control conventions, but the underlying mathematics is shared.

01 · SENSE

Perception

Encoders, cameras, LiDAR, IMUs, force/torque sensors. Raw signals are filtered, fused, and transformed into state estimates — "where am I, how fast, what's around me."

02 · PLAN

Reasoning

Trajectories, reference signals, motion plans. Maps current state + goal to an intended future. May be offline and optimal (trajectory optimization) or online and reactive (MPC).

03 · ACT

Actuation

Motors, servos, hydraulics. Low-level controllers (usually PID or model-based) turn reference setpoints into torque or velocity commands at kilohertz rates.

Joint primitives.

Every articulated robot is built from a small palette of joints. Each one contributes one or more degrees of freedom (DOF) — independent ways the mechanism can move.

Revolute
R · 1 DOF
Rotation about a fixed axis. The workhorse of manipulators.
Prismatic
P · 1 DOF
Linear translation along an axis. Linear actuators, slides.
Spherical
S · 3 DOF
Rotation about a point. Ball joints, human shoulders.
Helical
H · 1 DOF
Coupled rotation + translation (lead screw). One parameter.

A manipulator with six or more revolute joints in a general arrangement can — in principle — reach any position and orientation within its workspace. Six is the magic number because pose in 3-D space has six parameters: three for position (x, y, z) and three for orientation (roll, pitch, yaw). Fewer DOF means a restricted set of achievable poses; more means redundancy, which brings extra capability (obstacle avoidance, joint-limit avoidance) but also harder inverse kinematics.

Section 02 · Kinematics

The geometry of reach.

Kinematics asks a purely geometric question: given the joint angles, where is the end-effector? And the harder inverse: given a desired end-effector pose, what joint angles put it there?

The first question is forward kinematics (FK). It has a unique answer — chain the per-link transformations together and read off the tool frame. The second is inverse kinematics (IK). It generally doesn't have a unique answer — multiple joint configurations reach the same pose (elbow-up vs. elbow-down, for instance), and some poses are unreachable.

For a planar 2-link arm with link lengths L₁, L₂ and joint angles θ₁, θ₂, the forward map is:

FK x = L₁ cos(θ₁) + L₂ cos(θ₁ + θ₂)     y = L₁ sin(θ₁) + L₂ sin(θ₁ + θ₂)

And the inverse, using the law of cosines:

IK cos(θ₂) = (x² + y² − L₁² − L₂²) / (2 L₁ L₂)
θ₁ = atan2(y, x) − atan2( L₂ sin(θ₂), L₁ + L₂ cos(θ₂) )

The ± in acos is the elbow-up / elbow-down ambiguity. In the widget below, drag the red target anywhere inside the workspace annulus; the arm solves IK in real time. Targets outside the reach set leave the arm stretching toward them but unable to close the loop — geometry does not yield to wishful thinking.

DEMO / 2-LINK PLANAR ARM · INVERSE KINEMATICS
Link 1 · L₁100
Link 2 · L₂80
Elbow configuration
θ₁0.00°
θ₂0.00°
x, y0.0, 0.0
statusIN REACH

Drag the amber target.
Dashed annulus = workspace.

When the Jacobian — the matrix mapping joint velocities to end-effector velocities — becomes rank-deficient, the arm hits a singularity. In our 2-link case this happens when the arm is fully extended (θ₂ = 0) or fully folded (θ₂ = ±π). At these configurations, some directions of motion require infinite joint velocities. Real robots stay away from singularities using damped-least-squares IK or velocity filtering.

For serial arms with more than a couple of joints, analytic IK gets messy. The standard bookkeeping device is Denavit–Hartenberg (DH) parameters — a convention that assigns a local frame to each link and describes each link with just four numbers (aᵢ, αᵢ, dᵢ, θᵢ). The full forward kinematics is then a product of 4×4 homogeneous transformation matrices, one per link.

HOMOGENEOUS T = T₀₁ · T₁₂ · T₂₃ · ... · Tₙ₋₁,ₙ

Each Tᵢ,ⱼ is a 4×4 matrix combining a 3×3 rotation and a 3×1 translation. The top-left 3×3 block is the orientation of frame j expressed in frame i; the top-right 3×1 column is the origin of frame j in frame i. Multiplying them composes rigid transformations cleanly.

Section 03 · Control

Closing the loop.

A reference trajectory is a wish. A controller is what turns that wish into behavior — by driving the error between desired and measured state toward zero, continuously, at every sample.

The overwhelmingly most common control law in robotics is PID — proportional, integral, derivative. Despite its age (roots in 18th-century governor theory) and simplicity, PID remains the default for joint-level control because it is easy to tune, computationally trivial, and has excellent stability properties for well-behaved plants.

PID u(t) = Kₚ · e(t) + Kᵢ · ∫ e(τ) dτ + K_d · de/dt

Three terms, three intuitions:

Proportional pushes harder when the error is larger. Too much and you oscillate; too little and you never converge. Integral accumulates past error to kill steady-state offsets (gravity, friction, DC disturbances) — but it introduces phase lag and risks integral windup when the actuator saturates. Derivative reacts to the rate of change of error, adding damping and reducing overshoot — but it amplifies measurement noise, so it's typically filtered.

Play with the gains below. The plant is a simple mass with viscous damping m ẍ + c ẋ = u. The controller tries to drive position to the step reference of 1.0. Watch what happens with only P, only P+D, and the full three-term law.

DEMO / PID STEP RESPONSE · SECOND-ORDER PLANT
Kₚ · proportional4.0
Kᵢ · integral0.0
K_d · derivative0.5
Disturbance0.0
overshoot
settling 2%
ss error

PID is stateless with respect to the plant — it doesn't know anything about your robot. For multi-joint robots, the dynamics are coupled (moving joint 2 changes the inertia seen by joint 1) and nonlinear. Beyond PID, the common steps up the ladder are:

Feedforward + PID. Compute a model-based torque estimate (gravity, inertia, Coriolis) and let the PID correct the residual. The controller carries the nominal behavior; the feedback cleans up modeling error and disturbances.

Computed-torque control. Solve the full rigid-body dynamics M(q) q̈ + C(q,q̇) q̇ + g(q) = τ for the commanded torque given a desired acceleration. Linearizes and decouples the system in joint space; requires an accurate dynamic model.

Impedance / admittance control. Instead of regulating position, regulate the relationship between force and motion. The robot behaves as a programmable spring-mass-damper — essential for contact tasks (assembly, polishing, collaborative robotics).

MPC (Model Predictive Control). At every sample, solve a constrained optimization over a finite horizon, apply the first control, repeat. Handles constraints and previews natively at the cost of computation. Standard for legged locomotion and trajectory tracking under limits.

Section 04 · Planning

From where to how.

Control tells a joint what to do. Planning decides what the whole robot should do — routes around obstacles, respects joint limits, trades off time and smoothness.

Motion planning splits into two closely related subproblems. Path planning asks for a collision-free sequence of configurations from start to goal — it's a geometric question about configuration space (C-space). Trajectory generation adds timing — velocities, accelerations, jerk — producing something the controller can actually track.

Classical grid search on the workspace (A*, Dijkstra) works for mobile robots in 2-D or 3-D but doesn't scale to high-DOF manipulators where C-space has as many dimensions as joints. That's the realm of sampling-based planners — RRT, PRM, and their optimal variants (RRT*, PRM*), which probe random configurations and only do collision checks as needed.

The grid below runs A* with a Manhattan heuristic. Click to place or remove obstacles. Drag start (green) or goal (amber). The planner replans live.

DEMO / A-STAR GRID PLANNER · MANHATTAN HEURISTIC
Mode
Diagonal moves
path length
nodes expanded
statusREADY

Click cells.
Teal = explored.
Amber = path.

Once a path is in hand, it still needs to be made time-optimal or smooth before it gets handed to the controller. Common steps:

Smoothing. The raw output of a grid or sampling planner is jagged and has redundant waypoints. Shortcut smoothing — repeatedly try to replace two waypoints with a direct segment if collision-free — removes much of this.

Parameterization. Turn the geometric path into a time-parameterized trajectory respecting velocity, acceleration, and torque limits. TOPP-RA (time-optimal path parameterization via reachability analysis) is a modern standard.

Re-planning. In dynamic environments the plan goes stale as soon as it is produced. Reactive controllers (artificial potential fields, velocity obstacles, MPC with obstacle constraints) handle local deviations without re-running the global planner every tick.

Section 05 · Perception

How robots see.

Every autonomous behavior is downstream of perception. The quality of the state estimate is an upper bound on the quality of the control.

Modern robotic perception is a stack. At the bottom: proprioceptive sensors tell the robot about itself — encoders report joint positions, IMUs report angular rate and linear acceleration, force/torque sensors report contact loads. These are cheap, fast (kHz rates), and low-latency.

Above them: exteroceptive sensors tell the robot about the world — RGB cameras, depth cameras (stereo, ToF, structured-light), LiDAR, radar, ultrasonic. These are slower (typically 10–100 Hz), richer, and noisier, and they need careful extrinsic calibration against the robot's kinematic frame.

PROPRIOCEPTIVE

Joint encoders

Incremental or absolute. Report shaft angle at high rate with sub-milliradian resolution. Drive the innermost control loop. Missed counts or slipping couplings are a common fault mode — always design with a homing strategy.

PROPRIOCEPTIVE

IMU (inertial measurement)

3-axis gyro + 3-axis accelerometer, often 6- or 9-DOF with magnetometer. Measures rate and acceleration directly. Integrate once for orientation, twice for position — with drift. Only useful fused with absolute references.

EXTEROCEPTIVE

LiDAR

Pulses laser, measures return time. Produces dense point clouds with centimeter accuracy at tens of meters. Workhorse of mobile robotics and autonomous vehicles. Solid-state variants are displacing spinning designs.

EXTEROCEPTIVE

Cameras (RGB / depth)

Cheap and rich. Require calibration (intrinsics + extrinsics). Depth from stereo, structured light, or time-of-flight. The lifeblood of modern learned perception — object detection, segmentation, pose estimation.

The job of the perception pipeline is not to produce raw data but to produce state estimates — compact representations of what the downstream planner needs to know. For a mobile robot, state is usually pose plus velocity. For a manipulator, it's joint configuration plus contact state. For a humanoid, it's both plus the world's geometry.

The canonical tool for combining noisy measurements with a motion model is the Kalman filter (and its nonlinear variants EKF, UKF, or particle filters). For mapping and localization simultaneously, SLAM (Simultaneous Localization and Mapping) algorithms build a map of the environment while also estimating the robot's pose within it — visual-inertial SLAM is currently the workhorse for low-cost systems.

Section 06 · Glossary

Terminology, tapped.

Twenty-four terms that turn up everywhere. Click to expand. Type to filter.

Section 07 · Practical Notes

Things that bite.

The gap between a simulated robot and a real one is filled with the following inconveniences. None are deep theory. All will cost you a day if ignored.

Note · 01

Calibrate before you optimize.

Mechanical zero ≠ commanded zero. Encoder offsets, link-length manufacturing tolerances, gearbox backlash, and mounting misalignments all introduce bias. A 0.5° joint offset at the shoulder can produce 10+ mm end-effector error on a 1 m arm. Run a kinematic calibration routine before you trust any absolute position command.

Note · 02

Real-time is not fast — it's predictable.

A 1 kHz control loop that occasionally jitters to 3 ms is worse than a 500 Hz loop that always takes exactly 2 ms. Use real-time operating systems (RT-Linux with PREEMPT_RT, QNX, VxWorks) or dedicated microcontrollers for inner loops. Reserve Linux user-space for perception, planning, and logging.

Note · 03

Sensor fusion is 80% time synchronization.

Fusing an IMU at 1 kHz with a camera at 30 Hz requires knowing — to the millisecond — when each sample was captured, not when it arrived at your process. Hardware timestamps at the sensor, PTP/IEEE-1588 on the network, and a single coherent clock domain across the robot are the reliable solution.

Note · 04

Friction is the villain.

Classical models (viscous + Coulomb) capture the broad behavior but miss stiction, Stribeck effects, hysteresis, and temperature dependence. A motor that works perfectly at 25 °C can have double the breakaway torque after 30 minutes of operation. Budget for it — in both control design and thermal management.

Note · 05

Simulation lies, politely.

Rigid-body simulators (MuJoCo, Isaac, Drake) are excellent for policy development but make optimistic assumptions about contact, friction, sensor noise, and actuator bandwidth. The sim-to-real gap is widest exactly where you'd expect — at contacts, at joint limits, at the edges of the actuator envelope. Domain randomization helps; real hardware helps more.

Note · 06

Safety is a system property, not a layer.

Watchdog timers, redundant encoders, hardware e-stops wired independently of software, torque limits in the motor driver itself, and explicit workspace/velocity envelopes enforced at the lowest layer. Functional safety standards (ISO 13849, ISO 10218, ISO/TS 15066 for cobots) codify what has to be true. Do them before you need them — not after.

Note · 07

Log everything. Replay nothing.

Record every sensor, command, and internal state at full rate during development. When something goes wrong at 2:47 AM on a Saturday, you will not be able to reproduce it. A 500 MB/hour log is cheap; a week of debugging is not. Tools: rosbag, MCAP, Foxglove.

Note · 08

Actuators have bandwidth. Respect it.

A control law that commands 10 kHz torque updates is pointless if the motor driver's current loop closes at 2 kHz. Know the bandwidth of every element in the chain — commanded torque, actual torque, velocity, position — and design the controller for the slowest. Aliasing-induced instabilities are real and embarrassing.

— END OF PRIMER —