Skip to content

Commit b113287

Browse files
imu mag bug, ignored for now
1 parent 29c0b96 commit b113287

9 files changed

+111101
-64
lines changed

General_Driver/IMU.cpp

+2-22
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@ float angles[3];
2828
float q0, q1, q2, q3;
2929

3030
void imuInit()
31-
{
32-
// Wire.begin(S_SDA, S_SCL);
33-
// Serial.begin(115200);
34-
31+
{
3532
if (qmi8658_.begin() == 0)
3633
Serial.println("qmi8658_init fail");
3734

@@ -53,10 +50,6 @@ void imuInit()
5350
break;
5451
}
5552
}
56-
// Serial.println("Start figure-8 calibration after 1 seconds.");
57-
// delay(1000);
58-
// calibrate(10000, &offset_x, &offset_y, &offset_z);
59-
// calibrateMagn();
6053
q0 = 1.0f;
6154
q1 = 0.0f;
6255
q2 = 0.0f;
@@ -72,25 +65,14 @@ void imuDataGet(EulerAngles *pstAngles,
7265
float acc[3], gyro[3];
7366
float MotionVal[9];
7467

75-
magnetometer_.getData(&x, &y, &z);
68+
// magnetometer_.getData(&x, &y, &z);
7669

7770
pstMagnRawData->s16X = x- offset_x;
7871
pstMagnRawData->s16Y = y- offset_y;
7972
pstMagnRawData->s16Z = z- offset_z;
8073

81-
// qmi8658_.GetEulerAngles(&pstAngles->pitch,&pstAngles->roll,&pstAngles->yaw,acc,gyro);
8274
qmi8658_.read_sensor_data(acc,gyro);
8375

84-
// pstAngles->roll = atan2((float)acc[1], (float)acc[2]);
85-
// pstAngles->pitch = atan2(-(float)acc[0], sqrt((float)(acc[1] * acc[1]) + (float)(acc[2] * acc[2])));
86-
87-
// double Xheading = pstMagnRawData->s16X * cos(pstAngles->pitch) + pstMagnRawData->s16Y * sin(pstAngles->roll) * sin(pstAngles->pitch) + pstMagnRawData->s16Z * cos(pstAngles->roll) * sin(pstAngles->pitch);
88-
// double Yheading = pstMagnRawData->s16Y * cos(pstAngles->roll) - pstMagnRawData->s16Z * sin(pstAngles->pitch);
89-
90-
// pstAngles->yaw = /*180 + */57.3 * atan2(Yheading, Xheading) + declination_shenzhen;
91-
92-
// pstAngles->roll = atan2((float)acc[1], (float)acc[2]) * 57.3;
93-
// pstAngles->pitch = atan2(-(float)acc[0], sqrt((float)(acc[1] * acc[1]) + (float)(acc[2] * acc[2]))) * 57.3;
9476
MotionVal[0]=gyro[0];
9577
MotionVal[1]=gyro[1];
9678
MotionVal[2]=gyro[2];
@@ -105,8 +87,6 @@ void imuDataGet(EulerAngles *pstAngles,
10587
(float)MotionVal[3], (float)MotionVal[4], (float)MotionVal[5],
10688
(float)MotionVal[6], (float)MotionVal[7], MotionVal[8]);
10789

108-
109-
11090
pstAngles->pitch = asin(-2 * q1 * q3 + 2 * q0* q2)* 57.3; // pitch
11191
pstAngles->roll = atan2(2 * q2 * q3 + 2 * q0 * q1, -2 * q1 * q1 - 2 * q2* q2 + 1)* 57.3; // roll
11292
pstAngles->yaw = atan2(-2 * q1 * q2 - 2 * q0 * q3, 2 * q2 * q2 + 2 * q3 * q3 - 1) * 57.3;

General_Driver/IMU_ctrl.h

+2-40
Original file line numberDiff line numberDiff line change
@@ -35,35 +35,7 @@ void updateIMUData() {
3535

3636

3737
void imuCalibration() {
38-
// jsonInfoHttp.clear();
39-
// switch (inputStep) {
40-
// case 0:
41-
// if (InfoPrint == 1){
42-
// jsonInfoHttp["info"] = "keep 10dof-imu device horizontal and then calibrate next step.";
43-
// }
44-
// break;
45-
// case 1:
46-
// calibrateStepA();
47-
// if (InfoPrint == 1){
48-
// jsonInfoHttp["info"] = "rotate z axis 180 degrees and then calibrate next step.";
49-
// }
50-
// break;
51-
// case 2:
52-
// calibrateStepB();
53-
// if (InfoPrint == 1){
54-
// jsonInfoHttp["info"] = "flip 10dof-imu device and keep it horizontal and then calibrate next step.";
55-
// }
56-
// break;
57-
// case 3:
58-
// calibrateStepC();
59-
// if (InfoPrint == 1){
60-
// jsonInfoHttp["info"] = "calibration done.";
61-
// }
62-
// break;
63-
// }
64-
// String getInfoJsonString;
65-
// serializeJson(jsonInfoHttp, getInfoJsonString);
66-
// Serial.println(getInfoJsonString);
38+
6739
}
6840

6941

@@ -95,19 +67,9 @@ void getIMUData() {
9567
}
9668

9769
void getIMUOffset() {
98-
// getIMUOffsetData(&offsetData);
99-
// jsonInfoHttp.clear();
100-
// jsonInfoHttp["T"] = 101;
101-
102-
// jsonInfoHttp["x"] = offsetData.X;
103-
// jsonInfoHttp["y"] = offsetData.Y;
104-
// jsonInfoHttp["z"] = offsetData.Z;
10570

106-
// String getInfoJsonString;
107-
// serializeJson(jsonInfoHttp, getInfoJsonString);
108-
// Serial.println(getInfoJsonString);
10971
}
11072

11173
void setIMUOffset(int16_t inputX, int16_t inputY, int16_t inputZ) {
112-
// setOffset(inputX, inputY, inputZ);
74+
11375
}
Binary file not shown.
Binary file not shown.
Binary file not shown.

General_Driver/build/esp32.esp32.esp32/General_Driver.ino.map

+111,094
Large diffs are not rendered by default.
Binary file not shown.

General_Driver/ugv_advance.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,8 @@ void baseInfoFeedback() {
388388

389389
jsonInfoHttp["r"] = icm_roll;
390390
jsonInfoHttp["p"] = icm_pitch;
391-
jsonInfoHttp["y"] = icm_yaw;
391+
// jsonInfoHttp["y"] = icm_yaw;
392+
jsonInfoHttp["y"] = "null";
392393

393394
// jsonInfoHttp["q0"] = qw;
394395
// jsonInfoHttp["q1"] = qx;

General_Driver/ugv_config.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ bool runNewJsonCmd = false;
3535
// 1: WAVE ROVER
3636
// 2: UGV02(UGV)
3737
// 3: UGV01(UGV)
38-
byte mainType = 2;
38+
byte mainType = 1;
3939

4040
// 0: [Base default] without RoArm-M2 and gimbal.
4141
// 1: [RoArm default] RoArm-M2 mounted on the UGV.

0 commit comments

Comments
 (0)