Acceleration, gyro, compass
- Hits: 17747
Note: Use the WIKI for latest informationen!
Acceleration sensor (to detect orientation of the robot)
An acceleration sensor measures earth gravity force (m*s^2) in all 3 robot axes (x/y/z) allowing you to calculate the orientation towards earth center of the robot (Roll, Pitch). However, it cannot detect movement around Yaw - this requires a gyro.
Gyro (to detect rotation of the robot)
A gyro measure rotation speed (degree/second) in all 3 robot axes (Rol, Pitch, Yaw). This allows us to correct the robot if it is driving 'off-course' due to wet conditions or slope.
Compass (to detect the robot's course)
If a robot drives on a wet lawn, you'll notice quickly that it will not drive straight forward, but instead tends to drive into the direction of the slope. A compass can solve this problem and the robot will drive again straight forward.
However, a compass has a problem: if tilting the robot, the compass measurements (x,y,z) relate to the tilted robot. So, you need to correct them using knowing the tilt angles. This requires the use of the accerlation sensor (x,y).
To eliminate the issues of all sensor, they are merged to compute the course (degree) and pitch/roll angles (IMU - Intertial Measurement Unit). The IMU is key component of an intertial navigation system.
A Kalman filter can be used to fusion all sensor values.
Nine Axis IMU Module
- Acceleration sensor: ADXL345B
- Compass sensor: HMC5883L
- Gyro: L3G4200D
- Pressure sensor: BMP085 (not used here)
The IMU module (GY-80) is connected to an Arduino Nano which reads and evaluates compass, gyro and acceleration data. For exact wiring, see schematics.
This photo shows how the IMU module is placed in driving position (the black arrow shows the driving position). The shown tube was a prototype. Actually, you can now place the IMU module directly in the robot.
Step 1: Calibration - Acceleration sensor
This one-time calibration ensures that all 3 axes measurements are weighted equally. This calibration can be performed even outside of the robot.
1. Connect the Arduino Nano to your PC. On the PC, open the serial console (19200) in the Arduino environment. After the automatic gyro calibration menu appears (this can be shown at any time by pressing the "m" + ENTER keys).
2. Start the calibration by pressing "1" + ENTER keys.
2.1. After calibration, each of the 6 sides of the module has to look up-side and down-side (rotated 180 °). The module has 6 sides, so it must be rotated 6 times, so that each side once is on the table (you can hold the module with your hand without moving it). Press ENTER after each calibration step. The aim of the calibration to determine the acceleration due to gravity (more precisely, the minimum / maximum value) for each axis . The module must not be artificially accelerated. The order of the sides does not matter.
Finally, the calibration values for acceleration sensor are printed out on serial console.
Step 2: Calibration - compass
This one-time calibration ensures that cable, metal, etc. which is located in the robot near the IMU module has no effect on the compass data.
A measured value (x, y, z) of a 3D compass points (as seen by his origin 0,0,0) always in one direction: to the north pole. If you rotate the 3D compass around all of its axes, all measured values lie on a sphere:
If you add a magnetic material (e.g. metal) near the compass, the measured values from the origin (0,0,0) of the sensor suddenly point in one direction only - Why?
There are two types of disturbances of the magnetic field which change / move the values:
Hard ircon (e.g. magnets): the sphere moves
Soft ircon (e.g. metal): the sphere deforms (becomes an Ellipsoid)
(left: the uncalibrated readings do not lie on a sphere but on an ellipsoid and have shifted from the origin of the sensor
center: shift-corrected values
right: the calibrated values are now undeformed again on a sphere, centered around the origin of the sensor)
The aim of the calibration is that the measurements are centered again on a sphere around the origin of the sensor.
First ensure that the IMU module is mounted on the final position and that entire robotic electronic equipment and metal objects are 30cm or more away from it (ie the sensor is not distracted by metallic objects in its environment).
1. Download ArduMag calibration app for Android.
2. If not done yet, pair your Android device with the Bluetooth module: On the Android device main screen, choose symbol "Settings" (via Android menu). Now choose "Wirless and Networks->Bluetooth Settings" and "Find device". Finally, choose "pair with this device" and enter your pin (very often "1234"). The Bluetooth module should now appear as "paired".
3. In the ArduMag app, press the Android menu key and then "Bluetooth" to connect with your Bluetooth module (and your robot). The robot should confirm the connection with a beep. The number of measurements should increase.
Turn around the robot slowly for all axes and all 6 sides for at least 360 degrees:
The order of the axis of rotation and the direction does not matter. For example, rotate each side 180 degree clockwise and then again 180 degree counterclockwise (result is a 360 degree rotation). The measurements may not fit a sphere.
4. Finally, press 'Calibrate' to finish the calibration. The robot will confirm the calibration with two beeps. The measurements should fit a sphere now.
Testing of compass and tilt angles (via serial console)
The Arduino outputs:
yaw: Course/Yaw (see above figure)
pitch: Pitch angle (see above figure)
roll: Roll angle (see above figure)
frequency: Number of measurements per second (100)
latency: Number of latency overflows (0)
access: Number of external access counts (from Arduino Mega)
Testing (by using LED)
Align the compass facing north, south, east, west - the LED should go ON. Between them it should go OFF. North, south and east, west about should be opposite.
Testing (via Android pfodApp)
You can plot the results of the IMU module (yaw, pitch, roll) using pfodApp: