-
Notifications
You must be signed in to change notification settings - Fork 1
/
GlobalVariables.h
78 lines (65 loc) · 1.61 KB
/
GlobalVariables.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
* GlobalVariables.h
*
* Created on: 4 kwi 2017
* Author: radoslawkubera
*/
#ifndef _PIDServoGimbal_H_
#define _PIDServoGimbal_H_
//add your includes for the project PIDServoGimbal here
#include "Arduino.h"
#include "libraries/PID/PID_v1.h"
#if defined USE_MAVLINK
#include "mavlink.h"
#endif
#include "libraries/FrServo/FrServo.h"
#include "libraries/MPU6050/MPU6050.h"
#include "EEPROM.h"
#include "GlobalDefines.h"
#include "libraries/AutoSerial/AutoSerial.h"
//end of add your includes here
//Serials
AutoSerial debugSerial;
#if defined USE_MAVLINK
AutoSerial mavlinkSerial;
#endif
//Servos
FrServo rollServo;
FrServo pitchServo;
//RC
float rc_pitch;
float rc_roll;
uint16_t rollPWMIn, pitchPWMIn;
uint16_t rollMavlinkIn, pitchMavlinkIn;
//Roll, Pitch
float pitch, roll;
//MPU6050
MPU6050 mpu;
//Timers
#if defined USE_MAVLINK
uint32_t mavlink_timer;
#endif
uint32_t pid_timer, config_timer, serial_timer;
//Config
int8_t rollOrientation;
int8_t pitchOrientation;
int8_t yawOrientation;
int8_t rollPIDDirection;
int8_t pitchPIDDirection;
uint16_t pwmFrequency;
#if defined USE_MAVLINK
uint8_t mavlinkRollRCChannel;
uint8_t mavlinkPitchRCChannel;
#endif
//Debug
uint8_t debug_mode = 0;
//PID
float pitchKp=0.10, pitchKd=0.0001, pitchKi=0.001;
float rollKp=0.10, rollKd=0.0001, rollKi=0.001;
float posRoll, posPitch;
float posRollPID, posPitchPID;
float setRollPoint, setPitchPoint;
PID pitchPID(&pitch, &posPitchPID, &setPitchPoint, pitchKp, pitchKi, pitchKd, DIRECT);
PID rollPID(&roll, &posRollPID, &setRollPoint, rollKp, rollKi, rollKd, DIRECT);
//Do not add code below this line
#endif /* _PIDServoGimbal_H_ */