AnyLearn
All lessons
Roboticsbeginner

Sensors: How Robots Perceive

A robot is only as good as what it can measure. Explore the full sensor toolkit — encoders, IMUs, ultrasonic rangefinders, LiDAR, cameras, and force/torque sensors — and learn the four metrics that determine whether a sensor is fit for purpose: resolution, range, noise, and sampling rate.

Not signed in — your progress and quiz score won't be saved.
Lesson progress1 / 10

Why sensors are the foundation of robotics

A blindfolded person can barely walk across a room; a robot with no sensors is just expensive metalwork. Every decision a robot makes is only as trustworthy as the data its sensors supply. Garbage in, garbage out — and in robotics, garbage out can mean a bent wrist or a toppled shelf of products.

Sensors split into two fundamental families:

  • Proprioceptive sensors measure the robot's own internal state — motor speed, joint angle, battery voltage, body tilt.
  • Exteroceptive sensors measure the outside world — distances to walls, ambient light, the weight of a grasped object.

A well-designed robot uses both families together. An arm that knows its joint angles (proprioceptive) but can't feel when it's gripping too hard (exteroceptive force sensor) will crush every fragile part it touches. Balance is the goal, not maximum sensor count — every sensor adds wiring, latency, and complexity.

Full lesson text

All 10 steps on one page — for reading, reference, and search.

Show

1. Why sensors are the foundation of robotics

A blindfolded person can barely walk across a room; a robot with no sensors is just expensive metalwork. Every decision a robot makes is only as trustworthy as the data its sensors supply. Garbage in, garbage out — and in robotics, garbage out can mean a bent wrist or a toppled shelf of products.

Sensors split into two fundamental families:

  • Proprioceptive sensors measure the robot's own internal state — motor speed, joint angle, battery voltage, body tilt.
  • Exteroceptive sensors measure the outside world — distances to walls, ambient light, the weight of a grasped object.

A well-designed robot uses both families together. An arm that knows its joint angles (proprioceptive) but can't feel when it's gripping too hard (exteroceptive force sensor) will crush every fragile part it touches. Balance is the goal, not maximum sensor count — every sensor adds wiring, latency, and complexity.

2. The four metrics that define a sensor

Before choosing any sensor, engineers evaluate it on four axes:

MetricDefinitionWhy it matters
ResolutionSmallest detectable changeAn encoder with 12-bit resolution gives 4096 ticks/rev; a 10-bit encoder gives 1024 — less precise positioning
RangeMin–max measurable valueAn ultrasonic sensor rated 2 cm–4 m is blind to closer or farther objects
NoiseRandom error on each readingA noisy IMU makes smooth velocity estimation hard; filtering adds latency
Sampling rateReadings per second (Hz)A 10 Hz GPS on a fast drone is nearly useless; a 200 Hz IMU can track rapid tilts

These four metrics trade off against each other and against cost. A high-resolution, low-noise, wide-range, fast sensor is expensive. Real engineering is choosing which metrics matter most for a given task — and living with the compromises on the others.

3. Encoders: counting every step of rotation

An encoder measures rotation — how far a shaft or wheel has turned. It's the most common proprioceptive sensor in robotics. The two main types are:

  • Incremental encoder: produces pulses as the shaft rotates; you count pulses from a known reference position. Loses position if power is cut.
  • Absolute encoder: outputs the actual angular position at all times; survives power cycles.

A typical incremental encoder on a hobby robot wheel might give 360 pulses per revolution (PPR). With a 6 cm diameter wheel, one pulse represents π×6/3600.052\pi \times 6 / 360 \approx 0.052 cm of travel. Higher PPR means finer resolution but also faster pulse counting. Here's how to read an encoder on an Arduino:

volatile long count = 0;
void encoderISR() { count++; }  // interrupt fires on each pulse
void setup() {
  attachInterrupt(digitalPinToInterrupt(2), encoderISR, RISING);
}
void loop() {
  float dist_cm = count * (PI * 6.0 / 360.0);
}

