APM inertial sensor

We will learn how to compile the example related to the inertial sensor used to fly drones, in Erle-Brain. This example will show the acceleration and rotation readed by the sensor. The default sensor used is the 9-axis MEMS MPU9250.

Cross-compiling method is recommended, it takes less time compiling the code

Enter to the AP_InertialSensor folder:

$ cd /path_to/ardupilot/libraries/AP_InertialSensor/examples/INS_generic

Compile the code and copy it into Erle-Brain:

#compile using 4 cores
$ make pxf -j4
#get into /tmp folder tp copy the example
$ cd /tmp/INS_generic.build
$ scp INS_generic.elf root@192.168.7.2:~/
# get into Erle-Brain
$ ssh root@192.168.7.2
#Run the example
$ cd ~
$ ./INS_generic.elf
# You need to select what to do, press t
AP_InertialSensor startup...
Init Gyro***

Accel Offsets X:0.00000000   Y:0.00000000    Z:0.00000000
Accel Scale X:1.000000   Y:1.000000      Z:1.000000
Gyro Offsets X:0.00945510    Y:0.00566300    Z:-0.01345085
Complete. Reading:

Menu:
    c) calibrate accelerometers
    d) display offsets and scaling
    l) level (capture offsets from level)
    t) test
    r) reboot
t
Accel X:0.74     Y:0.39      Z:-9.31     len:9.35    Gyro X:0.00     Y:0.00      Z:0.00
Accel X:0.72     Y:0.41      Z:-9.31     len:9.34    Gyro X:0.00     Y:-0.00     Z:-0.00
Accel X:0.73     Y:0.40      Z:-9.31     len:9.35    Gyro X:0.00     Y:0.00      Z:-0.00
Accel X:0.58     Y:0.88      Z:-9.53     len:9.59    Gyro X:-0.19    Y:-0.05     Z:0.00
Accel X:-0.47    Y:2.55      Z:-8.99     len:9.36    Gyro X:-3.10    Y:0.14      Z:-0.11
Accel X:-1.53    Y:4.14      Z:-8.65     len:9.71    Gyro X:-3.62    Y:0.44      Z:-0.17
Accel X:-0.99    Y:5.08      Z:-7.44     len:9.06    Gyro X:-1.60    Y:0.09      Z:-0.13
Accel X:-1.16    Y:5.22      Z:-6.43     len:8.36    Gyro X:-1.63    Y:0.02      Z:-0.05

If you wish to understand how the code works, check the INS_generic.cppfile.