6#ifndef BOSCH_IMU_DEVICE
7#define BOSCH_IMU_DEVICE
55#define START_BYTE 0xAA
60#define REPLY_HEAD 0xBB
61#define ERROR_HEAD 0xEE
62#define WRITE_SUCC 0x01
64#define WRITE_FAIL 0x03
67#define REGISTER_NOT_READY 0x07
71#define REG_CHIP_ID 0x00
72#define REG_SW_VERSION 0x04
73#define REG_BOOTLOADER 0x06
74#define REG_PAGE_ID 0x07
76#define REG_ACC_DATA 0x08
77#define REG_MAGN_DATA 0x0E
78#define REG_GYRO_DATA 0x14
79#define REG_RPY_DATA 0x1A
80#define REG_QUATERN_DATA 0x20
81#define REG_GRAVITY 0x2E
82#define REG_CALIB_STATUS 0x35
83#define REG_SYS_CLK_STATUS 0x38
84#define REG_SYS_STATUS 0x39
85#define REG_SYS_ERR 0x3A
86#define REG_UNIT_SEL 0x3B
87#define REG_OP_MODE 0x3D
88#define REG_POWER_MODE 0x3E
89#define REG_SYS_TRIGGER 0x3F
92#define CONFIG_MODE 0x00
99#define TRIG_EXT_CLK_SEL 0x80
100#define TRIG_RESET_INT 0x40
101#define TRIG_RESET_SYSTEM 0x20
102#define TRIG_SELF_TEST 0x01
104#define BNO055_ID 0xA0
106#define RESP_HEADER_SIZE 2
108#define SWITCHING_TIME 0.020
109#define TIME_REPORT_INTERVAL 30
111#define ATTEMPTS_NUM_OF_SEND_CONFIG_CMD 3
176 bool sendReadCommandSer(
unsigned char register_add,
int len,
unsigned char* buf, std::string comment =
"");
177 bool sendWriteCommandSer(
unsigned char register_add,
int len,
unsigned char* cmd, std::string comment =
"");
181 bool sendReadCommandI2c(
unsigned char register_add,
int len,
unsigned char* buf, std::string comment =
"");
202 bool close()
override;
224 bool calibrate(
int ch,
double v)
override;
contains the definition of a Vector type
This class is the parameters parser for class BoschIMU.
imuBosch_BNO055: This device will connect to the proper analogServer and read the data broadcasted ma...
void threadRelease() override
Terminate communication with the device and release the thread.
yarp::sig::Vector errorReading
unsigned char command[MAX_MSG_LENGTH]
packet to be written to the device
yarp::dev::ReturnValue getThreeAxisLinearAccelerometerFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame in which three axis linear accelerometer measurements are expressed.
bool sendReadCommandSer(unsigned char register_add, int len, unsigned char *buf, std::string comment="")
std::atomic< bool > dataIsValid
std::mutex mutex
mutex to avoid resource clash
short status
device status - UNUSED
bool checkReadResponse(unsigned char *response)
yarp::dev::ReturnValue getNrOfThreeAxisLinearAccelerometers(size_t &num) const override
Get the number of three axis linear accelerometers in the device.
ReadFuncPtr readFunc
Functor object.
yarp::math::Quaternion quaternion_tmp
orientation in quaternion representation
void printBuffer(unsigned char *buffer, int length)
bool checkError
flag to check read error of sensor data
yarp::sig::Vector data
sensor data buffer
yarp::os::ResourceFinder rf
resource finder object to load config parameters
bool getChannels(int *nc) override
Get the number of channels of the sensor.
yarp::dev::ReturnValue getThreeAxisGyroscopeFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame in which three axis gyroscope measurements are expressed.
bool sendReadCommandI2c(unsigned char register_add, int len, unsigned char *buf, std::string comment="")
yarp::dev::ReturnValue getNrOfThreeAxisMagnetometers(size_t &num) const override
Get the number of three axis magnetometers in the device.
yarp::dev::ReturnValue getOrientationSensorName(size_t sens_index, std::string &name) const override
Get the name of orientation sensor.
yarp::dev::ReturnValue getThreeAxisLinearAccelerometerName(size_t sens_index, std::string &name) const override
Get the name of three axis linear accelerometer.
bool close() override
Close the device.
double m_timeStamp
device timestamp
unsigned char response[MAX_MSG_LENGTH]
packet to be read from the device
yarp::dev::ReturnValue getThreeAxisMagnetometerName(size_t sens_index, std::string &name) const override
Get the name of three axis magnetometer.
bool threadInit() override
Initialize process with desired device configurations.
yarp::dev::ReturnValue getOrientationSensorMeasureAsRollPitchYaw(size_t sens_index, yarp::sig::Vector &rpy, double ×tamp) const override
Get orientation sensor measurements.
bool verbose
Flag to get verbose output.
bool sendAndVerifyCommandSer(unsigned char register_add, int len, unsigned char *cmd, std::string comment)
yarp::dev::ReturnValue getThreeAxisLinearAccelerometerMeasure(size_t sens_index, yarp::sig::Vector &out, double ×tamp) const override
Get three axis linear accelerometer measurements.
bool checkWriteResponse(unsigned char *response)
yarp::dev::ReturnValue getThreeAxisMagnetometerMeasure(size_t sens_index, yarp::sig::Vector &out, double ×tamp) const override
Get three axis magnetometer measurements.
bool calibrate(int ch, double v) override
Calibrate the sensor, single channel.
yarp::sig::Vector errorCounter
yarp::dev::MAS_status getOrientationSensorStatus(size_t sens_index) const override
Get the status of orientation sensor.
yarp::dev::ReturnValue getThreeAxisMagnetometerFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame in which three axis magnetometer measurements are expressed.
bool read(yarp::sig::Vector &out) override
Read a vector from the sensor.
yarp::dev::ReturnValue getNrOfThreeAxisGyroscopes(size_t &num) const override
Get the number of three axis gyroscopes in the device.
yarp::dev::MAS_status getThreeAxisGyroscopeStatus(size_t sens_index) const override
Get the status of three axis gyroscope.
yarp::math::Quaternion quaternion
orientation in quaternion representation
bool sendWriteCommandSer(unsigned char register_add, int len, unsigned char *cmd, std::string comment="")
yarp::dev::MAS_status getThreeAxisMagnetometerStatus(size_t sens_index) const override
Get the status of three axis magnetometer.
double timeLastReport
timestamp of last reported data
int readBytes(unsigned char *buffer, int bytes)
int fd
file descriptor to open device at system level
bool m_i2c_flag
flag to check if device connected through i2c commununication
bool open(yarp::os::Searchable &config) override
Open the device and set up parameters/communication.
yarp::dev::ReturnValue getNrOfOrientationSensors(size_t &num) const override
Get the number of orientation sensors in the device.
yarp::sig::Vector data_tmp
sensor data temporary buffer
yarp::sig::Vector RPY_angle
orientation in Euler angle representation
bool(BoschIMU::*)(unsigned char, int, unsigned char *, std::string) ReadFuncPtr
Functor to choose between i2c or serial comm.
yarp::dev::ReturnValue getThreeAxisGyroscopeName(size_t sens_index, std::string &name) const override
Get the name of three axis gyroscope.
yarp::dev::MAS_status getThreeAxisLinearAccelerometerStatus(size_t sens_index) const override
Get the status of three axis linear accelerometer.
yarp::dev::ReturnValue getOrientationSensorFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame in which orientation sensor measurements are expressed.
yarp::dev::ReturnValue getThreeAxisGyroscopeMeasure(size_t sens_index, yarp::sig::Vector &out, double ×tamp) const override
Get three axis gyroscope measurements.
void run() override
Update loop where measurements are read from the device.
Interface implemented by all device drivers.
A generic interface to sensors – gyro, a/d converters etc.
Device interface to one or multiple orientation sensors, such as IMUs with on board estimation algori...
Device interface to one or multiple three axis gyroscopes.
Device interface to one or multiple three axis linear accelerometers.
Device interface to one or multiple three axis magnetometers.
An abstraction for a periodic thread.
Helper class for finding config files and other external resources.
A base class for nested structures that can be searched.
constexpr int MAX_MSG_LENGTH
MAS_status
Status of a given analog sensor exposed by a multiple analog sensors interface.