IMU Interface#

IMU sensor abstraction layer.

This module provides a common interface for IMU drivers (Hardware and SITL).

IMU Implementations:

namespace drivers#
class IMU#
#include <imu.hpp>

Abstract Interface for IMU sensor class. The point of this class is to give a clean interface so the Payload Controller doesn’t need to know where it gets sensor data from. This header is the only interface the rest of the application needs, hence why there is no imu_sitl.hpp.

Subclassed by drivers::ICM20948, drivers::IMU_SITL, drivers::LSM6DSO

Public Functions

virtual ~IMU() = default#
virtual void start() = 0#

Starts the IMU. It should immediately start writing imu messages to internal buffer.

void write_latest(const sensor_msgs_msg_Imu &msg)#

Writes a new incoming imu reading to the local cache.

sensor_msgs_msg_Imu get_latest()#

returns the latest imu reading

bool get_latest_if_updated(uint32_t &last_update_count, sensor_msgs_msg_Imu &msg)#

Returns true and copies the latest imu reading if it is newer than last_update_count.

inline virtual void update()#

Polls the sensor; backends receiving samples asynchronously need no work here.

Public Static Functions

static IMU *instance()#

Gets singleton instance of imu implementation (sitl, hardware). implemented in backend .cpp files, not imu.cpp

Protected Functions

IMU() = default#

Private Members

sensor_msgs_msg_Imu reading_ = {}#
uint32_t update_count_ = 0#
util::StaticMutex mtx_#