diff --git a/flix/cli.ino b/flix/cli.ino index 9a5c179..ad2cae0 100644 --- a/flix/cli.ino +++ b/flix/cli.ino @@ -6,8 +6,6 @@ #include "pid.h" #include "vector.h" -extern PID rollRatePID, pitchRatePID, yawRatePID, rollPID, pitchPID; -extern LowPassFilter ratesFilter; extern const int MOTOR_REAR_LEFT, MOTOR_REAR_RIGHT, MOTOR_FRONT_RIGHT, MOTOR_FRONT_LEFT; extern float loopRate; diff --git a/flix/control.ino b/flix/control.ino index dd92d7d..e81b686 100644 --- a/flix/control.ino +++ b/flix/control.ino @@ -30,8 +30,8 @@ #define YAW_P 3 #define PITCHRATE_MAX radians(360) #define ROLLRATE_MAX radians(360) -#define YAWRATE_MAX radians(360) -#define MAX_TILT radians(30) +#define YAWRATE_MAX radians(300) +#define TILT_MAX radians(30) #define RATES_D_LPF_ALPHA 0.2 // cutoff frequency ~ 40 Hz @@ -92,8 +92,8 @@ void interpretRC() { yawMode = controls[RC_CHANNEL_YAW] == 0 ? YAW : YAW_RATE; attitudeTarget = Quaternion::fromEulerZYX(Vector( - controls[RC_CHANNEL_ROLL] * MAX_TILT, - controls[RC_CHANNEL_PITCH] * MAX_TILT, + controls[RC_CHANNEL_ROLL] * TILT_MAX, + controls[RC_CHANNEL_PITCH] * TILT_MAX, attitudeTarget.getYaw())); ratesTarget.z = -controls[RC_CHANNEL_YAW] * YAWRATE_MAX; // positive yaw stick means clockwise rotation in FLU diff --git a/flix/failsafe.ino b/flix/failsafe.ino index eab6ee5..4ff0066 100644 --- a/flix/failsafe.ino +++ b/flix/failsafe.ino @@ -8,14 +8,15 @@ extern float controlsTime; +// RC loss failsafe void failsafe() { if (t - controlsTime > RC_LOSS_TIMEOUT) { descend(); } } +// Smooth descend on RC lost void descend() { - // Smooth descend on RC lost mode = STAB; controls[RC_CHANNEL_ROLL] = 0; controls[RC_CHANNEL_PITCH] = 0; diff --git a/flix/imu.ino b/flix/imu.ino index f9c27d1..bf8a54f 100644 --- a/flix/imu.ino +++ b/flix/imu.ino @@ -7,11 +7,12 @@ #include #include "util.h" +MPU9250 IMU(SPI); + // NOTE: use 'ca' command to calibrate the accelerometer and put the values here Vector accBias(0, 0, 0); Vector accScale(1, 1, 1); -MPU9250 IMU(SPI); Vector gyroBias; void setupIMU() { diff --git a/flix/motors.ino b/flix/motors.ino index 998af2c..6200b8c 100644 --- a/flix/motors.ino +++ b/flix/motors.ino @@ -2,8 +2,6 @@ // Repository: https://github.com/okalachev/flix // Motors output control using MOSFETs -// In case of using ESC, use this version of the code: https://gist.github.com/okalachev/8871d3a94b6b6c0a298f41a4edd34c61. -// Motor: 8520 3.7V #include "util.h" diff --git a/flix/rc.ino b/flix/rc.ino index fe7b4d4..2f2c1ea 100644 --- a/flix/rc.ino +++ b/flix/rc.ino @@ -36,14 +36,14 @@ void normalizeRC() { } void calibrateRC() { - Serial.println("Calibrate RC: move all sticks to maximum positions in 4 seconds"); + Serial.println("Calibrate RC: move all sticks to maximum positions [4 sec]"); Serial.println("··o ··o\n··· ···\n··· ···"); delay(4000); while (!readRC()); for (int i = 0; i < 16; i++) { channelMax[i] = channels[i]; } - Serial.println("Calibrate RC: move all sticks to neutral positions in 4 seconds"); + Serial.println("Calibrate RC: move all sticks to neutral positions [4 sec]"); Serial.println("··· ···\n··· ·o·\n·o· ···"); delay(4000); while (!readRC());