Skip to content

Commit

Permalink
ANGLE MODE WORKINGgit add . Fly test succeed!
Browse files Browse the repository at this point in the history
  • Loading branch information
liourej committed Jul 15, 2017
1 parent d5cf5b8 commit 5da3829
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
6 changes: 5 additions & 1 deletion CodeDroneDIY.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ void InitTimer1() {

void PrintSettings(StateMachine _stateMachine) {
Serial.println(F("/********* settings *********/"));
if ( MAX_POWER == 1860)
Serial.println(F("FLYING MODE POWER!!!\t"));
else if ( MAX_POWER <= 1300)
Serial.println(F("DEBUG MODE POWER!!!\t"));
Serial.print(F("MAX_POWER:\t")); Serial.println(MAX_POWER);
if ( _stateMachine.state == angle) {
Serial.println(F("FLYING_MODE_ANGLE"));
Expand All @@ -78,7 +82,7 @@ void PrintSettings(StateMachine _stateMachine) {
pitchSpeedPID.PrintGains();
yawSpeedPID.PrintGains();
Serial.println(F("/********* Complementary filter *********/"));
Serial.print("Coefficient:\t");Serial.print(Position.HighPassFilterCoeff); Serial.print("\tTime constant:\t");Serial.println(Position.GetFilterTimeConstant(0.00249));
Serial.print("Coefficient:\t"); Serial.print(Position.HighPassFilterCoeff); Serial.print("\tTime constant:\t"); Serial.println(Position.GetFilterTimeConstant(0.00249));
} else if ( _stateMachine.state == accro) {
Serial.println(F("FLYING_MODE_ACCRO"));
Serial.println(F("/********* PID settings *********/"));
Expand Down
2 changes: 0 additions & 2 deletions CodeDroneDIY.ino
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ void loop() {
pitchSpeedPID.SetGains(angleSpeedPIDParams);
yawSpeedPID.SetGains(yawSpeedPIDParams);
stateMachine.statePrev = stateMachine.state;
Serial.println("ANGLE MODE");
PrintSettings(stateMachine);

} else if ( (stateMachine.state != disarmed) && ( stateMachine.state == accro ) ) {
Expand All @@ -227,7 +226,6 @@ void loop() {
yawSpeedPID.SetGains(yawSpeedPIDParams);

stateMachine.statePrev = stateMachine.state;
Serial.println("ACCRO MODE");
PrintSettings(stateMachine);
} else
stateMachine.state = starting;
Expand Down
2 changes: 1 addition & 1 deletion GetPosition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void GetPosition::GetCurrPos(MPU6050 _accelgyro, float _pos[], float _speed[], f

Normalize(accRaw);

/*static int counter = 0;
/* static int counter = 0;
static float pitchGyro = 0.0;
float pitchAcc = 0.0;
pitchGyro = pitchGyro + (gyroRaw[1]) * _loop_time;
Expand Down
1 change: 0 additions & 1 deletion PID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ void PID::SetGains(float _params[4]) {
Kp = _params[1];
Kd = _params[2];
Ki = _params[3];
PrintGains();
};

void PID::Reset() {
Expand Down
2 changes: 1 addition & 1 deletion Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#define GAIN 0.010

// Angle mode
float anglePosPIDParams[4] = { 0.010, 260, 0.5, 0.3};// G, Kp, Kd, Ki
float anglePosPIDParams[4] = { 0.010, 268, 0.5, 0.0};// G, Kp, Kd, Ki
float angleSpeedPIDParams[4] = { 0.010, 192, 0.0, 0.0};

// Accro mode
Expand Down

0 comments on commit 5da3829

Please sign in to comment.