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:04:32 2021 +0000
Revision:
64:e9661430f0e3
Parent:
61:c05353850017
Child:
66:e5afad70fdd8
global.hpp;

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"
cocorlow 56:888379912f81 15 #include "HAPS_EKF.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 float rpy_g[3];
cocorlow 56:888379912f81 40 };
cocorlow 56:888379912f81 41
cocorlow 56:888379912f81 42 // var
cocorlow 56:888379912f81 43
cocorlow 56:888379912f81 44 // communication
cocorlow 56:888379912f81 45 extern I2C i2c; // sda, scl
NaotoMorita 64:e9661430f0e3 46 extern UsaPack pc; // log - tail
cocorlow 56:888379912f81 47
cocorlow 56:888379912f81 48 // sensor
cocorlow 56:888379912f81 49 extern MPU6050 accelgyro;
cocorlow 56:888379912f81 50 extern MAG3110 mag_sensor;
NaotoMorita 61:c05353850017 51 extern CalibrateMagneto magCalibrator;
cocorlow 56:888379912f81 52
cocorlow 56:888379912f81 53 // io
cocorlow 56:888379912f81 54 extern DigitalIn userButton;
NaotoMorita 64:e9661430f0e3 55 extern CalibrateMagneto joyCalibrator;
cocorlow 56:888379912f81 56
cocorlow 56:888379912f81 57 // control
NaotoMorita 64:e9661430f0e3 58 extern FastPWM elevServo;
NaotoMorita 64:e9661430f0e3 59 extern FastPWM rudServo;
cocorlow 56:888379912f81 60 extern PID pitchPID; // rad
cocorlow 56:888379912f81 61 extern PID pitchratePID;// rad/s
cocorlow 56:888379912f81 62 extern HAPS_EKF ekf; // EKF class
cocorlow 56:888379912f81 63
cocorlow 56:888379912f81 64 extern int loop_count;
cocorlow 56:888379912f81 65 extern float att_dt;
cocorlow 56:888379912f81 66
cocorlow 56:888379912f81 67 extern int16_t ax, ay, az;
cocorlow 56:888379912f81 68 extern int16_t gx, gy, gz;
cocorlow 56:888379912f81 69 extern MotionSensorDataUnits mdata;
cocorlow 56:888379912f81 70 extern float magval[3];
cocorlow 56:888379912f81 71
cocorlow 56:888379912f81 72 // position
cocorlow 56:888379912f81 73 extern Vector3 rpy; // x:roll y:pitch z:yaw
cocorlow 56:888379912f81 74 extern Vector3 acc;
cocorlow 56:888379912f81 75 extern Vector3 accref;
cocorlow 56:888379912f81 76 extern Vector3 mag;
cocorlow 56:888379912f81 77 extern Vector3 magref;
cocorlow 56:888379912f81 78 extern Vector3 gyro;
cocorlow 56:888379912f81 79
NaotoMorita 64:e9661430f0e3 80 extern float scaledServoOut[2];
NaotoMorita 64:e9661430f0e3 81 extern float servoOut[2];
cocorlow 56:888379912f81 82
cocorlow 56:888379912f81 83
NaotoMorita 61:c05353850017 84
cocorlow 56:888379912f81 85 extern int calibrationFlag;
cocorlow 56:888379912f81 86 extern int agoffset[6];
NaotoMorita 61:c05353850017 87 extern float magbiasMin[3];
NaotoMorita 61:c05353850017 88 extern float magbiasMax[3];
cocorlow 56:888379912f81 89
cocorlow 56:888379912f81 90 extern Vector3 rpy_align;
cocorlow 56:888379912f81 91
cocorlow 56:888379912f81 92
cocorlow 56:888379912f81 93 //// UsaPack
NaotoMorita 64:e9661430f0e3 94 extern valuePack posValues;
cocorlow 56:888379912f81 95
cocorlow 56:888379912f81 96 // function
cocorlow 56:888379912f81 97
cocorlow 56:888379912f81 98 // main.cpp
cocorlow 56:888379912f81 99
cocorlow 56:888379912f81 100 // setup.cpp
cocorlow 56:888379912f81 101 extern void setup();
cocorlow 56:888379912f81 102 extern void calibrate();
cocorlow 56:888379912f81 103
cocorlow 56:888379912f81 104 // run.cpp
cocorlow 56:888379912f81 105 extern void run();
cocorlow 56:888379912f81 106
cocorlow 56:888379912f81 107 // imu.cpp
cocorlow 56:888379912f81 108 extern void getIMUval();
cocorlow 56:888379912f81 109
cocorlow 56:888379912f81 110 // servo.cpp
cocorlow 56:888379912f81 111 extern void calcServoOut();
cocorlow 56:888379912f81 112
cocorlow 56:888379912f81 113 // sd_eeprom.cpp
cocorlow 56:888379912f81 114 extern void writeSdcard();
cocorlow 56:888379912f81 115
cocorlow 56:888379912f81 116 // global.cpp
cocorlow 56:888379912f81 117 extern float mapfloat(float x, float in_min, float in_max, float out_min, float out_max);
cocorlow 56:888379912f81 118
cocorlow 56:888379912f81 119 #endif