Encoders don't feel slip — if a wheel skids, the count is wrong.

4. IMUs: measuring motion through space

An Inertial Measurement Unit (IMU) bundles two (or three) sensors into one chip:

  • Accelerometer — measures linear acceleration along each axis (in m/s2m/s^2). Gravity counts as acceleration, so a stationary IMU reads 9.8 m/s² pointing downward — which is how it estimates tilt.
  • Gyroscope — measures angular velocity (in °/s or rad/s). Integrate over time to get orientation angle.
  • Magnetometer (optional) — measures magnetic field direction to give an absolute heading, like a compass.

The catch: gyroscopes drift. Every small measurement error accumulates when you integrate. After 30 seconds, a consumer gyroscope might report 5° of phantom rotation. This is called gyro drift or integration drift, and it's why drones, phones, and cars fuse IMU data with GPS or visual odometry rather than relying on the gyro alone. The art of combining noisy sensor streams is called sensor fusion, and it's one of the richest problems in robotics.

5. Range sensors: measuring distance

Range sensors let a robot answer: how far away is that wall? Three technologies dominate:

SensorPrincipleRangeProsCons
UltrasonicSound echo time (e.g., HC-SR04)2 cm – 4 mCheap ($2), easySlow (25 Hz), cone-shaped beam, misses thin objects
IR rangefinderTriangulated infrared reflection10 cm – 1.5 mFast, compactFails on black or shiny surfaces
LiDARLaser pulse time-of-flight0.1 m – 100+ mMillimeter accuracy, 360° scanExpensive (100100–10,000), needs compute

Ultrasonic sensors are the Hello World of robotics sensing: a $2 HC-SR04 can tell an Arduino-driven car not to hit a wall. LiDAR is what gives a self-driving car its detailed 3D map of the road. Same principle — time of flight — but orders of magnitude apart in speed, resolution, and cost.

6. Cameras: rich but expensive to process

Cameras capture 2D images (or 3D stereo depth) at high resolution — a modern robot camera might produce 640×480640 \times 480 pixels at 60 Hz, giving 18 million data points per second. That richness is both the superpower and the problem: interpreting an image requires substantial compute.

Four camera variants appear in robotics:

  • Monocular — one lens, 2D image. Cheap, but depth is ambiguous without additional processing.
  • Stereo — two lenses separated horizontally. The disparity between the two images encodes depth, like human binocular vision. Accuracy degrades with distance.
  • Depth (RGB-D) — combines a color camera with an infrared structured-light depth sensor (e.g., Intel RealSense, Kinect). Direct per-pixel depth at short range.
  • Event camera — records only pixel-level brightness changes asynchronously; ultra-low latency and no motion blur, useful for high-speed robotics.

Camera data almost always requires preprocessing — undistortion, noise filtering, feature extraction — before the controller can act on it.

7. Force and torque sensors: feeling the world

A robot that can't feel force is dangerous around humans and fragile objects. Force/torque (F/T) sensors measure the loads applied at a robot's wrist or fingertips, typically using strain gauges — thin metal strips whose electrical resistance changes when they bend.

Applications where F/T sensors are non-negotiable:

  • Assembly tasks: pressing a peg into a hole requires knowing when contact is made and how hard to push.
  • Human-robot collaboration: the robot must yield when a person pushes on it, not fight back.
  • Grinding or polishing: maintaining a constant contact force regardless of surface irregularities.

A lighter-weight alternative is current sensing — measuring the motor current, which is proportional to torque. Industrial robots like the KUKA LBR iiwa embed current sensors in every joint, enabling compliance without external F/T hardware. This approach is less accurate but far cheaper and lighter.

8. Why no sensor is perfect

Every sensor fails in characteristic ways worth memorizing:

SensorClassic failure mode
Wheel encoderWheel slip → false odometry
IMU gyroscopeIntegration drift over time
UltrasonicMisses thin objects; slow update rate
IR rangefinderFails on dark or reflective surfaces
LiDARRain, fog, and glass confuse point clouds
CameraLow light, motion blur, lens distortion
F/T sensorThermal drift; overload damage

