Tutorial V: IMU Data Reading Demo
Modules Usage Tutorial
- How To Install Arduino IDE
- Tutorial I: Motor With Encoder Control Demo
- Tutorial II: Motor Without Encoder Control Demo
- Tutorial III: ST3215 Serial Bus Servo Control Demo
- Tutorial IV: PWM Servo Control Demo
- Tutorial V: IMU Data Reading Demo
- Tutorial VI: SD Card Reading Demo
- Tutorial VII: INA219 Voltage And Current Monitoring Demo
- Tutorial VIII: OLED Screen Control Demo
- Tutorial IX Lidar and Publishing Lidar Topics in ROS2
- UGV01 WIKI Main Page
- General Driver for Robots WIKI Main Page
IMU Data Reading
The General Driver for Robots has a 9-axis IMU on board, which can read the position data of the driver board itself. The IMU data reading demo is provided below.
Demo
Upload Demo
After downloading the zip package, open 9DOF_Demo.ino, connect the multifunctional driver board to the computer with a USB cable (here, the Type-C port of the USB of the multifunctional driver board is plugged in), click on "Tools" -> "Ports", and then click on the new COM (COM26 in my case). Click on the newly appeared COM port.
In Arduino IDE, click "Tools" → "Development Board" → "ESP32" → "ESP32 Dev Module". Upload the demo after selecting the board and the port. After uploading the demo, open the serial monitor of Arduino IDE to read the IMU data, and the data will change when you rotate the driver board.
Demo Analysis
#include"IMU.h" int IMU_Roll = 100; int IMU_Pitch = 100; int IMU_Yaw = 100; int IMU_Temp = 100; IMU_ST_ANGLES_DATA stAngles; IMU_ST_SENSOR_DATA stGyroRawData; IMU_ST_SENSOR_DATA stAccelRawData; IMU_ST_SENSOR_DATA stMagnRawData; void getIMU(){ imuDataGet( &stAngles, &stGyroRawData, &stAccelRawData, &stMagnRawData); IMU_Temp = QMI8658_readTemp(); IMU_Roll = stAngles.fRoll; IMU_Pitch = stAngles.fPitch; IMU_Yaw = stAngles.fYaw; } void DOF(){ Serial.print("R:"); Serial.println(IMU_Roll); Serial.print("P:"); Serial.println(IMU_Pitch); Serial.print("Y:"); Serial.println(IMU_Yaw); Serial.print("T:"); Serial.println(IMU_Temp); } void setup() { Serial.begin(115200); while(!Serial){} imuInit(); } void loop() { getIMU(); DOF(); delay(1000); }