mirror of
https://github.com/okalachev/flix.git
synced 2025-07-29 20:38:59 +00:00
Cleanups and updates
This commit is contained in:
parent
0a7ed1039f
commit
f2aae92f1e
@ -6,8 +6,6 @@
|
|||||||
#include "pid.h"
|
#include "pid.h"
|
||||||
#include "vector.h"
|
#include "vector.h"
|
||||||
|
|
||||||
extern PID rollRatePID, pitchRatePID, yawRatePID, rollPID, pitchPID;
|
|
||||||
extern LowPassFilter<Vector> ratesFilter;
|
|
||||||
extern const int MOTOR_REAR_LEFT, MOTOR_REAR_RIGHT, MOTOR_FRONT_RIGHT, MOTOR_FRONT_LEFT;
|
extern const int MOTOR_REAR_LEFT, MOTOR_REAR_RIGHT, MOTOR_FRONT_RIGHT, MOTOR_FRONT_LEFT;
|
||||||
extern float loopRate;
|
extern float loopRate;
|
||||||
|
|
||||||
|
@ -30,8 +30,8 @@
|
|||||||
#define YAW_P 3
|
#define YAW_P 3
|
||||||
#define PITCHRATE_MAX radians(360)
|
#define PITCHRATE_MAX radians(360)
|
||||||
#define ROLLRATE_MAX radians(360)
|
#define ROLLRATE_MAX radians(360)
|
||||||
#define YAWRATE_MAX radians(360)
|
#define YAWRATE_MAX radians(300)
|
||||||
#define MAX_TILT radians(30)
|
#define TILT_MAX radians(30)
|
||||||
|
|
||||||
#define RATES_D_LPF_ALPHA 0.2 // cutoff frequency ~ 40 Hz
|
#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;
|
yawMode = controls[RC_CHANNEL_YAW] == 0 ? YAW : YAW_RATE;
|
||||||
|
|
||||||
attitudeTarget = Quaternion::fromEulerZYX(Vector(
|
attitudeTarget = Quaternion::fromEulerZYX(Vector(
|
||||||
controls[RC_CHANNEL_ROLL] * MAX_TILT,
|
controls[RC_CHANNEL_ROLL] * TILT_MAX,
|
||||||
controls[RC_CHANNEL_PITCH] * MAX_TILT,
|
controls[RC_CHANNEL_PITCH] * TILT_MAX,
|
||||||
attitudeTarget.getYaw()));
|
attitudeTarget.getYaw()));
|
||||||
ratesTarget.z = -controls[RC_CHANNEL_YAW] * YAWRATE_MAX; // positive yaw stick means clockwise rotation in FLU
|
ratesTarget.z = -controls[RC_CHANNEL_YAW] * YAWRATE_MAX; // positive yaw stick means clockwise rotation in FLU
|
||||||
|
|
||||||
|
@ -8,14 +8,15 @@
|
|||||||
|
|
||||||
extern float controlsTime;
|
extern float controlsTime;
|
||||||
|
|
||||||
|
// RC loss failsafe
|
||||||
void failsafe() {
|
void failsafe() {
|
||||||
if (t - controlsTime > RC_LOSS_TIMEOUT) {
|
if (t - controlsTime > RC_LOSS_TIMEOUT) {
|
||||||
descend();
|
descend();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Smooth descend on RC lost
|
||||||
void descend() {
|
void descend() {
|
||||||
// Smooth descend on RC lost
|
|
||||||
mode = STAB;
|
mode = STAB;
|
||||||
controls[RC_CHANNEL_ROLL] = 0;
|
controls[RC_CHANNEL_ROLL] = 0;
|
||||||
controls[RC_CHANNEL_PITCH] = 0;
|
controls[RC_CHANNEL_PITCH] = 0;
|
||||||
|
@ -7,11 +7,12 @@
|
|||||||
#include <MPU9250.h>
|
#include <MPU9250.h>
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
MPU9250 IMU(SPI);
|
||||||
|
|
||||||
// NOTE: use 'ca' command to calibrate the accelerometer and put the values here
|
// NOTE: use 'ca' command to calibrate the accelerometer and put the values here
|
||||||
Vector accBias(0, 0, 0);
|
Vector accBias(0, 0, 0);
|
||||||
Vector accScale(1, 1, 1);
|
Vector accScale(1, 1, 1);
|
||||||
|
|
||||||
MPU9250 IMU(SPI);
|
|
||||||
Vector gyroBias;
|
Vector gyroBias;
|
||||||
|
|
||||||
void setupIMU() {
|
void setupIMU() {
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Repository: https://github.com/okalachev/flix
|
// Repository: https://github.com/okalachev/flix
|
||||||
|
|
||||||
// Motors output control using MOSFETs
|
// 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"
|
#include "util.h"
|
||||||
|
|
||||||
|
@ -36,14 +36,14 @@ void normalizeRC() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void calibrateRC() {
|
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··· ···");
|
Serial.println("··o ··o\n··· ···\n··· ···");
|
||||||
delay(4000);
|
delay(4000);
|
||||||
while (!readRC());
|
while (!readRC());
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 16; i++) {
|
||||||
channelMax[i] = channels[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· ···");
|
Serial.println("··· ···\n··· ·o·\n·o· ···");
|
||||||
delay(4000);
|
delay(4000);
|
||||||
while (!readRC());
|
while (!readRC());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user