The Encoder: A Ruler for Rotation
Before a robot can sense the world around it, it needs to sense itself: where its own joints are. This inward-looking sense is called proprioceptive sensing — the same word doctors use when you close your eyes and still know where your hand is. The most basic proprioceptive sensor is the rotary encoder, a small device bolted to a rotating shaft that answers one question: how far has this shaft turned?
Picture a thin disk on the shaft, slotted with hundreds of fine lines like the teeth of a comb. A tiny light shines through one side; a detector on the other side sees the light flicker on and off as the lines sweep past. Each flicker is one tick. Count the ticks and you know the angle: if the disk has 1000 lines and you counted 250 ticks, the shaft turned a quarter of a circle, or 90 degrees. The encoder has turned a physical rotation into a number the robot can read.
Why does this matter so much? Because the joint angle the encoder reports is the raw input to forward kinematics — the math that turns "each joint is at this angle" into "the hand is at this point in space." Each revolute joint of an arm carries its own encoder, and together they tell the robot its exact pose. Miss a count, and the robot's idea of where its hand is drifts away from the truth.
Two New Senses: Feeling Push and Feeling Spin
An encoder is perfect when there is a shaft to bolt it to. But a flying drone or a walking robot also needs to know how its whole body is tilting and moving through the air, where there is no shaft to count. For that we use two different sensors that feel forces directly.
The first is the accelerometer. Imagine a tiny weight held by springs inside a chip. When the chip speeds up, slows down, or gets shoved, the weight lags behind and tugs on the springs; the chip measures that tug. Here is the subtle part: gravity tugs on the weight too, exactly as if the chip were being pushed upward at 9.8 meters per second squared. So a still accelerometer always feels a one-gravity push pointing away from the Earth — which is wonderful, because it tells the robot which way is down.
The second is the gyroscope. It does not feel pushes; it feels rotation rate — how fast the body is spinning, in degrees per second, about each of its three axes. A modern gyroscope has no spinning wheel inside; instead a tiny structure is kept vibrating, and when the chip rotates, a sideways force (the Coriolis effect) nudges that vibration in a way the chip can measure. Where the accelerometer answers "which way am I tilted right now," the gyroscope answers "how fast am I turning."
The IMU: Pairing Opposites Together
Put an accelerometer and a gyroscope (and often a magnetic compass) into one small package and you have an inertial measurement unit, or IMU — the chip that gives a phone, a drone, and a humanoid their sense of balance. The whole point of the IMU is teamwork: each sensor covers exactly the weakness of the other.
Why can't an accelerometer do the job alone? It can find "down," so it can tell you tilt — roll and pitch. But it cannot tell which way you are facing on a flat floor, because spinning in place does not change which way gravity points. Heading is invisible to it. Worse, every footstep and motor vibration shows up as a fake acceleration, so its tilt estimate is jittery.
Why can't a gyroscope do it alone? It catches heading and every quick turn beautifully and is barely bothered by bumps. But it only reports *rate* of turn, never absolute angle. To get an angle you must add up the rate over time, and any tiny constant error in the reading — its bias — gets added in again and again, so the angle slowly slides away from the truth. This creeping error is called drift, and a lone gyro will, given a few minutes, confidently insist it is tilted when it is sitting perfectly flat.
The fix writes itself. Trust the gyroscope for the fast, smooth, moment-to-moment changes, and lean gently on the accelerometer's view of "down" to slowly correct the gyro's drift back toward truth. Blending two imperfect sensors into one estimate better than either alone is the heart of sensor fusion, a theme you will meet again and again in robotics.
From Rate to Angle: Integration and Its Price
Let's make the gyro's math concrete. The chip hands you a turning rate many times a second. To turn rate into an angle, you do something simple: every time step, multiply the rate by how much time passed and add it to a running total. Multiply-and-add, over and over. That running sum is your angle. This step-by-step accumulation is called integration, and the same trick turns the accelerometer's reading into a velocity.
# repeat every time step (dt = seconds since last reading) angle = angle + gyro_rate * dt # rate -> angle velocity = velocity + accel_meas * dt # accel -> velocity position = position + velocity * dt # velocity -> position # the catch: a small constant error (bias) in gyro_rate or accel_meas # is added in EVERY step, so the error grows without bound -> drift
The price of integration is that it has a long memory for mistakes. Suppose the gyro's bias makes it read just 0.1 degree per second too high while you sit perfectly still. After one minute the integrated angle is off by 6 degrees; after ten minutes, 60. The accelerometer's case is even harsher: position comes from integrating twice, so a small bias grows not in a straight line but like a snowball, faster and faster.
This is exactly why an IMU drives a robot by dead reckoning — estimating where you are purely from your own motion — only for short stretches, and why that same drift problem shows up in wheel-based odometry. The cure is to occasionally check against something absolute: gravity pins down tilt, a magnetic compass or GPS pins down heading and position, and good calibration measures and subtracts the bias before it ever gets integrated.
The Workhorses of Self-Sensing
Encoders and IMUs are the quiet workhorses of proprioceptive sensing. They are cheap, fast, and always available — they never need a clear view of the room or good lighting the way a camera does. Almost every robot, from a tabletop arm to a self-driving car, leans on them as its baseline sense of self before any fancier perception is layered on top.
But notice the recurring lesson: each of these sensors is honest about only part of the story. The encoder counts ticks but can slip; the accelerometer finds down but is shaken; the gyro turns smoothly but drifts. None is trustworthy alone over long stretches. The robot's real sense of its own motion comes from combining them — and combining them well, against occasional absolute references, is the craft you will keep practicing.