Functions which handle the inertial measurement unit. More...
Modules | |
| Advanced informations | |
Enumerations | |
| enum | eImuGyroResolution |
| clusters all possible values for the maximum angular veloctiy (yaw angle) More... | |
| enum | eImuSelectMask |
| clusters bit masks for the requests of the imu More... | |
| enum | eImuGet |
| clusters select values for reading data from the imu More... | |
| enum | eImuSet |
| clusters select values for writing data to the imu More... | |
Functions | |
| uint8_t | imu_calibrate (void) |
| Sets the three offsets through simple bias estimation. More... | |
Request Funktions | |
| void | imu_request (eImuSelectMask bitmask, eRequestType request) |
| Requests new data from the imu. More... | |
| eImuSelectMask | imu_received (eImuSelectMask bitmask) |
| Indicates if new data for the selected data blocks were received. More... | |
| eImuSelectMask | imu_changed (eImuSelectMask bitmask) |
| Indicates if new data changed the selected data blocks. More... | |
Access Funktions | |
| int16_t | imu_get (eImuGet select) |
| Returns the last stored version of the selected value. More... | |
| void | imu_set (eImuSet select, int16_t value) |
| Sets the selected value of the imu sensors. More... | |
Functions which handle the inertial measurement unit.
The MPU6050 is an IMU (Inertial Measurement Unit), which is integrated into the TUC-Bot. This IMU contains different sensors for measuring the angular velocities and the acceleration of the x-, y- and z-axis. The MPU6050 also contains a sensor, that can measure the temperature.
With the use of this IMU it is possible to improve the determination of the orientation and position of the TUC-Bot.
The IMU will be initialized by executing the function init_tucbot(). To check the success of initialization, call imu_get() with parameter kImuGetStateInit. The IMU might be manually (re-)initialized by using tucbot_imu_reset().
In order to improve the accuracy of the IMU, the function imu_calibrate() needs to be executed. While the IMU is calibrating all its sensors, the TUC-Bot must not be moved for 5-6 seconds! With the use of the functions imu_get() and imu_set() it is possible to either get or set the offsets of the IMU.
To receive data from the IMU, the function imu_request() must be executed.
example
| enum eImuGet |
clusters select values for reading data from the imu
| Enumerator | |
|---|---|
| kImuGetOrientation | constant ( 1): orientation of robot - around z-axis (16-bit) |
| kImuGetAccelX | constant ( 2): linear acceleration along x-axis (16-bit) |
| kImuGetAccelY | constant ( 3): linear acceleration along y-axis (16-bit) |
| kImuGetGyroZ | constant ( 4): angular velocity around z-axis (16-bit) |
| kImuGetTemperature | constant ( 5): temperature (16-bit) |
| kImuGetStateInit | constant ( 6): initialization of imu |
| kImuGetUseSmallFilter | constant ( 7): small-velocity-filter |
| kImuGetUseMotorFilter | constant ( 8): motor-filter |
| kImuGetGyroResolution | constant ( 9): maximum angular velocity |
| kImuGetOffsetX | constant (10): offset for linear accel. along x-axis (16-bit) |
| kImuGetOffsetY | constant (11): offset for linear accel. along y-axis (16-bit) |
| kImuGetOffsetZ | constant (12): offset for angular vel. around z-axis (16-bit) |
| kImuGetAccelZ | constant (13): linear acceleration along z-axis (16-bit) |
| kImuGetGyroX | constant (14): angular velocity around x-axis (16-bit) |
| kImuGetGyroY | constant (15): angular velocity around y-axis (16-bit) |
| enum eImuGyroResolution |
clusters all possible values for the maximum angular veloctiy (yaw angle)
The values correlate to the GYRO_CONFIG register of the IMU.
The current resolution for the gyro registers (e.g. kImuRegGyroZ) depend on the maximum angular velocity:
1 LSB = max_velocity / 2^15; // Not 2^16, since 1 bit is needed for the signedness.
| Enumerator | |
|---|---|
| kImuGyroResolution250 | constant (0x00): +/-250 degree/s |
| kImuGyroResolution500 | constant (0x08): +/-500 degree/s |
| kImuGyroResolution1000 | constant (0x10): +/-1000 degree/s |
| kImuGyroResolution2000 | constant (0x18): +/-2000 degree/s |
| kImuGyroResolutionDefault | constant (kImuGyroResolution500): default setting on startup |
| kImuGyroResolutionError | constant: indicating error during readout |
| enum eImuSelectMask |
clusters bit masks for the requests of the imu
| Enumerator | |
|---|---|
| kImuSelectNone | bit mask (0x00): select no data block |
| kImuSelectAccelerometer | bit mask (0x01): linear accelerations (16-bit) |
| kImuSelectTemperature | bit mask (0x02): temperature (16-bit) |
| kImuSelectGyroscope | bit mask (0x04): angular velocities (16-bit) |
| kImuSelectAll | bit mask (0x07): select all data blocks |
| enum eImuSet |
clusters select values for writing data to the imu
| Enumerator | |
|---|---|
| kImuSetOrientation | constant (kImuGetOrientation): orientation of robot - around z-axis (16-bit) |
| kImuSetUseSmallFilter | constant (kImuGetUseSmallFilter): small-velocity-filter (boolean) |
| kImuSetUseMotorFilter | constant (kImuGetUseMotorFilter): motor-filter (boolean) |
| kImuSetGyroResolution | constant (kImuGetGyroResolution): maximum angular velocity |
| kImuSetOffsetX | constant (kImuGetOffsetX): offset of linear accel. along x-axis (16-bit) |
| kImuSetOffsetY | constant (kImuGetOffsetY): offset of linear accel. along y-axis (16-bit) |
| kImuSetOffsetZ | constant (kImuGetOffsetZ): offset of angular vel. around z-axis (16-bit) |
| uint8_t imu_calibrate | ( | void | ) |
Sets the three offsets through simple bias estimation.
This function will automatically request the imu data and try to estimates the offsets.
The TUC-Bot must not move during the calibration.
| eImuSelectMask imu_changed | ( | eImuSelectMask | bitmask | ) |
Indicates if new data changed the selected data blocks.
| bitmask | bit mask of the selected data blocks - see also eImuSelectMask The parameter is used to only return the value of the masked changed-bits. All other values(bits) are set to 0. |
| int16_t imu_get | ( | eImuGet | select | ) |
Returns the last stored version of the selected value.
This function relies on the internal data blocks sMI_Accelerometer, sMI_Temperature and sMI_Gyroscope - for new data use imu_request()
| select | value of the selected data - see also eImuGet |
| select | decription |
| kImuGetOrientation | absolute orientation of robot |
| kImuGetAccelX kImuGetAccelY | linear acceleration (offset corrected) |
| kImuGetGyroZ | angular velocity (offset corrected) |
| kImuGetTemperature | temperature |
| ... | for more details see also eImuGet |
| eImuSelectMask imu_received | ( | eImuSelectMask | bitmask | ) |
Indicates if new data for the selected data blocks were received.
| bitmask | bit mask of the selected data blocks - see also eImuSelectMask The parameter is used to only return the value of the masked received-bits. All other values(bits) are set to 0. |
| void imu_request | ( | eImuSelectMask | bitmask, |
| eRequestType | request | ||
| ) |
Requests new data from the imu.
For details on the request schema see The general request.
Involved data blocks are:
sMI_Accelerometer, sMI_Temperature and sMI_Gyroscope
| bitmask | bit mask of the selected data blocks - see also eImuSelectMask |
| request | See also eRequestType |
| void imu_set | ( | eImuSet | select, |
| int16_t | value | ||
| ) |
Sets the selected value of the imu sensors.
| select | value of the selected data - see also eImuSet |
| value | 16-bit integer value to be stored within the selected data |
1.8.17