solaESKF_EIGEN

Dependencies:   mbed LPS25HB_I2C LSM9DS1 PIDcontroller LoopTicker GPSUBX_UART_Eigen SBUS_without_mainfile MedianFilter Eigen UsaPack solaESKF_Eigen Vector3 CalibrateMagneto FastPWM

Committer:
NaotoMorita
Date:
Tue Jun 22 02:45:43 2021 +0000
Revision:
67:41fcdfb7cc5a
Parent:
66:e5afad70fdd8
Child:
68:b9f6938fab9d
compiled

Who changed what in which revision?

UserRevisionLine numberNew contents of line
cocorlow 56:888379912f81 1 #ifndef __GLOBAL_HPP__
cocorlow 56:888379912f81 2 #define __GLOBAL_HPP__
cocorlow 56:888379912f81 3
cocorlow 56:888379912f81 4 #include "mbed.h"
cocorlow 56:888379912f81 5 #include "PIDcontroller.h"
cocorlow 56:888379912f81 6 #include "LoopTicker.hpp"
cocorlow 56:888379912f81 7 #include "MPU6050.h"
cocorlow 56:888379912f81 8 #include "MAG3110.h"
NaotoMorita 61:c05353850017 9 #include "CalibrateMagneto.h"
cocorlow 56:888379912f81 10 #include "I2Cdev.h"
cocorlow 56:888379912f81 11 #include "FastPWM.h"
cocorlow 56:888379912f81 12 #include <cmath>
cocorlow 56:888379912f81 13 #include "UsaPack.hpp"
cocorlow 56:888379912f81 14 #include "Vector3.hpp"
NaotoMorita 67:41fcdfb7cc5a 15 #include "errStateEKF.hpp"
cocorlow 56:888379912f81 16
cocorlow 56:888379912f81 17 #define MPU6050_PWR_MGMT_1 0x6B
cocorlow 56:888379912f81 18 #define MPU_ADDRESS 0x68
cocorlow 56:888379912f81 19 #define M_PI 3.141592f
cocorlow 56:888379912f81 20 #define ACCEL_FSR MPU6050_ACCEL_FS_8
cocorlow 56:888379912f81 21 #define ACCEL_SSF 4096.0f
cocorlow 56:888379912f81 22 #define GYRO_FSR MPU6050_GYRO_FS_250
cocorlow 56:888379912f81 23 #define GYRO_SSF 131.0f
cocorlow 56:888379912f81 24 #define MPU6050_LPF MPU6050_DLPF_BW_256
cocorlow 56:888379912f81 25 #define PID_dt 0.015f
cocorlow 56:888379912f81 26 #define servoPwmMax 1800.0f
cocorlow 56:888379912f81 27 #define servoPwmMin 1200.0f
cocorlow 56:888379912f81 28 #define motorPwmMax 2000.0f
cocorlow 56:888379912f81 29 #define motorPwmMin 1100.0f
cocorlow 56:888379912f81 30
cocorlow 56:888379912f81 31 struct valuePack
cocorlow 56:888379912f81 32 {
cocorlow 56:888379912f81 33 float dt;
cocorlow 56:888379912f81 34 int count;
cocorlow 56:888379912f81 35 float acc[3];
cocorlow 56:888379912f81 36 float gyro[3];
cocorlow 56:888379912f81 37 float mag[3];
cocorlow 56:888379912f81 38 float rpy[3];
cocorlow 56:888379912f81 39 };
cocorlow 56:888379912f81 40
cocorlow 56:888379912f81 41 // var
cocorlow 56:888379912f81 42
cocorlow 56:888379912f81 43 // communication
cocorlow 56:888379912f81 44 extern I2C i2c; // sda, scl
NaotoMorita 64:e9661430f0e3 45 extern UsaPack pc; // log - tail
cocorlow 56:888379912f81 46
cocorlow 56:888379912f81 47 // sensor
cocorlow 56:888379912f81 48 extern MPU6050 accelgyro;
cocorlow 56:888379912f81 49 extern MAG3110 mag_sensor;
NaotoMorita 61:c05353850017 50 extern CalibrateMagneto magCalibrator;
cocorlow 56:888379912f81 51
cocorlow 56:888379912f81 52 // io
cocorlow 56:888379912f81 53 extern DigitalIn userButton;
NaotoMorita 64:e9661430f0e3 54 extern CalibrateMagneto joyCalibrator;
cocorlow 56:888379912f81 55
cocorlow 56:888379912f81 56 // control
NaotoMorita 64:e9661430f0e3 57 extern FastPWM elevServo;
NaotoMorita 64:e9661430f0e3 58 extern FastPWM rudServo;
cocorlow 56:888379912f81 59 extern PID pitchPID; // rad
cocorlow 56:888379912f81 60 extern PID pitchratePID;// rad/s
NaotoMorita 67:41fcdfb7cc5a 61 extern errStateEKF ekf; // EKF class
cocorlow 56:888379912f81 62
cocorlow 56:888379912f81 63 extern int loop_count;
cocorlow 56:888379912f81 64 extern float att_dt;
cocorlow 56:888379912f81 65
cocorlow 56:888379912f81 66 extern int16_t ax, ay, az;
cocorlow 56:888379912f81 67 extern int16_t gx, gy, gz;
cocorlow 56:888379912f81 68 extern MotionSensorDataUnits mdata;
cocorlow 56:888379912f81 69 extern float magval[3];
cocorlow 56:888379912f81 70
cocorlow 56:888379912f81 71 // position
cocorlow 56:888379912f81 72 extern Vector3 rpy; // x:roll y:pitch z:yaw
cocorlow 56:888379912f81 73 extern Vector3 acc;
cocorlow 56:888379912f81 74 extern Vector3 accref;
cocorlow 56:888379912f81 75 extern Vector3 mag;
cocorlow 56:888379912f81 76 extern Vector3 magref;
cocorlow 56:888379912f81 77 extern Vector3 gyro;
cocorlow 56:888379912f81 78
NaotoMorita 64:e9661430f0e3 79 extern float scaledServoOut[2];
NaotoMorita 64:e9661430f0e3 80 extern float servoOut[2];
cocorlow 56:888379912f81 81
cocorlow 56:888379912f81 82
NaotoMorita 61:c05353850017 83
cocorlow 56:888379912f81 84 extern int calibrationFlag;
cocorlow 56:888379912f81 85 extern int agoffset[6];
NaotoMorita 61:c05353850017 86 extern float magbiasMin[3];
NaotoMorita 61:c05353850017 87 extern float magbiasMax[3];
cocorlow 56:888379912f81 88
cocorlow 56:888379912f81 89 extern Vector3 rpy_align;
cocorlow 56:888379912f81 90
cocorlow 56:888379912f81 91
cocorlow 56:888379912f81 92 //// UsaPack
NaotoMorita 64:e9661430f0e3 93 extern valuePack posValues;
cocorlow 56:888379912f81 94
cocorlow 56:888379912f81 95 // function
cocorlow 56:888379912f81 96
cocorlow 56:888379912f81 97 // main.cpp
cocorlow 56:888379912f81 98
cocorlow 56:888379912f81 99 // setup.cpp
cocorlow 56:888379912f81 100 extern void setup();
cocorlow 56:888379912f81 101 extern void calibrate();
cocorlow 56:888379912f81 102
cocorlow 56:888379912f81 103 // run.cpp
cocorlow 56:888379912f81 104 extern void run();
cocorlow 56:888379912f81 105
cocorlow 56:888379912f81 106 // imu.cpp
cocorlow 56:888379912f81 107 extern void getIMUval();
cocorlow 56:888379912f81 108
cocorlow 56:888379912f81 109 // servo.cpp
cocorlow 56:888379912f81 110 extern void calcServoOut();
cocorlow 56:888379912f81 111
cocorlow 56:888379912f81 112 // sd_eeprom.cpp
cocorlow 56:888379912f81 113 extern void writeSdcard();
cocorlow 56:888379912f81 114
cocorlow 56:888379912f81 115 // global.cpp
cocorlow 56:888379912f81 116 extern float mapfloat(float x, float in_min, float in_max, float out_min, float out_max);
cocorlow 56:888379912f81 117
NaotoMorita 67:41fcdfb7cc5a 118
cocorlow 56:888379912f81 119 #endif