mirror of
https://github.com/okalachev/flix.git
synced 2025-07-29 04:19:00 +00:00
Use 'loop rate' term instead of misleading 'loop frequency'
This commit is contained in:
parent
7fa3baa76a
commit
ea141f851f
@ -23,7 +23,7 @@ Do the following:
|
|||||||
* **Check the RC data** if you use it. Use `rc` command, `Control` should show correct values between -1 and 1, and between 0 and 1 for the throttle.
|
* **Check the RC data** if you use it. Use `rc` command, `Control` should show correct values between -1 and 1, and between 0 and 1 for the throttle.
|
||||||
* **Configure QGroundControl correctly before connecting to the drone** if you use it to control the drone. Go to the settings and enable *Virtual Joystick*. *Auto-Center Throttle* setting **should be disabled**.
|
* **Configure QGroundControl correctly before connecting to the drone** if you use it to control the drone. Go to the settings and enable *Virtual Joystick*. *Auto-Center Throttle* setting **should be disabled**.
|
||||||
* **Make sure you're not moving the drone several seconds after the power on**. The drone calibrates its gyroscope on the start so it should stay still for a while.
|
* **Make sure you're not moving the drone several seconds after the power on**. The drone calibrates its gyroscope on the start so it should stay still for a while.
|
||||||
* **Check the IMU frequency**. Perform `imu` command. The `frequency` field should be about 1000 (Hz).
|
* **Check the IMU sample rate**. Perform `imu` command. The `rate` field should be about 1000 (Hz).
|
||||||
* **Check the IMU data**. Perform `imu` command, check raw accelerometer and gyro output. The output should change as you move the drone.
|
* **Check the IMU data**. Perform `imu` command, check raw accelerometer and gyro output. The output should change as you move the drone.
|
||||||
* **Calibrate the accelerometer.** if is wasn't done before. Perform `ca` command and put the results to `imu.ino` file.
|
* **Calibrate the accelerometer.** if is wasn't done before. Perform `ca` command and put the results to `imu.ino` file.
|
||||||
* **Check the attitude estimation**. Connect to the drone using QGroundControl. Rotate the drone in different orientations and check if the attitude estimation shown in QGroundControl is correct.
|
* **Check the attitude estimation**. Connect to the drone using QGroundControl. Rotate the drone in different orientations and check if the attitude estimation shown in QGroundControl is correct.
|
||||||
|
@ -53,7 +53,7 @@ const struct Param {
|
|||||||
{"lpr", &ratesFilter.alpha, nullptr},
|
{"lpr", &ratesFilter.alpha, nullptr},
|
||||||
{"lpd", &rollRatePID.lpf.alpha, &pitchRatePID.lpf.alpha},
|
{"lpd", &rollRatePID.lpf.alpha, &pitchRatePID.lpf.alpha},
|
||||||
|
|
||||||
{"ss", &loopFreq, nullptr},
|
{"ss", &loopRate, nullptr},
|
||||||
{"dt", &dt, nullptr},
|
{"dt", &dt, nullptr},
|
||||||
{"t", &t, nullptr},
|
{"t", &t, nullptr},
|
||||||
};
|
};
|
||||||
@ -73,7 +73,7 @@ void doCommand(String& command, String& value) {
|
|||||||
Serial.printf("gyro: %f %f %f\n", rates.x, rates.y, rates.z);
|
Serial.printf("gyro: %f %f %f\n", rates.x, rates.y, rates.z);
|
||||||
Serial.printf("acc: %f %f %f\n", acc.x, acc.y, acc.z);
|
Serial.printf("acc: %f %f %f\n", acc.x, acc.y, acc.z);
|
||||||
printIMUCal();
|
printIMUCal();
|
||||||
Serial.printf("frequency: %f\n", loopFreq);
|
Serial.printf("rate: %f\n", loopRate);
|
||||||
} else if (command == "rc") {
|
} else if (command == "rc") {
|
||||||
Serial.printf("Raw: throttle %d yaw %d pitch %d roll %d armed %d mode %d\n",
|
Serial.printf("Raw: throttle %d yaw %d pitch %d roll %d armed %d mode %d\n",
|
||||||
channels[RC_CHANNEL_THROTTLE], channels[RC_CHANNEL_YAW], channels[RC_CHANNEL_PITCH],
|
channels[RC_CHANNEL_THROTTLE], channels[RC_CHANNEL_YAW], channels[RC_CHANNEL_PITCH],
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
float t = NAN; // current step time, s
|
float t = NAN; // current step time, s
|
||||||
float dt; // time delta from previous step, s
|
float dt; // time delta from previous step, s
|
||||||
float loopFreq; // loop frequency, Hz
|
float loopRate; // loop rate, Hz
|
||||||
int16_t channels[RC_CHANNELS]; // raw rc channels
|
int16_t channels[RC_CHANNELS]; // raw rc channels
|
||||||
float controls[RC_CHANNELS]; // normalized controls in range [-1..1] ([0..1] for throttle)
|
float controls[RC_CHANNELS]; // normalized controls in range [-1..1] ([0..1] for throttle)
|
||||||
float controlsTime; // time of the last controls update
|
float controlsTime; // time of the last controls update
|
||||||
|
@ -12,16 +12,16 @@ void step() {
|
|||||||
dt = 0; // assume dt to be zero on first step and on reset
|
dt = 0; // assume dt to be zero on first step and on reset
|
||||||
}
|
}
|
||||||
|
|
||||||
computeLoopFreq();
|
computeLoopRate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void computeLoopFreq() {
|
void computeLoopRate() {
|
||||||
static float windowStart = 0;
|
static float windowStart = 0;
|
||||||
static uint32_t freq = 0;
|
static uint32_t rate = 0;
|
||||||
freq++;
|
rate++;
|
||||||
if (t - windowStart >= 1) { // 1 second window
|
if (t - windowStart >= 1) { // 1 second window
|
||||||
loopFreq = freq;
|
loopRate = rate;
|
||||||
windowStart = t;
|
windowStart = t;
|
||||||
freq = 0;
|
rate = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
float t = NAN;
|
float t = NAN;
|
||||||
float dt;
|
float dt;
|
||||||
float loopFreq;
|
float loopRate;
|
||||||
float motors[4];
|
float motors[4];
|
||||||
int16_t channels[16]; // raw rc channels
|
int16_t channels[16]; // raw rc channels
|
||||||
float controls[RC_CHANNELS];
|
float controls[RC_CHANNELS];
|
||||||
@ -32,7 +32,7 @@ Vector rates;
|
|||||||
Quaternion attitude;
|
Quaternion attitude;
|
||||||
|
|
||||||
// declarations
|
// declarations
|
||||||
void computeLoopFreq();
|
void computeLoopRate();
|
||||||
void applyGyro();
|
void applyGyro();
|
||||||
void applyAcc();
|
void applyAcc();
|
||||||
void control();
|
void control();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user