Sensor Libraries

This section covers the core sensor libraries used in ArduPilot for reading and processing sensor data from GPS, barometers, compasses, airspeed sensors, and attitude/heading reference systems.

AP_GPS

Header: libraries/AP_GPS/AP_GPS.h

Inheritance: None (top-level class)

Description: GPS driver supporting multiple backends (NMEA, UBX, SBF, etc.). This is the primary position sensor for autonomous flight, providing position, velocity, time, and satellite information.

Detailed Documentation:

AP_GPS Detailed Reference - Detailed AP_GPS API Reference

Related Classes (Derived):

  • AP_GPS_UBLOX - u-blox GPS driver

  • AP_GPS_NMEA - NMEA GPS driver

  • AP_GPS_SBF - Septentrio GPS driver

  • AP_GPS_ERB - Esterel GPS driver

  • AP_GPS_GSOF - Generic Sensor Output Format

  • AP_GPS_MAV - MAVLink GPS

  • AP_GPS_NOVA - NovAtel GPS

  • AP_GPS_SIRF - SiRF GPS

  • AP_GPS_SBP - SBP driver

Friend Classes:

  • AP_GPS_Backend - Base class for GPS backends

  • AP_GPS_Blended - Blended multi-GPS instance


AP_Baro

Header: libraries/AP_Baro/AP_Baro.h

Inheritance: None (top-level class)

Description: Barometer (air pressure) sensor driver for altitude estimation. Critical for maintaining altitude in fixed-wing aircraft and for altitude hold in multirotors.

Detailed Documentation:

AP_Baro Detailed Reference - Detailed AP_Baro API Reference

Related Classes (Derived):

  • AP_Baro_BMP280

  • AP_Baro_MS5611

  • AP_Baro_MS5637

  • AP_Baro_BMP388

  • AP_Baro_BMP581

  • AP_Baro_DPS280

  • AP_Baro_DPS310

  • AP_Baro_ICM20789

Backend Class:

  • AP_Baro_Backend - Base class for barometer backends


AP_Compass

Header: libraries/AP_Compass/AP_Compass.h

Inheritance: None (top-level class)

Description: Digital compass/magnetometer for heading determination using the Earth’s magnetic field.

Detailed Documentation:

AP_Compass Detailed Reference - Detailed AP_Compass API Reference

Related Classes (Derived):

  • AP_Compass_AK09916

  • AP_Compass_AK8963

  • AP_Compass_BMM150

  • AP_Compass_HMC5843

  • AP_Compass_LIS3MDL

  • AP_Compass_LSM303D

  • AP_Compass_QMC5883L

  • AP_Compass_RM3100

Backend Class:

  • AP_Compass_Backend - Base class for compass backends


AP_Airspeed

Header: libraries/AP_Airspeed/AP_Airspeed.h

Inheritance: None (top-level class)

Description: Airspeed sensor driver for fixed-wing aircraft. Essential for stall protection and safe flight.

Related Classes (Derived):

  • AP_Airspeed_MS4525 - MEAS MS4525DO

  • AP_Airspeed_MS5525 - MEAS MS5525DO

  • AP_Airspeed_SDP3X - Sensirion SDP3X

  • AP_Airspeed_DLVR - Littelfuse DLVR

  • AP_Airspeed_NMEA - NMEA airspeed

  • AP_Airspeed_ASP5033 - First Sensor ASP5033

  • AP_Airspeed_Params - Parameters class

  • AP_Airspeed_Analog - Analog airspeed

Backend Class:

  • AP_Airspeed_Backend - Base class for airspeed backends


AP_AHRS

Header: libraries/AP_AHRS/AP_AHRS.h

Inheritance: None (top-level class)

Description: Attitude and Heading Reference System using sensor fusion (EKF). This is the central navigation system combining GPS, compass, gyros, and accelerometers for attitude estimation.

Key Features:

  • Extended Kalman Filter (EKF) for attitude estimation

  • GPS fusion for position

  • Compass fusion for heading

  • Sensor redundancy handling

  • Multiple EKF lanes for safety

Detailed Documentation:

AP_AHRS Detailed Reference - Detailed AP_AHRS API Reference

Related Classes (Derived):

  • AP_AHRS_Backend - Base class for AHRS backends

  • AP_AHRS_View - View into another AHRS instance

Usage Example:

AP_AHRS &ahrs = AP_AHRS::get_singleton();

// In main loop (100Hz)
ahrs.update();

// Get attitude
Vector3f euler = ahrs.get_roll_pitch_yaw();
float roll = ahrs.get_roll();      // radians
float pitch = ahrs.get_pitch();    // radians
float yaw = ahrs.get_yaw();        // radians

AP_InertialNav

Header: libraries/AP_InertialNav/AP_InertialNav.h

Inheritance: None (top-level class)

Description: Inertial navigation system combining accelerometer and gyroscope data for position estimation.


AP_RangeFinder

Header: libraries/AP_RangeFinder/AP_RangeFinder.h

Inheritance: None (top-level class)

Description: Range finder (distance sensor) driver for terrain following, obstacle avoidance, and precision landing. Supports sonar, laser, and other distance measurement technologies.

Detailed Documentation:

AP_RangeFinder Detailed Reference - Detailed AP_RangeFinder API Reference

Related Classes (Backends):

  • AP_RangeFinder_Ping - Ping sonar

  • AP_RangeFinder_Maxsonar - MaxBotix sonar

  • AP_RangeFinder_LightWareSFxx - LightWare laser

  • AP_RangeFinder_LeddarOne - LeddarOne laser

  • AP_RangeFinder_VL53L0X - ST VL53L0X (ToF)

  • AP_RangeFinder_DroneCAN - DroneCAN rangefinder

  • AP_RangeFinder_Backend - Base class for backends

Common Orientations:

  • ROTATION_PITCH_270 - Downward (terrain following, landing)

  • ROTATION_PITCH_90 - Forward (obstacle avoidance)

  • ROTATION_YAW_180 - Backward (rear obstacle avoidance)


AP_RTC (Real-Time Clock)

Header: libraries/AP_RTC/AP_RTC.h

Description: Real-time clock for timekeeping and timestamping.

Key Features:

  • Battery-backed time

  • GPS time synchronization

  • Timestamp for logging

Usage Example:

AP_RTC *rtc = AP_RTC::get_singleton();

// Get current time
uint64_t time_us = rtc->get_time_us();
uint32_t date = rtc->get_date();
uint32_t time = rtc->get_time_hms();

AP_RSSI (RSSI Receiver)

Header: libraries/AP_RSSI/AP_RSSI.h

Description: Receiver Signal Strength Indicator monitoring.

Usage Example:

AP_RSSI *rssi = AP_RSSI::get_instance();

// Get RSSI
uint16_t rssi_value = rssi->get_rx_rssi();
uint16_t link_quality = rssi->get_rx_link_quality();