MyRoboPath
Perception & Control15 min readUpdated 2026-03-28Intermediate

Sensors in Robotics: Perception, Telemetry & Sensor Fusion

A comprehensive guide covering encoders, IMUs, LiDAR, ultrasonic, depth vision, and Kalman state estimation for autonomous systems.

MyRoboPath Robotics Engineering Lab
Perception & Autonomous Navigation
Sensors in Robotics: Perception, Telemetry & Sensor Fusion
Sensor Architectures
2 Types
Proprioceptive (Internal) & Exteroceptive (External)
LiDAR Update Rate
5 – 20 Hz
Typical 360° rotational scan frequencies
IMU Gyro Drift
< 0.05°/sec
Industrial MEMS angular rate drift with EKF fusion
Depth Resolution
Sub-millimeter
Structured Light & Stereo Point Clouds

Core Engineering Takeaways

  • Robotics sensors are divided into Proprioceptive (measuring internal states: wheel ticks, joint angles, battery voltage) and Exteroceptive (measuring surroundings: obstacles, camera frames, distance).
  • Quadrature Encoders output two 90°-phase-shifted square waves (Channel A and B). Decoding both edges in 4x mode quadruples measurement resolution.
  • MEMS IMUs combine 3-axis Accelerometers (measuring gravity + linear acceleration) and 3-axis Gyroscopes (measuring angular rate).
  • Ultrasonic sensors bounce sound waves (wide cone, 2cm to 4m); Time-of-Flight (VL53L0X) uses infrared laser photons for millimeter precision.
  • 2D LiDAR provides 360° distance slices for 2D SLAM mapping; 3D LiDAR produces dense point clouds for autonomous self-driving vehicles.
  • Sensor Fusion algorithms (such as the Extended Kalman Filter) combine noisy IMU odometry with wheel encoders and LiDAR scans for drift-free navigation.
Prerequisites
  • Basic serial buses (I2C, SPI, UART)
  • Understanding of robot coordinate frames (X, Y, Z axes)

1. Classification of Robotic Sensors

Without sensors, a robot is merely an open-loop mechanism executing blind movements. Sensors provide the state feedback necessary for balance, obstacle avoidance, mapping, and human-safe interaction.

Robotic sensors are categorized into two primary domains:

1. By State Domain: - **Proprioceptive Sensors**: Measure the robot's **internal state** and physical parameters. - Examples: Motor wheel encoders (ticks/revolution), joint potentiometers, 6-DOF IMUs (linear acceleration, angular velocity), motor current shunt resistors (torque sensing), temperature probes, and battery voltage monitors. - **Exteroceptive Sensors**: Measure the **external environment** and spatial relationships outside the robot body. - Examples: Ultrasonic rangefinders, 2D/3D LiDAR scanners, RGB-D depth cameras, tactile bumper switches, GPS/GNSS receivers, and microphones.

2. By Energy Mode: - **Active Sensors**: Emit their own energy into the environment and measure the reflected signal (e.g., LiDAR emitting laser pulses, Ultrasonic transducers emitting 40 kHz sound waves, Active Stereo IR projectors). - **Passive Sensors**: Measure ambient environmental energy without emitting signals (e.g., standard RGB cameras, thermal infrared sensors, ambient light photodiodes, magnetic compasses).

Robotics sensor PCB module
Figure 1: High-density sensor interface board integrating MEMS IMU, dual I2C buses, and high-speed SPI ADC converters.

2. Proprioceptive Telemetry: Encoders & 9-DOF IMUs

Quadrature Encoders (Optical vs Magnetic) Quadrature encoders are attached to the rear shaft of DC motors or joint pivots to measure angular position and rotational speed.

  • Working Mechanics: Two sensors (Channel A and Channel B) are positioned 90° electrical degrees out of phase.
  • Direction Decoding:
  • If Channel A leads Channel B -> Clockwise rotation.
  • If Channel B leads Channel A -> Counter-Clockwise rotation.
  • 4X Decoding Multiplier: By counting both rising and falling edges on both channels (2 channels × 2 edges = 4x), an encoder with a 100 CPR physical disc delivers 400 pulses per revolution.

6-DOF and 9-DOF Inertial Measurement Units (IMUs) A modern IMU (such as the MPU-6050, ICM-42688-P, or BNO085) integrates micro-electromechanical sensors: 1. **3-Axis Accelerometer**: Measures linear specific force (m/s²) including the downward pull of gravity. Provides absolute Roll and Pitch angle references when stationary. 2. **3-Axis Gyroscope**: Measures instantaneous angular rotation speed (deg/s or rad/s). Integrating angular rate gives instant orientation change. 3. **3-Axis Magnetometer**: Measures Earth's magnetic field vector to calculate absolute heading relative to magnetic north.

MEMS IMU chip circuit
Figure 2: 9-DOF IMU sensor circuit with onboard ARM Cortex co-processor running sensor fusion firmware.

4X Quadrature Encoder Resolution Formula

Total Pulses per Turn = Physical CPR × 4 × Gearbox Ratio
In Simple Words: In 4X quadrature decoding, every rising and falling edge of Channels A and B is counted. Multiplying by the gearbox ratio gives the exact tick resolution at the robot wheel.
Variables Breakdown:
Physical CPR
Counts Per Revolution of the encoder discUnit: CPR
4X Multiplier
Counting rising and falling edges on both channelsUnit: Constant
Gearbox Ratio
Motor gearbox reduction factorUnit: Ratio
Worked Example:

An encoder disc with 11 CPR paired with a 30:1 gearbox gives: 11 × 4 × 30 = 1,320 ticks per wheel revolution (0.27° precision per tick).

encoder_interrupt_decoder.cpp
cpp
// Hardware Interrupt-Driven 4X Quadrature Encoder Reader
volatile long encoderTicks = 0;
const int pinA = 2; // Interrupt Pin 1
const int pinB = 3; // Interrupt Pin 2

void IRAM_ATTR handleEncoderInterrupt() {
  int a = digitalRead(pinA);
  int b = digitalRead(pinB);

  // Quadrature state matrix lookup
  if (a == b) {
    encoderTicks++; // Forward
  } else {
    encoderTicks--; // Reverse
  }
}

void setup() {
  pinMode(pinA, INPUT_PULLUP);
  pinMode(pinB, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(pinA), handleEncoderInterrupt, CHANGE);
  attachInterrupt(digitalPinToInterrupt(pinB), handleEncoderInterrupt, CHANGE);
}

Note: High-speed microcontroller interrupt routine executing in <1 µs to track bidirectional encoder pulses without missing counts.

3. Range Sensing: Ultrasonic (HC-SR04) vs ToF (VL53L0X)

Range sensors detect distance to nearby obstacles, acting as the primary reflex layer for collision avoidance.

Ultrasonic Transducers (HC-SR04, US-100) - **Principle**: Emits a 40 kHz burst of ultrasonic sound and times how long the echo takes to bounce back to the receiver. - **Characteristics**: - Effective Range: 2 cm to 400 cm. - Beam Angle: Wide acoustic cone (15° to 30°). - Limitations: Fails when surfaces are angled >45° (sound bounces away like a mirror) or against acoustic-absorbing soft fabrics and foam.

Optical Time-of-Flight Laser Ranging (ST VL53L0X / VL53L1X) - **Principle**: Uses a Vertical-Cavity Surface-Emitting Laser (VCSEL) to emit invisible 940 nm infrared photons, measuring picosecond flight time using a SPAD detector array. - **Characteristics**: - Distance: 3 cm to 400 cm with 1 mm measurement resolution. - Narrow Field of View: 27° conical cone. - Immunity: Independent of target surface color or reflectance.

Ultrasonic Distance Formula

Distance = (Echo Time × Speed of Sound) ÷ 2
In Simple Words: Sound travels at 343 meters per second in air (0.0343 cm/microsecond). Because the sound wave travels to the obstacle and bounces back, divide total travel time by 2.
Variables Breakdown:
Distance
Distance to obstacleUnit: Centimeters (cm)
Echo Time
Time from pulse emission to echo returnUnit: Microseconds (µs)
Speed of Sound
Speed of acoustic wave in airUnit: 343 m/s (0.0343 cm/µs)
Worked Example:

If an HC-SR04 sensor measures an echo return time of 1,000 µs: Distance = (1,000 × 0.0343) ÷ 2 = 17.15 cm.

Table 1: Range Sensor Comparison
ParameterUltrasonic (HC-SR04)Infrared Analog (Sharp GP2Y)Laser ToF (VL53L1X)
Measurement Medium40 kHz Acoustic Sound Wave850 nm Optical Triangulation940 nm Laser Photons (ToF)
Max Useful Range4.0 meters0.8 – 1.5 meters4.0 meters
Sample Frequency10 – 20 Hz (Speed of sound limit)50 – 100 Hz50 Hz
Target Color SensitivityZero (Sound reflects off solid surfaces)High (Dark surfaces report wrong distance)Low (Direct photon time measurement)
Interference RisksAcoustic echoes & multi-robot crosstalkDirect sunlight saturationBright direct sunlight outdoors

