![]() |
Laelaps
2.3.5
RoadNarrows Robotics Small Outdoor Mobile Robot Project
|
#include <laeImu.h>
Public Member Functions | |
LaeImu (std::string strIdent="Virtual IMU") | |
Default constructor. More... | |
virtual | ~LaeImu () |
Destructor. | |
virtual int | open (const std::string &strDevName, int nBaudRate) |
virtual int | close () |
Close connection to motor controller. More... | |
virtual bool | isOpen () |
Check if IMU serial interface is open. More... | |
virtual void | blacklist () |
Black list IMU from robot sensors. | |
virtual void | whitelist () |
White list IMU sensor. | |
virtual bool | isBlackListed () |
Test if IMU is black listed. More... | |
virtual void | clearSensedData () |
Clear IMU sensed data. | |
virtual int | numDoFs () |
Get the total IMU degress of freedom. More... | |
virtual bool | hasAccelerometer () |
Test if IMU has an accelerometer. More... | |
virtual bool | hasGyroscope () |
Test if IMU has an gyroscope. More... | |
virtual bool | hasMagnetometer () |
Test if IMU has an magnetometer. More... | |
virtual int | configure (const laelaps::LaeDesc &desc) |
Configure IMU from product description. More... | |
virtual int | configure (const laelaps::LaeTunes &tunes) |
Configure IMU from tunable parameters. More... | |
virtual int | reload (const laelaps::LaeTunes &tunes) |
Reload with new tuning parameters. More... | |
virtual int | readIdentity (std::string &strIdent)=0 |
Read sensor identity values. More... | |
virtual int | readRawImu ()=0 |
Read sensor raw IMU values. More... | |
virtual int | convertRawToSI ()=0 |
Convert last read IMU values to International System of Units. More... | |
virtual void | compute () |
Compute all IMU values form converted, raw values. More... | |
virtual void | computeQuaternion () |
Compute the quaternion from the IMU data. | |
virtual void | computeDynamics () |
Compute the velocity, position, and any other dynamics from the IMU data. More... | |
virtual void | exec () |
Exectute one step to read, convert, and compute IMU values. | |
std::string | getIdentity () |
Get IMU identity. More... | |
std::string | getDevName () |
Get IMU device name. More... | |
virtual void | getRawInertiaData (int accel[], int gyro[]) |
Get the last read raw inertia data. More... | |
virtual void | getInertiaData (double accel[], double gyro[]) |
Get the last read and converted inertia data. More... | |
virtual void | getMagnetometerData (double mag[]) |
Get the last read magnetometer values. More... | |
virtual void | getAttitude (double rpy[]) |
Get the last read IMU (vehicle) attitude. More... | |
virtual void | getAttitude (double &roll, double &pitch, double &yaw) |
Get the last read IMU (vehicle) attitude. More... | |
virtual void | getQuaternion (Quaternion &q) |
Get the last computed quaternion. More... | |
virtual void | getImuData (double accel[], double gyro[], double mag[], double rpy[], Quaternion &q) |
Get the last sensed, converted, and computed IMU data. More... | |
Protected Member Functions | |
void | lockIo () |
Lock the shared I/O resource. More... | |
void | unlockIo () |
Unlock the shared I/O resource. More... | |
void | lockOp () |
Lock the extended operation. More... | |
void | unlockOp () |
Unlock the extended operation. More... | |
Protected Attributes | |
std::string | m_strIdent |
IMU identity. | |
std::string | m_strDevName |
serial device name | |
int | m_nBaudRate |
device baudrate | |
int | m_fd |
opened device file descriptor | |
bool | m_bBlackListed |
IMU is [not] black listed. | |
int | m_accelRaw [NumOfAxes] |
accelerometer raw values | |
int | m_gyroRaw [NumOfAxes] |
gyroscope raw values | |
int | m_magRaw [NumOfAxes] |
magnetometer raw values | |
int | m_rpyRaw [NumOfAxes] |
roll,pitch,yaw raw values | |
double | m_accel [NumOfAxes] |
accelerometer (m/s^2) | |
double | m_gyro [NumOfAxes] |
gyrscope (radians/s) | |
double | m_mag [NumOfAxes] |
magnetometer (tesla) | |
double | m_rpy [NumOfAxes] |
roll,pitch,yaw (radians) | |
Quaternion | m_quaternion |
imu orientation (and robot) | |
pthread_mutex_t | m_mutexIo |
low-level I/O mutex | |
pthread_mutex_t | m_mutexOp |
high-level operation mutex | |
Inertia Measurement Unit virtual base class with serial interface.
LaeImu::LaeImu | ( | std::string | strIdent = "Virtual IMU" | ) |
Default constructor.
strIdent | IMU identity string. |
Definition at line 143 of file laeImu.cxx.
References clearSensedData(), m_bBlackListed, m_fd, m_mutexIo, and m_mutexOp.
|
virtual |
Close connection to motor controller.
Definition at line 201 of file laeImu.cxx.
References lockIo(), m_fd, m_nBaudRate, m_strDevName, and unlockIo().
Referenced by Laelaps.WatchDog.WatchDog::attach(), blacklist(), laelaps::LaeRobot::disconnect(), Laelaps.WatchDog.WatchDog::open(), and ~LaeImu().
|
virtual |
Compute all IMU values form converted, raw values.
Definition at line 270 of file laeImu.cxx.
References computeDynamics(), and computeQuaternion().
Referenced by exec().
|
virtual |
Compute the velocity, position, and any other dynamics from the IMU data.
Definition at line 281 of file laeImu.cxx.
Referenced by compute().
|
virtual |
Configure IMU from product description.
Call after connection is opened.
desc | Product description. |
Definition at line 237 of file laeImu.cxx.
Referenced by laelaps::LaeRobot::configForOperation().
|
virtual |
Configure IMU from tunable parameters.
Call after connection is opened.
tunes | Laelaps tuning parameters. |
Definition at line 242 of file laeImu.cxx.
|
pure virtual |
Convert last read IMU values to International System of Units.
Implemented in sensor::imu::LaeImuCleanFlight.
Referenced by exec().
|
virtual |
Get the last read IMU (vehicle) attitude.
[out] | rpy | Vehicle roll, pitch, and yaw (radians). The array size must be ≥ NumOfAxes. |
Definition at line 329 of file laeImu.cxx.
References m_rpy, and sensor::imu::NumOfAxes.
Referenced by getImuData().
|
virtual |
Get the last read IMU (vehicle) attitude.
[out] | roll | Vehicle roll (radians). |
[out] | pitch | Vehicle pitch (radians). |
[out] | yaw | Vehicle yaw (radians). |
Definition at line 337 of file laeImu.cxx.
References m_rpy, sensor::imu::PITCH, sensor::imu::ROLL, and sensor::imu::YAW.
|
inline |
Get IMU device name.
Definition at line 396 of file laeImu.h.
|
inline |
|
virtual |
Get the last sensed, converted, and computed IMU data.
[out] | accel | Accelerometer data (m/s^2). The array size must be ≥ NumOfAxes. |
[out] | gyro | Gyroscope data (radians/s). The array size must be ≥ NumOfAxes. |
[out] | mag | Magnetometer data (tesla). The array size must be ≥ NumOfAxes. |
[out] | rpy | Vehicle roll, pitch, and yaw (radians). The array size must be ≥ NumOfAxes. |
[out] | q | Vehicle quaternion. |
Definition at line 349 of file laeImu.cxx.
References getAttitude(), getInertiaData(), getMagnetometerData(), getQuaternion(), lockOp(), and unlockOp().
Referenced by laelaps::LaeRobot::getImu().
|
virtual |
Get the last read and converted inertia data.
[out] | accel | Accelerometer data (m/s^2). The array size must be ≥ NumOfAxes. |
[out] | gyro | Gyroscope data (radians/s). The array size must be ≥ NumOfAxes. |
Definition at line 312 of file laeImu.cxx.
References m_accel, m_gyro, and sensor::imu::NumOfAxes.
Referenced by getImuData().
|
virtual |
Get the last read magnetometer values.
[out] | mag | Magnetometer data (tesla). The array size must be ≥ NumOfAxes. |
Definition at line 321 of file laeImu.cxx.
References m_mag, and sensor::imu::NumOfAxes.
Referenced by getImuData().
|
virtual |
Get the last computed quaternion.
[out] | q | Vehicle quaternion. |
Definition at line 344 of file laeImu.cxx.
References m_quaternion.
Referenced by getImuData().
|
virtual |
Get the last read raw inertia data.
[out] | accel | Raw accelerometer data. The array size must be ≥ NumOfAxes. |
[out] | gyro | Raw gyroscope data. The array size must be ≥ NumOfAxes. |
Definition at line 303 of file laeImu.cxx.
References m_accelRaw, m_gyroRaw, and sensor::imu::NumOfAxes.
|
inlinevirtual |
Test if IMU has an accelerometer.
Reimplemented in sensor::imu::LaeImuCleanFlight.
|
inlinevirtual |
Test if IMU has an gyroscope.
Reimplemented in sensor::imu::LaeImuCleanFlight.
|
inlinevirtual |
|
inlinevirtual |
Test if IMU is black listed.
Definition at line 242 of file laeImu.h.
Referenced by exec(), sensor::imu::LaeImuCleanFlight::readIdentity(), sensor::imu::LaeImuCleanFlight::readRawImu(), sensor::imu::LaeImuCleanFlight::readRawInertia(), and sensor::imu::LaeImuCleanFlight::readRawRollPitchYaw().
|
inlinevirtual |
Check if IMU serial interface is open.
Definition at line 222 of file laeImu.h.
Referenced by blacklist(), Laelaps.WatchDog.WatchDog::cmdConfigDPin(), Laelaps.WatchDog.WatchDog::cmdEnableAuxPort5V(), Laelaps.WatchDog.WatchDog::cmdEnableAuxPortBatt(), Laelaps.WatchDog.WatchDog::cmdEnableMotorCtlrs(), Laelaps.WatchDog.WatchDog::cmdGetFwVersion(), Laelaps.WatchDog.WatchDog::cmdPetTheDog(), Laelaps.WatchDog.WatchDog::cmdReadAPin(), Laelaps.WatchDog.WatchDog::cmdReadDPin(), Laelaps.WatchDog.WatchDog::cmdReadEnables(), Laelaps.WatchDog.WatchDog::cmdReadVoltages(), Laelaps.WatchDog.WatchDog::cmdResetRgbLed(), Laelaps.WatchDog.WatchDog::cmdSetAlarms(), Laelaps.WatchDog.WatchDog::cmdSetBatterySoC(), Laelaps.WatchDog.WatchDog::cmdSetRgbLed(), Laelaps.WatchDog.WatchDog::cmdWriteDPin(), sensor::imu::LaeImuCleanFlight::mspReadAttitude(), sensor::imu::LaeImuCleanFlight::mspReadIdent(), and sensor::imu::LaeImuCleanFlight::mspReadRawImu().
|
inlineprotected |
Lock the shared I/O resource.
The lock()/unlock() primitives provide for safe multi-threading.
Definition at line 541 of file laeImu.h.
Referenced by close(), sensor::imu::LaeImuCleanFlight::mspReadAttitude(), sensor::imu::LaeImuCleanFlight::mspReadIdent(), sensor::imu::LaeImuCleanFlight::mspReadRawImu(), and open().
|
inlineprotected |
Lock the extended operation.
The lock()/unlock() primitives provide for safe multi-threading.
Definition at line 565 of file laeImu.h.
Referenced by exec(), and getImuData().
|
inlinevirtual |
|
virtual |
Open connection to IMU.
strDevName | Serial device name. |
nBaudRate | Serial device baud rate. |
Definition at line 162 of file laeImu.cxx.
References clearSensedData(), laelaps::getRealDeviceName(), lockIo(), m_bBlackListed, m_fd, m_nBaudRate, m_strDevName, and unlockIo().
Referenced by laelaps::LaeRobot::connSensors().
|
pure virtual |
Read sensor identity values.
[out] | strIdent | Hardware specific, formated identity string. |
Implemented in sensor::imu::LaeImuCleanFlight.
|
pure virtual |
Read sensor raw IMU values.
Depending on the sensor and the board, raw values read:
Implemented in sensor::imu::LaeImuCleanFlight.
Referenced by exec().
|
virtual |
Reload with new tuning parameters.
tunes | Laelaps tuning parameters. |
Definition at line 247 of file laeImu.cxx.
Referenced by laelaps::LaeThreadImu::reload().
|
inlineprotected |
Unlock the shared I/O resource.
Definition at line 552 of file laeImu.h.
Referenced by close(), sensor::imu::LaeImuCleanFlight::mspReadAttitude(), sensor::imu::LaeImuCleanFlight::mspReadIdent(), sensor::imu::LaeImuCleanFlight::mspReadRawImu(), and open().
|
inlineprotected |
Unlock the extended operation.
Definition at line 576 of file laeImu.h.
Referenced by exec(), and getImuData().