RBCX
Library for the RB3204-RBCX board with the ESP32 by RoboticsBrno.
Loading...
Searching...
No Matches
RBCXMpu.h
Go to the documentation of this file.
1#pragma once
2
3#include <freertos/FreeRTOS.h>
4
5#include "rbcx.pb.h"
6namespace rb {
7
8struct MpuVector {
10 : x(0)
11 , y(0)
12 , z(0) {}
13 float x;
14 float y;
15 float z;
16};
17
18struct MpuMotion9 {
23};
24
25struct MpuMotion6 {
28};
29
33class Mpu {
34 friend class Manager;
35
36public:
41 void init();
42
48 void sendOne();
49
55 void sendStart();
56
61 void sendStop();
62
67 void setCalibrationData();
68
73
79
84 float getAccX();
85
90 float getAccY();
91
96 float getAccZ();
97
103
108 float getGyroX();
109
114 float getGyroY();
115
120 float getGyroZ();
121
127
132 float getAngleX();
133
138 float getAngleY();
139
148 float getAngleZ();
149
150 // Reset heading back to 0
151 void resetAngleZ();
152
158 void setCompressCoef(uint8_t coef);
159
164 uint8_t getCompressCoef();
165
166private:
167 MpuMotion9 m_mpuMotion;
168 MpuMotion6 m_mpuMotionOffset;
169
170 TickType_t m_lastTicks;
171
172 uint8_t m_compressCoef;
173
174 Mpu();
175 Mpu(const Mpu&) = delete;
176 ~Mpu();
177
178 void setState(const CoprocStat_MpuStat& msg);
179 void calculateAcc(const CoprocStat_MpuVector& accel);
180 void calculateGyro(const CoprocStat_MpuVector& gyro);
181 void calculateAngle();
182
183 float wrap(float angle, float limit);
184
185 void sendMpuReq(CoprocReq_MpuReq mpuReq);
186};
187};
The main library class for working with the RBCX board. Call the install() method at the start of you...
Definition: RBCXManager.h:61
Helper class for controlling the Mpu.
Definition: RBCXMpu.h:33
void sendStop()
Stop sending the Mpu data continuously to the coprocessor. To start the continuous sending,...
Definition: RBCXMpu.cpp:52
MpuVector getGyro()
Get the Mpu gyroscope data.
Definition: RBCXMpu.cpp:165
float getGyroY()
Get the Mpu gyroscope data on the Y axis.
Definition: RBCXMpu.cpp:167
MpuVector getAngle()
Get the Mpu angle data.
Definition: RBCXMpu.cpp:170
float getGyroZ()
Get the Mpu gyroscope data on the Z axis.
Definition: RBCXMpu.cpp:168
MpuVector getAcc()
Get the Mpu acceleration data.
Definition: RBCXMpu.cpp:160
void setCalibrationData()
Records current Gyro and Accelerometer data as "start" position and subtracts it from future readings...
Definition: RBCXMpu.cpp:69
void resetAngleZ()
Definition: RBCXMpu.cpp:147
void clearCalibrationData()
Clears the data recorded by setCalibrationData.
Definition: RBCXMpu.cpp:65
void sendOne()
Send a one shot request to the coprocessor to get the Mpu data. The data will be available in the get...
Definition: RBCXMpu.cpp:40
float getAccZ()
Get the Mpu acceleration data on the Z axis.
Definition: RBCXMpu.cpp:163
float getGyroX()
Get the Mpu gyroscope data on the X axis.
Definition: RBCXMpu.cpp:166
float getAngleZ()
Get the Mpu angle data on the Z axis.
Definition: RBCXMpu.cpp:173
float getAngleY()
Get the Mpu angle data on the Y axis.
Definition: RBCXMpu.cpp:172
void init()
Initialize the Mpu. This function must be called before using the Mpu. It will send a request to the ...
Definition: RBCXMpu.cpp:34
float getAccX()
Get the Mpu acceleration data on the X axis.
Definition: RBCXMpu.cpp:161
uint8_t getCompressCoef()
Get the Mpu compression coefficient (1 - 20).
Definition: RBCXMpu.cpp:185
float getAngleX()
Get the Mpu angle data on the X axis.
Definition: RBCXMpu.cpp:171
void setCompressCoef(uint8_t coef)
Set the Mpu compression coefficient (10 - 20). It is used to reduce sending interval....
Definition: RBCXMpu.cpp:175
void sendStart()
Start sending the Mpu data continuously to the coprocessor. The data will be available in the get fun...
Definition: RBCXMpu.cpp:46
float getAccY()
Get the Mpu acceleration data on the Y axis.
Definition: RBCXMpu.cpp:162
Definition: RBCXAngle.cpp:3
Definition: RBCXMpu.h:25
MpuVector accel
Definition: RBCXMpu.h:26
MpuVector gyro
Definition: RBCXMpu.h:27
Definition: RBCXMpu.h:18
MpuVector gyro
Definition: RBCXMpu.h:20
MpuVector angleAcc
Definition: RBCXMpu.h:22
MpuVector angle
Definition: RBCXMpu.h:21
MpuVector accel
Definition: RBCXMpu.h:19
Definition: RBCXMpu.h:8
float z
Definition: RBCXMpu.h:15
float x
Definition: RBCXMpu.h:13
MpuVector()
Definition: RBCXMpu.h:9
float y
Definition: RBCXMpu.h:14