-
Notifications
You must be signed in to change notification settings - Fork 0
/
mpu6050.h
executable file
·59 lines (45 loc) · 1.4 KB
/
mpu6050.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef MPU6050
#define MPU6050
#include <time.h>
#include <math.h>
#include "m_pd.h"
#include <pthread.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/i2c-dev.h>
#include <i2c/smbus.h>
#include <stdlib.h>
#define FILTER_GYRO_COEF 0.98f
#define RAD_T_DEG 57.29577951308 //Radians to degrees (180/PI)
void init_mpu6050(int acc_range, int gyro_range, float output_freq, float f_coeff);
void stop_thread();
void start_thread(pthread_attr_t thread_attr,
pthread_t x_threadid,
void (*callback)(void *),
void *x);
void get_offsets(void *x, void (*callback)(void *, float, float, float, float, float, float));
void set_offsets(float acc_x, float acc_y, float acc_z, float gyro_r, float gyro_p, float gyro_y);
int get_angle(int axis, float *result);
void get_accel(float *x, float *y, float *z);
float offset_acc_x;
float offset_acc_y;
float offset_acc_z;
float offset_gyro_r;
float offset_gyro_p;
float offset_gyro_y;
uint8_t acc_config;
uint8_t gyro_config;
float acc_sens;
float gyro_sens;
float filter_coeff;
float output_secs;
struct timespec start, end;
int running;
int f_dev;
float accel_angle[3];
float gyro_angle[3];
float angle[3]; //Store all angles (accel roll, accel pitch, accel yaw, gyro roll, gyro pitch, gyro yaw, comb roll, comb pitch comb yaw)
float ax, ay, az, gr, gp, gy, angle_acc_x, angle_acc_y, sgZ;
float dt;
#endif