Skip to content

Commit 2905aba

Browse files
committed
update Imu
1 parent 69d8d8c commit 2905aba

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

src/Arduino_Robot_Firmware.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ int Arduino_Robot_Firmware::begin(){
6767
connectExternalI2C();
6868
ext_wire->begin(ARDUINO_ROBOT_ADDRESS);
6969

70-
//beginImu();
70+
7171

7272
if (beginAPDS()!=0){
7373
errorLed(ERROR_APDS);
@@ -85,6 +85,9 @@ int Arduino_Robot_Firmware::begin(){
8585
//errorLed(ERROR_TOUCH);
8686
}
8787

88+
if (beginImu()!=){
89+
errorLed(ERROR_IMU);
90+
}
8891

8992
return 0;
9093
}
@@ -386,6 +389,12 @@ int Arduino_Robot_Firmware::beginImu(){
386389
imu->Set_G_FS(2000);
387390
imu->Enable_X();
388391
imu->Enable_G();
392+
return 0;
393+
}
394+
395+
void Arduino_Robot_Firmware::updateImu(){
396+
imu->Get_X_Axes(accelerometer);
397+
imu->Get_G_Axes(gyroscope);
389398
}
390399

391400

src/Arduino_Robot_Firmware.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ class Arduino_Robot_Firmware{
3434
AT42QT2120::Status touch_status;
3535

3636
LSM6DSOSensor * imu;
37+
int32_t accelerometer[3];
38+
int32_t gyroscope[3];
3739

3840

3941
public:
@@ -130,8 +132,7 @@ class Arduino_Robot_Firmware{
130132

131133
// Imu
132134
int beginImu();
133-
134-
135+
void updateImu();
135136

136137
void errorLed(const int error_code);
137138

src/robot_definitions.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,11 @@ const float MOTOR_RATIO = MOTOR_CPR*MOTOR_GEAR_RATIO;
1414
#define MOTOR_KD_RIGHT 0.4
1515
#define MOTOR_CONTROL_PERIOD 0.01
1616

17+
18+
19+
#define FROM_MG_TO_G 0.001f
20+
#define FROM_G_TO_MG 1000.0f
21+
#define FROM_MDPS_TO_DPS 0.001f
22+
#define FROM_DPS_TO_MDPS 1000.0f
23+
1724
#endif

0 commit comments

Comments
 (0)