58 #include "rnr/rnrconfig.h" 69 #define STATIC_STR const char* 71 #define STATIC_STR static const char* const 162 void convertEuler(
double phi,
double theta,
double psi);
193 LaeImu(std::string strIdent=
"Virtual IMU");
208 virtual int open(
const std::string &strDevName,
int nBaudRate);
224 return m_fd >= 0?
true:
false;
230 virtual void blacklist();
235 virtual void whitelist();
244 return m_bBlackListed;
250 virtual void clearSensedData();
330 virtual int readIdentity(std::string &strIdent) = 0;
348 virtual int readRawImu() = 0;
355 virtual int convertRawToSI() = 0;
362 virtual void compute();
367 virtual void computeQuaternion();
375 virtual void computeDynamics();
411 virtual void getRawInertiaData(
int accel[],
int gyro[]);
423 virtual void getInertiaData(
double accel[],
double gyro[]);
433 virtual void getMagnetometerData(
double mag[]);
443 virtual void getAttitude(
double rpy[]);
454 virtual void getAttitude(
double &roll,
double &pitch,
double &yaw);
489 virtual void getImuData(
double accel[],
double gyro[],
double mag[],
505 int m_accelRaw[NumOfAxes];
506 int m_gyroRaw[NumOfAxes];
507 int m_magRaw[NumOfAxes];
508 int m_rpyRaw[NumOfAxes];
513 double m_accel[NumOfAxes];
514 double m_gyro[NumOfAxes];
515 double m_mag[NumOfAxes];
516 double m_rpy[NumOfAxes];
543 pthread_mutex_lock(&m_mutexIo);
554 pthread_mutex_unlock(&m_mutexIo);
567 pthread_mutex_lock(&m_mutexOp);
578 pthread_mutex_unlock(&m_mutexOp);
676 static const int SerBaud9600 = 9600;
677 static const int SerBaud19200 = 19200;
678 static const int SerBaud38400 = 38400;
679 static const int SerBaud57600 = 38400;
680 static const int SerBaud115200 = 115200;
682 static const int SerBaudDft = SerBaud115200;
687 static const uint_t TCmdTimeout = 1000;
688 static const uint_t TRspTimeout = 12000;
689 static const uint_t TFlushDelay = 100;
745 virtual int readIdentity(std::string &strIdent);
757 virtual int readRawImu();
764 virtual int readRawInertia();
771 virtual int readRawRollPitchYaw();
778 virtual int convertRawToSI();
812 int mspReadAttitude();
823 int sendCmd(uint_t cmdId, byte_t cmdData[],
size_t lenData);
834 int receiveRsp(uint_t cmdId, byte_t rspData[],
size_t lenData);
847 void flush(uint_t t);
861 return pack16((uint_t &)val, buf);
874 int pack16(uint_t val, byte_t buf[]);
886 int unpack16(byte_t buf[],
int &val);
898 int unpack16(byte_t buf[], uint_t &val);
912 return pack32((uint_t)val, buf);
925 int pack32(uint_t val, byte_t buf[]);
937 int unpack32(byte_t buf[],
int &val);
949 int unpack32(byte_t buf[], uint_t &val);
virtual bool hasGyroscope()
Test if IMU has an gyroscope.
Quaternion operator=(const Quaternion &rhs)
Assignment operator.
static const double MspMpu6050RawToDegPerSec
MPU-6050 rotation raw value to degrees/second.
uint_t m_uCaps
capabilities or'd bits
uint_t m_uMultiType
multiwii type
Laelaps tuning data class.
static const char *const MspPreamble
message preamble
Laelaps robotic mobile platform full description class.
void lockIo()
Lock the shared I/O resource.
void unlockIo()
Unlock the shared I/O resource.
std::string m_strIdent
IMU identity.
int m_fd
opened device file descriptor
pthread_mutex_t m_mutexIo
low-level I/O mutex
static const double MspGToMPerSec2
standard g in m/s^2
virtual int numDoFs()
Get the total degress of freedom of the IMU sensor.
int pack16(int val, byte_t buf[])
Pack 16-bit signed value into buffer.
void unlockOp()
Unlock the extended operation.
static const char *const MspCmdPreamble
command preamble
RPY
Roll, pitch, and yaw indices.
static const uint_t MspCmdIdIdent
read board/sensor idents
int m_nBaudRate
device baudrate
static const int MspRspMinLen
MspRspHdrLen+1 response min len.
static const char *const MspDirTo
to imu
virtual int numDoFs()
Get the total IMU degress of freedom.
static const int MspRspHdrLen
response header len
virtual bool hasMagnetometer()
Test if IMU has an magnetometer.
virtual bool isOpen()
Check if IMU serial interface is open.
static const char *const MspDirFrom
from imu
static const int MspCmdMaxLen
response max len
uint_t m_uMspVersion
MSP version.
virtual bool hasGyroscope()
Test if IMU has an gyroscope.
Board identity structure.
static const char *const MspRspPreamble
response preamble
Laelaps robotic base mobile platform description class interface.
static const int MspCmdMinLen
MspCmdHdrLen+1 command min len.
const int NumOfAxes
maximum number of axes per sensor component.
uint_t m_uFwVersion
firmware version
static const double MspAttitudeRawToDeg
board computed attitude raw value to degreess
static const int MspCmdHdrLen
command header len
static const int MspFieldPosDataStart
data start field position
void lockOp()
Lock the extended operation.
static const double MspMpu6050RawToG
MPU-6050 acceleration raw value to g's.
std::string getIdentity()
Get IMU identity.
virtual bool hasAccelerometer()
Test if IMU has an accelerometer.
static const int MspFieldPosSize
data size field position
int pack32(int val, byte_t buf[])
Pack 32-bit signed value into buffer.
static const uint_t MspCmdIdRawImu
read raw imu data
static const int MspFieldPosDir
dir field position
pthread_mutex_t m_mutexOp
high-level operation mutex
Quaternion m_quaternion
imu orientation (and robot)
bool m_bBlackListed
IMU is [not] black listed.
Quaternion()
Default constructor.
void convertEuler(double phi, double theta, double psi)
Convert Euler angles to quaternion.
static const uint_t MspCmdIdAttitude
read raw attitude data
void convertTaitBryan(double roll, double pitch, double yaw)
Convert Tait-Bryan angles to quaternion.
std::string getDevName()
Get IMU device name.
static const int MspRspMaxLen
response max len
virtual bool hasAccelerometer()
Test if IMU has an accelerometer.
virtual bool isBlackListed()
Test if IMU is black listed.
std::string m_strDevName
serial device name
Top-level package include file.
static const int MspFieldPosCmdId
command id field position
void clear()
Clear quaternion values.