|
YARP
Yet Another Robot Platform
|
|
Go to the documentation of this file.
19 #ifndef BOSCH_IMU_DEVICE
20 #define BOSCH_IMU_DEVICE
67 #define START_BYTE 0xAA
68 #define WRITE_CMD 0x00
72 #define REPLY_HEAD 0xBB
73 #define ERROR_HEAD 0xEE
74 #define WRITE_SUCC 0x01
75 #define READ_FAIL 0x02
76 #define WRITE_FAIL 0x03
79 #define REGISTER_NOT_READY 0x07
83 #define REG_CHIP_ID 0x00
84 #define REG_SW_VERSION 0x04 // 2 software revision bytes
85 #define REG_BOOTLOADER 0x06 // 1 byte bootloader version
86 #define REG_PAGE_ID 0x07 // page ID number
88 #define REG_ACC_DATA 0x08 // 3*2 bytes: LSB first (LSB 0x08, MSB 0x09) for X
89 #define REG_MAGN_DATA 0x0E // 3*2 bytes: LSB first
90 #define REG_GYRO_DATA 0x14 // 3*2 bytes: LSB first
91 #define REG_RPY_DATA 0x1A // 3*2 bytes: LSB first (raw order is Yaw, Roll, Pitch)
92 #define REG_QUATERN_DATA 0x20 // 4*2 bytes: LSB first (raw order is w, x, y, z)
93 #define REG_GRAVITY 0x2E // Gravity Vector data
94 #define REG_CALIB_STATUS 0x35 // Check if sensors are calibrated, 2 bits each. SYS - GYRO - ACC - MAG. 3 means calibrated, 0 not calbrated
95 #define REG_SYS_CLK_STATUS 0x38 // only 1 last LSB
96 #define REG_SYS_STATUS 0x39
97 #define REG_SYS_ERR 0x3A
98 #define REG_UNIT_SEL 0x3B
99 #define REG_OP_MODE 0x3D
100 #define REG_POWER_MODE 0x3E
101 #define REG_SYS_TRIGGER 0x3F
104 #define CONFIG_MODE 0x00
105 #define AMG_MODE 0x07
106 #define IMU_MODE 0x08
107 #define M4G_MODE 0x0A
108 #define NDOF_MODE 0x0C
111 #define TRIG_EXT_CLK_SEL 0x80 // 1 for external clock (if available), 0 for internal clock
112 #define TRIG_RESET_INT 0x40 // reset interrupts
113 #define TRIG_RESET_SYSTEM 0x20 // reset system
114 #define TRIG_SELF_TEST 0x01 // Start self test
116 #define BNO055_ID 0xA0
118 #define RESP_HEADER_SIZE 2
120 #define SWITCHING_TIME 0.020 // 20ms
121 #define TIME_REPORT_INTERVAL 30
123 #define ATTEMPTS_NUM_OF_SEND_CONFIG_CMD 3
198 bool sendReadCommandSer(
unsigned char register_add,
int len,
unsigned char* buf, std::string comment =
"");
199 bool sendWriteCommandSer(
unsigned char register_add,
int len,
unsigned char* cmd, std::string comment =
"");
203 bool sendReadCommandI2c(
unsigned char register_add,
int len,
unsigned char* buf, std::string comment =
"");
224 bool close()
override;
246 bool calibrate(
int ch,
double v)
override;
423 bool genericGetSensorName(
size_t sens_index, std::string &name)
const;
424 bool genericGetFrameName(
size_t sens_index, std::string &frameName)
const;
426 std::string m_sensorName;
427 std::string m_frameName;
431 #endif // BOSCH_IMU_DEVICE
size_t getNrOfOrientationSensors() const override
Get the number of orientation sensors in the device.
yarp::sig::Vector data_tmp
sensor data temporary buffer
yarp::dev::MAS_status getOrientationSensorStatus(size_t sens_index) const override
Get the status of orientation sensor.
bool sendWriteCommandSer(unsigned char register_add, int len, unsigned char *cmd, std::string comment="")
size_t getNrOfThreeAxisLinearAccelerometers() const override
Get the number of three axis linear accelerometers in the device.
bool close() override
Close the device.
A generic interface to sensors – gyro, a/d converters etc.
bool getChannels(int *nc) override
Get the number of channels of the sensor.
A base class for nested structures that can be searched.
contains the definition of a Vector type
yarp::os::ResourceFinder rf
resource finder object to load config parameters
bool threadInit() override
Initialize process with desired device configurations.
Interface implemented by all device drivers.
bool getThreeAxisMagnetometerFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame in which three axis magnetometer measurements are expressed.
yarp::math::Quaternion quaternion
orientation in quaternion representation
bool calibrate(int ch, double v) override
Calibrate the sensor, single channel.
yarp::dev::MAS_status getThreeAxisMagnetometerStatus(size_t sens_index) const override
Get the status of three axis magnetometer.
Device interface to one or multiple three axis magnetometers.
bool read(yarp::sig::Vector &out) override
Read a vector from the sensor.
Device interface to one or multiple three axis gyroscopes.
Device interface to one or multiple orientation sensors, such as IMUs with on board estimation algori...
bool verbose
Flag to get verbose output.
bool getThreeAxisLinearAccelerometerMeasure(size_t sens_index, yarp::sig::Vector &out, double ×tamp) const override
Get three axis linear accelerometer measurements.
yarp::dev::MAS_status getThreeAxisLinearAccelerometerStatus(size_t sens_index) const override
Get the status of three axis linear accelerometer.
bool i2c_flag
flag to check if device connected through i2c commununication
bool getThreeAxisGyroscopeMeasure(size_t sens_index, yarp::sig::Vector &out, double ×tamp) const override
Get three axis gyroscope measurements.
bool sendReadCommandI2c(unsigned char register_add, int len, unsigned char *buf, std::string comment="")
int fd
file descriptor to open device at system level
imuBosch_BNO055: This device will connect to the proper analogServer and read the data broadcasted ma...
yarp::sig::Vector errorCounter
bool(BoschIMU::*)(unsigned char, int, unsigned char *, std::string) ReadFuncPtr
Functor to choose between i2c or serial comm.
bool 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.
yarp::sig::Vector RPY_angle
orientation in Euler angle representation
bool checkWriteResponse(unsigned char *response)
bool getThreeAxisLinearAccelerometerName(size_t sens_index, std::string &name) const override
Get the name of three axis linear accelerometer.
bool getThreeAxisGyroscopeName(size_t sens_index, std::string &name) const override
Get the name of three axis gyroscope.
constexpr int MAX_MSG_LENGTH
Device interface to one or multiple three axis linear accelerometers.
std::atomic< bool > dataIsValid
int nChannels
number of channels in the output port. Default 12. If 16, also includes quaternion data
std::mutex mutex
mutex to avoid resource clash
short status
device status - UNUSED
double m_timeStamp
device timestamp
yarp::math::Quaternion quaternion_tmp
orientation in quaternion representation
bool sendReadCommandSer(unsigned char register_add, int len, unsigned char *buf, std::string comment="")
bool checkReadResponse(unsigned char *response)
void printBuffer(unsigned char *buffer, int length)
An abstraction for a periodic thread.
bool open(yarp::os::Searchable &config) override
Open the device and set up parameters/communication.
bool checkError
flag to check read error of sensor data
yarp::sig::Vector errorReading
ReadFuncPtr readFunc
Functor object.
double timeLastReport
timestamp of last reported data
int readBytes(unsigned char *buffer, int bytes)
bool sendAndVerifyCommandSer(unsigned char register_add, int len, unsigned char *cmd, std::string comment)
bool getOrientationSensorMeasureAsRollPitchYaw(size_t sens_index, yarp::sig::Vector &rpy, double ×tamp) const override
Get orientation sensor measurements.
yarp::dev::MAS_status getThreeAxisGyroscopeStatus(size_t sens_index) const override
Get the status of three axis gyroscope.
bool getOrientationSensorFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame in which orientation sensor measurements are expressed.
MAS_status
Status of a given analog sensor exposed by a multiple analog sensors interface.
bool getThreeAxisMagnetometerName(size_t sens_index, std::string &name) const override
Get the name of three axis magnetometer.
bool getThreeAxisGyroscopeFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame in which three axis gyroscope measurements are expressed.
size_t getNrOfThreeAxisMagnetometers() const override
Get the number of three axis magnetometers in the device.
bool getThreeAxisMagnetometerMeasure(size_t sens_index, yarp::sig::Vector &out, double ×tamp) const override
Get three axis magnetometer measurements.
void run() override
Update loop where measurements are read from the device.
size_t getNrOfThreeAxisGyroscopes() const override
Get the number of three axis gyroscopes in the device.
unsigned char command[MAX_MSG_LENGTH]
packet to be written to the device
unsigned char response[MAX_MSG_LENGTH]
packet to be read from the device
yarp::sig::Vector data
sensor data buffer
void threadRelease() override
Terminate communication with the device and release the thread.
bool getOrientationSensorName(size_t sens_index, std::string &name) const override
Get the name of orientation sensor.
Helper class for finding config files and other external resources.