The engineering response to imperfect sensors is redundancy and fusion. Use multiple sensor types that fail in different ways, and combine their outputs using algorithms like Kalman filters or particle filters. When one sensor is fooled, another compensates. No individual reading is trusted blindly — all readings are evidence, weighted by estimated reliability.

9. Picking the right sensor for the job

A sensor is never chosen in isolation — it must match the task, the environment, and the budget. Here's a quick decision framework:

  1. What physical quantity do you need? Speed → encoder or IMU. Distance → ultrasonic/LiDAR. Visual scene → camera.
  2. What is the required range and resolution? A warehouse navigation task needs 10 cm accuracy over 20 m; a surgical robot needs 0.1 mm accuracy over 30 cm.
  3. What is the environment like? Dusty/wet environments kill open optical encoders. Bright sunlight saturates some IR sensors. Metallic surfaces scramble magnetic encoders.
  4. What is the loop rate requirement? Control loops running at 1 kHz need sensors sampling at least that fast, or you're interpolating blind.

Before writing a line of control code, sketch your sensor suite and annotate each sensor with its resolution, range, noise, and sample rate. Mismatched sensors account for a surprising fraction of robotics project failures.

10. Reading it all together

Here is a snapshot of how a typical mobile robot uses multiple sensor families simultaneously:

# Pseudocode: one control cycle on a differential-drive robot
encoder_ticks = read_encoders()        # proprioceptive: wheel travel
imu_angle     = read_imu_yaw()         # proprioceptive: heading
lidar_scan    = read_lidar()           # exteroceptive: obstacle distances

# Fuse encoder + IMU into an estimated pose
pose = odometry_update(encoder_ticks, imu_angle)

# Check for obstacles in the path
if nearest_obstacle(lidar_scan) < 0.3:  # 30 cm threshold
    cmd_velocity = stop()
else:
    cmd_velocity = drive_toward_goal(pose, goal)

send_motor_commands(cmd_velocity)

Notice each sensor plays a distinct role: encoders track distance traveled, the IMU tracks heading, and LiDAR detects the environment. A failure in any one stream degrades performance in a predictable way — which is why you instrument each stream with sanity checks and fallback behaviors in production code.

Check your understanding

The lesson ends with a 5-question quiz. Take it in the player above to see your score.

  1. A robot's wheel encoder reads 360 pulses per revolution. The wheel diameter is 6 cm. Approximately how far does the robot travel per pulse?
    • About 5.2 mm
    • About 1.0 mm
    • About 18.8 mm
    • About 0.5 mm
  2. An IMU gyroscope is used to estimate a robot's heading angle by integrating angular velocity over time. The main problem with this approach is:
    • Gyroscopes only measure acceleration, not rotation.
    • Small measurement errors accumulate, causing the heading estimate to drift over time.
    • Gyroscopes require a GPS signal to calibrate correctly.
    • Integration produces velocity, not angle — a second integration is needed.
  3. A $2 HC-SR04 ultrasonic sensor is used to detect a thin metal wire strung across a doorway. Why might the sensor fail to detect it?
    • Ultrasonic sensors cannot detect metal objects.
    • The sensor's wide, cone-shaped beam may miss the thin wire, and its slow update rate could skip transient reflections.
    • Ultrasonic waves are absorbed entirely by metal before reflecting.
    • The wire's diameter is probably larger than the sensor's maximum range.
  4. Which sensor type provides direct per-pixel depth information at short range by combining a color camera with infrared structured light?
    • Monocular camera
    • Stereo camera
    • RGB-D camera
    • Event camera
  5. A warehouse robot uses wheel encoders for odometry but occasionally skids on a polished floor. What is the correct characterization of this failure?
    • The sensor's resolution is too low for the task.
    • The sensor's sampling rate is insufficient to detect skids.
    • Wheel slip means the encoder counts rotations that do not correspond to real forward motion, producing false position estimates.
    • The encoder's range is exceeded when the robot travels more than a few meters.

Related lessons