We will learn how to compile the example related to the Altitud and Heading Reference, in Erle-Brain, 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_AHRS folder:
$ cd /path_to/ardupilot/libraries/AP_AHRS/examples/AHRS_Test
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/AHRS_Test.build
$ scp AHRS_Test.elf root@192.168.7.2:~/
# get into Erle-Brain
$ ssh root@192.168.7.2
#Run the example
$ cd ~
$ ./AHRS_Test.elf
# You should see...
Init Gyro***
HMC5843: Could not detect version
Enabling compass
r: 0.0 p:-0.0 y:-174.4 drift=( 0.0 0.0 0.0) hdg=-180.0 rate=0.9
r: 0.0 p:-0.0 y:-174.4 drift=( 0.0 0.0 0.0) hdg=-45.7 rate=109.9
r: 0.1 p: 0.1 y:-169.3 drift=( 0.0 0.0 0.0) hdg=-45.2 rate=100.0
r: 0.6 p: 0.9 y:-163.2 drift=( 0.0 0.0 0.0) hdg=-45.6 rate=100.0
r: 1.3 p: 1.7 y:-157.0 drift=( 0.0 0.0 0.0) hdg=-46.3 rate=100.0
r: 2.0 p: 2.3 y:-149.5 drift=( 0.0 0.0 0.0) hdg=-47.4 rate=100.0
r: 2.7 p: 2.7 y:-142.3 drift=( 0.0 0.0 0.0) hdg=-47.9 rate=100.0
r: 3.3 p: 2.9 y:-134.2 drift=( 0.0 0.0 0.0) hdg=-47.9 rate=100.0
r: 3.8 p: 2.9 y:-126.9 drift=( 0.0 0.0 0.0) hdg=-48.3 rate=100.0
r: 4.2 p: 2.9 y:-119.1 drift=( 0.0 0.0 0.0) hdg=-48.2 rate=100.0
r: 4.6 p: 2.8 y:-112.5 drift=( 0.0 0.0 0.0) hdg=-48.7 rate=100.0
r: 4.6 p: 2.8 y:-105.7 drift=( 0.0 0.0 0.0) hdg=-48.4 rate=100.0
If you wish to understand how the code works, check the AHRS_test.cpp file.