4. 2D & 3D LiDAR for SLAM and Mapping

LiDAR (Light Detection and Ranging) is the cornerstone sensor for mobile robots navigating complex indoor facilities and outdoor streets.

2D Planar Scanning LiDAR (RPLIDAR A1/A2, YDLIDAR) A 2D LiDAR contains a laser emitter and receiver mounted on a rotating motor turret spinning at 5 to 15 Hz: - **Triangulation LiDAR**: Uses a laser diode and a linear CMOS camera array. Cheaper ($70 to $200), with range up to 8 to 12 meters. - **Direct Time-of-Flight (dToF) LiDAR**: Emits nanosecond laser pulses and measures high-precision flight times. Works reliably up to 25 to 50 meters even in bright ambient daylight. - **Output Data**: Generates a 360° array of distance readings per revolution, used directly by SLAM algorithms to build 2D floor maps.

3D Multi-Beam LiDAR (Velodyne VLP-16, Ouster OS1) Instead of a single horizontal slice, 3D LiDARs stack 16, 32, 64, or 128 vertical laser channels spinning simultaneously: - Generates over 1,000,000 3D points per second. - Produces dense 3D point clouds used for elevation mapping, obstacle classification, and autonomous vehicle navigation.

3D LiDAR point cloud map
Figure 3: 3D point cloud environment reconstruction captured by a multi-beam solid-state LiDAR scanner.

5. RGB-D Depth Cameras: Stereo vs Structured Light

While LiDAR generates distance slices, an RGB-D Depth Camera outputs a photo-realistic color pixel image where every single pixel contains an exact metric distance measurement (X, Y, Z) in millimeters.

The Three Core Depth Camera Technologies:

  1. 1
    Active Stereo Vision (Intel RealSense D435 / D455)
  • Uses two calibrated infrared cameras spaced by a known physical baseline distance.
  • An infrared laser projector casts an invisible random speckle pattern onto the scene, creating texture on smooth walls.
  • Calculates depth from disparity between left and right camera frames.
  • Operates reliably indoors and outdoors under direct sunlight.
  1. 2
    Structured Light (Microsoft Kinect v1, Orbbec Astra)
  • Projects a known geometric grid or dot pattern and measures contour deformations.
  • Delivers sub-millimeter accuracy at close ranges (0.2m to 2.0m), ideal for 3D scanning and robotic pick-and-place grippers.
  1. 3
    Time-of-Flight Depth Cameras (Microsoft Azure Kinect)
  • Illuminates the entire scene with modulated continuous-wave infrared light and measures the phase shift of returning light at every pixel.
  • Delivers 30 to 60 FPS dense point clouds with zero disparity calculation lag.
RGB-D depth camera hardware
Figure 4: RGB-D stereo depth camera system with dual infrared sensors, central RGB optical sensor, and active laser speckle projector.

Stereo Vision Depth Formula

Depth (Z) = (Focal Length × Baseline Distance) ÷ Disparity
In Simple Words: The distance to an object is calculated by comparing how much the object shifts position (disparity) between the left and right cameras. Objects that are closer shift more; objects further away shift less.
Variables Breakdown:
Depth (Z)
Perpendicular distance to the target pointUnit: Meters (m)
Focal Length (f)
Camera lens focal lengthUnit: Pixels (px)
Baseline (B)
Physical spacing between the two camerasUnit: Meters (m)
Disparity (d)
Pixel shift difference between left and right imagesUnit: Pixels (px)

6. Sensor Fusion: Complementary & Extended Kalman Filter (EKF)

No single sensor is perfect:

  • Encoders accumulate wheel slip error.
  • IMU gyroscopes accumulate integration drift.
  • LiDAR scan matching drops out in long featureless corridors.
  • GPS loses signal indoors.

Sensor Fusion mathematically merges multiple imperfect sensor streams into a single high-confidence estimate of the robot state (Position X, Y, Z, Orientation Roll, Pitch, Yaw, and Velocities).

Complementary Filter (Simple Fusion on Microcontrollers) Combines fast Gyroscope rate integration with steady Accelerometer gravity angles: - The gyroscope provides fast, responsive updates during motion. - The accelerometer continuously corrects long-term gyro drift when stationary.

Extended Kalman Filter (EKF) in ROS 2 The **Extended Kalman Filter** operates in a continuous two-step cycle: 1. **Prediction Step**: Uses high-speed IMU and wheel velocity inputs to predict where the robot has moved forward in time. 2. **Correction Step**: When an absolute measurement arrives from LiDAR or GPS, it calculates the optimal Kalman Gain to correct any accumulated error.

Complementary Filter Angle Formula

Fused Angle = 0.98 × (Previous Angle + Gyro Rate × Δt) + 0.02 × Accel Angle
In Simple Words: Takes 98% of the fast, responsive gyro angle and blends in 2% of the stable accelerometer angle to cancel out gyro drift without noise.
Variables Breakdown:
Fused Angle
Optimal clean pitch/roll angle estimateUnit: Degrees (°)
Gyro Rate
Instantaneous rotational speedUnit: deg/s
Δt
Time elapsed since last calculation loopUnit: Seconds (s)
Accel Angle
Angle measured from gravity vectorUnit: Degrees (°)
complementary_filter.py
python
class ComplementaryFilter:
    def __init__(self, alpha=0.98):
        self.alpha = alpha
        self.pitch = 0.0
        self.roll = 0.0

    def update(self, gyro_x, gyro_y, accel_x, accel_y, accel_z, dt):
        import math
        # Calculate pitch & roll from gravity vector
        accel_pitch = math.atan2(accel_y, math.sqrt(accel_x**2 + accel_z**2)) * (180.0 / math.pi)
        accel_roll  = math.atan2(-accel_x, accel_z) * (180.0 / math.pi)

        # Fuse high-frequency gyro rate with low-frequency absolute accel vector
        self.pitch = self.alpha * (self.pitch + gyro_x * dt) + (1.0 - self.alpha) * accel_pitch
        self.roll  = self.alpha * (self.roll  + gyro_y * dt) + (1.0 - self.alpha) * accel_roll
        
        return self.roll, self.pitch

Note: Python implementation of a 6-DOF complementary filter fusing angular rates and gravity vectors for attitude estimation.

7. Sensor Selection by Robot Archetype

Choose your robotics perception suite based on application domain and operating environment:

Table 2: Recommended Sensor Suites by Robot Archetype
Robot ArchetypeCore Proprioceptive SensorsCore Exteroceptive SensorsKey Sensor Fusion Node
Differential Drive AMR (Warehouse AGV)Dual Quadrature Wheel Encoders, 6-DOF IMU, Battery Voltage Shunt2D 360° LiDAR, 3x Ultrasonic Bumpers, Downward IR Cliff SensorsROS 2 `robot_localization` (EKF) + Nav2 AMCL
6-DOF Manipulator Robotic Arm14-bit Absolute Magnetic Joint Encoders, 6-Axis Force/Torque Wrist SensorEye-in-Hand RGB-D Depth Camera (RealSense), Tool Center Laser PointerForward/Inverse Kinematics + MoveIt 2 Collision Monitor
Autonomous Quadcopter / UAV9-DOF IMU (ICM-42688), Optical Flow Downward Camera, Barometer, Current ShuntDownward Laser ToF Altimeter, Forward Stereocamera, RTK-GPS GNSSPX4 / ArduPilot EKF3 Flight State Estimator
Humanoid Biped / QuadrupedJoint Motor Encoders, High-Rate 6-DOF IMU (1 kHz), Foot Contact Pressure GaugesForward 3D Solid-State LiDAR, RealSense Wide Depth Camera, Head RGB CameraWhole-Body State Estimator + Legged Odometry Filter
Frequently Asked Questions

Common Questions & Troubleshooting

Q:Why does my robot navigation drift when using only wheel encoders (Dead Reckoning)?

Wheel odometry assumes pure rolling without slipping. In reality, wheels experience physical micro-slippage, tire compression, and floor irregularities. Over a 10-meter travel distance, uncorrected wheel odometry typically accumulates 5% to 15% heading error. You must fuse encoders with an IMU and LiDAR SLAM to eliminate drift.

Q:What is Hard-Iron vs Soft-Iron distortion in magnetometer sensors?

Hard-Iron distortion is caused by permanent magnetic materials on the robot (like speaker magnets, motor casings, or magnetized screws) that shift the magnetic reading by a constant offset. Soft-Iron distortion is caused by non-magnetic metals (iron, nickel) that warp the magnetic field lines. Both can be calibrated out by rotating the robot in a figure-8 motion.

Q:Can I use an Intel RealSense camera outdoors under bright sunlight?

Yes! The Intel RealSense D435, D435i, and D455 models utilize active stereoscopic vision. Under direct sunlight, the ambient sunlight overwhelms the infrared speckle projector, but the dual infrared cameras simply switch to using natural outdoor ambient light texture for stereo disparity matching.