#include <MotionDetection.h>
|
| MotionDetection () |
|
void | begin (void) |
| initialized the IMU Component. Wakes the IMU from Standby Set configuration More...
|
|
void | end (void) |
| stops the component Sets the IMU to Low-Power-Mode More...
|
|
IMUResult | getAcceleration (void) |
| Triggers a new Reading of the accelerationvalues and reads them from the IMU. More...
|
|
IMUResult | getRotation (void) |
| Triggers a new reading of the gyroscope and reads the values from the imu. More...
|
|
float | getTemperature (void) |
| Reads the current On Chip temperature of the IMU. More...
|
|
int8_t | getWhoAmI (void) |
| Returns the value of reading the whoAmI register When IMU working correctly, value should be 0x67. More...
|
|
bool | isShaken (uint32_t threshold=defaultShakeThreshold, uint8_t axis=xAxis|yAxis|zAxis) |
| Detects if at the time of calling is shaken. Therefore the sum over all accelerationvalues is calculated and checked against threshold. If sum > threshold a shake is detected, else not. More...
|
|
Orientation | getTilt () |
| calculates how the robot is tilted. It is set, that when the robot is placed normally on a flat table, the result will be (0,0) Tilting the robot, so that the front leg is deeper than the other to results in an increasing degrees, tilting the front leg up will increase negativ degrees Tilting the robot to the right will increase the degrees until 180° (upside down), tilting it left will result in increasing negativ degrees (-1,-2,...,-180). On the top there is a jump of the values from 180->-180 and vice versa. More...
|
|
Direction | getTiltDirection (uint tolerance=10) |
| Checks in which direction (Front, Left, Right, Back) the robot is tilted. More...
|
|
void | calibrateZAxis (uint gforceValue) |
|
uint | getDataFromFIFO (FIFO_Package *buffer) |
| will read all availible packages from fifo, after 40ms Fifo is full More...
|
|
Definition at line 51 of file MotionDetection.h.
◆ registerBank
◆ MotionDetection()
MotionDetection::MotionDetection |
( |
| ) |
|
◆ begin()
void MotionDetection::begin |
( |
void |
| ) |
|
initialized the IMU Component. Wakes the IMU from Standby Set configuration
Definition at line 8 of file MotionDetection.cpp.
◆ calibrateZAxis()
void MotionDetection::calibrateZAxis |
( |
uint |
gforceValue | ) |
|
can be used to set a custom value for the gforceReading of the zaxis, which will improve the getTiltFunction.
- Attention
- this method is not persisten, so the value is not stored when the programm is restarted / the robot is powerd off
- Parameters
-
gforceValue | the value the IMU returns for the gravitationforce -> to get this value, place the robot on a leveled surface and read the value getAcceleration().z |
Definition at line 74 of file MotionDetection.cpp.
◆ cmdRead() [1/2]
uint8_t MotionDetection::cmdRead |
( |
uint8_t |
reg | ) |
|
|
protected |
◆ cmdRead() [2/2]
uint16_t MotionDetection::cmdRead |
( |
uint8_t |
regHigh, |
|
|
uint8_t |
regLow |
|
) |
| |
|
protected |
◆ cmdWrite() [1/2]
uint8_t MotionDetection::cmdWrite |
( |
uint8_t |
reg | ) |
|
|
protected |
◆ cmdWrite() [2/2]
uint16_t MotionDetection::cmdWrite |
( |
uint8_t |
regHigh, |
|
|
uint8_t |
regLow |
|
) |
| |
|
protected |
◆ end()
void MotionDetection::end |
( |
void |
| ) |
|
◆ getAcceleration()
IMUResult MotionDetection::getAcceleration |
( |
void |
| ) |
|
Triggers a new Reading of the accelerationvalues and reads them from the IMU.
- Returns
- IMUResult that contains the new read values
Definition at line 28 of file MotionDetection.cpp.
◆ getDataFromFIFO()
uint MotionDetection::getDataFromFIFO |
( |
FIFO_Package * |
buffer | ) |
|
will read all availible packages from fifo, after 40ms Fifo is full
- Parameters
-
buffer | pointer to FIFO_Package Struct that at least must have size 64 (this is the max package count with APEX Enabled) |
- Returns
- the amount of acutally fetched packages
Definition at line 245 of file MotionDetection.cpp.
◆ getRotation()
IMUResult MotionDetection::getRotation |
( |
void |
| ) |
|
◆ getTemperature()
float MotionDetection::getTemperature |
( |
void |
| ) |
|
Reads the current On Chip temperature of the IMU.
- Returns
- normalized temperature in degree Centigrade
Definition at line 45 of file MotionDetection.cpp.
◆ getTilt()
calculates how the robot is tilted. It is set, that when the robot is placed normally on a flat table, the result will be (0,0) Tilting the robot, so that the front leg is deeper than the other to results in an increasing degrees, tilting the front leg up will increase negativ degrees Tilting the robot to the right will increase the degrees until 180° (upside down), tilting it left will result in increasing negativ degrees (-1,-2,...,-180). On the top there is a jump of the values from 180->-180 and vice versa.
Precision is rounded to 1 deg steps
- Attention
- The results are only valid, if the robot is not moved in any way during the measurment, as the calculation is made by using the accelration values. If it's detected, that the robot is accelerated while measuring, the method will return max(int). Please note that the imu is pretty sensitiv, even walking next to the table may influcene the result.
Definition at line 78 of file MotionDetection.cpp.
◆ getTiltDirection()
Direction MotionDetection::getTiltDirection |
( |
uint |
tolerance = 10 | ) |
|
Checks in which direction (Front, Left, Right, Back) the robot is tilted.
- Attention
- Does only work if the robot is not moving
- Parameters
-
tolerance | (optional, default = 10) how many degrees can the robot be tilted, and still will be considerd as neutral. |
- Returns
- Direction the direction in that the robot is tilted most. Front is onsiderd as the direction of driving. If robot is not tilted more than the tolerance in any direction, return is Neutral. If Robot is upside down, return is Flipped. If Robot is moved, return is Error
Definition at line 122 of file MotionDetection.cpp.
◆ getWhoAmI()
int8_t MotionDetection::getWhoAmI |
( |
void |
| ) |
|
Returns the value of reading the whoAmI register When IMU working correctly, value should be 0x67.
- Returns
- the value of the whoami register of the ICM-42670
Definition at line 51 of file MotionDetection.cpp.
◆ initFIFO()
void MotionDetection::initFIFO |
( |
| ) |
|
|
protected |
◆ isShaken()
Detects if at the time of calling is shaken. Therefore the sum over all accelerationvalues is calculated and checked against threshold. If sum > threshold a shake is detected, else not.
- Parameters
-
threshold | (optional) the level of acceleration that must be reached to detect a shake |
axis | (optional) select which axis should be used for detection. Possible values ar xAxis,yAxis,zAxis It's possible to combine multiple axis with the bitwise or Operator | For Example: to detect x and y axis: axis = xAxis|yAxis |
- Returns
- true if a shake is detected, false else
Definition at line 55 of file MotionDetection.cpp.
◆ readDoubleRegister()
int16_t MotionDetection::readDoubleRegister |
( |
uint8_t |
lowerReg | ) |
|
|
protected |
◆ readFromRegisterBank()
uint8_t MotionDetection::readFromRegisterBank |
( |
registerBank |
bank, |
|
|
uint8_t |
reg |
|
) |
| |
|
protected |
◆ readRegister()
uint8_t MotionDetection::readRegister |
( |
uint8_t |
reg | ) |
|
|
protected |
◆ resetRegisterBankAccess()
void MotionDetection::resetRegisterBankAccess |
( |
| ) |
|
|
protected |
◆ writeRegister()
void MotionDetection::writeRegister |
( |
uint8_t |
reg, |
|
|
uint8_t |
value |
|
) |
| |
|
protected |
◆ writeToRegisterBank()
void MotionDetection::writeToRegisterBank |
( |
registerBank |
bank, |
|
|
uint8_t |
reg, |
|
|
uint8_t |
value |
|
) |
| |
|
protected |
◆ buf
◆ bufferLength
const uint MotionDetection::bufferLength = 64*16 |
|
protected |
◆ defaultShakeThreshold
const uint16_t MotionDetection::defaultShakeThreshold = 500 |
|
staticprotected |
◆ frequency
const uint MotionDetection::frequency = 24000000 |
|
staticprotected |
◆ gForceCalib
uint MotionDetection::gForceCalib = 4050 |
|
protected |
◆ handler
SPIClass* MotionDetection::handler = NULL |
|
protected |
The documentation for this class was generated from the following files: