Initial escape library
Not working yet
This commit is contained in:
41
examples/AccelGyroMag/AccelGyroMag.cpp
Normal file
41
examples/AccelGyroMag/AccelGyroMag.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
Provided to you by Emlid Ltd (c) 2014.
|
||||
twitter.com/emlidtech || www.emlid.com || info@emlid.com
|
||||
|
||||
Example: Read accelerometer, gyroscope and magnetometer values from
|
||||
MPU9250 inertial measurement unit over SPI on Raspberry Pi + Navio.
|
||||
|
||||
Navio's onboard MPU9250 is connected to the SPI bus on Raspberry Pi
|
||||
and can be read through /dev/spidev0.1
|
||||
|
||||
To run this example navigate to the directory containing it and run following commands:
|
||||
make
|
||||
./AccelGyroMag
|
||||
*/
|
||||
|
||||
#include "darkwater/MPU9250.h"
|
||||
#include "darkwater/Util.h"
|
||||
#include <stdlib.h>
|
||||
//=============================================================================
|
||||
|
||||
int main()
|
||||
{
|
||||
if (check_apm()) {
|
||||
return 1;
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
MPU9250 imu;
|
||||
imu.initialize();
|
||||
|
||||
float ax, ay, az, gx, gy, gz, mx, my, mz;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
while(1) {
|
||||
imu.getMotion9(&ax, &ay, &az, &gx, &gy, &gz, &mx, &my, &mz);
|
||||
printf("Acc: %+7.3f %+7.3f %+7.3f ", ax, ay, az);
|
||||
printf("Gyr: %+8.3f %+8.3f %+8.3f ", gx, gy, gz);
|
||||
printf("Mag: %+7.3f %+7.3f %+7.3f\n", mx, my, mz);
|
||||
|
||||
usleep(500000);
|
||||
}}
|
||||
9
examples/AccelGyroMag/Makefile
Normal file
9
examples/AccelGyroMag/Makefile
Normal file
@@ -0,0 +1,9 @@
|
||||
CC = g++
|
||||
DW = ../../darkwater
|
||||
INCLUDES = -I ../..
|
||||
|
||||
all:
|
||||
$(CC) $(INCLUDES) AccelGyroMag.cpp $(DW)/MPU9250.cpp $(DW)/Util.cpp -o AccelGyroMag
|
||||
|
||||
clean:
|
||||
rm AccelGyroMag
|
||||
Reference in New Issue
Block a user