Use 'loop rate' term instead of misleading 'loop frequency'

This commit is contained in:
Oleg Kalachev 2024-12-04 07:00:00 +03:00
parent 7fa3baa76a
commit ea141f851f
5 changed files with 12 additions and 12 deletions

View File

@ -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.
* **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.
* **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.
* **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.

View File

@ -53,7 +53,7 @@ const struct Param {
{"lpr", &ratesFilter.alpha, nullptr},
{"lpd", &rollRatePID.lpf.alpha, &pitchRatePID.lpf.alpha},
{"ss", &loopFreq, nullptr},
{"ss", &loopRate, nullptr},
{"dt", &dt, 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("acc: %f %f %f\n", acc.x, acc.y, acc.z);
printIMUCal();
Serial.printf("frequency: %f\n", loopFreq);
Serial.printf("rate: %f\n", loopRate);
} else if (command == "rc") {
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],

View File

@ -25,7 +25,7 @@
float t = NAN; // current step time, 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
float controls[RC_CHANNELS]; // normalized controls in range [-1..1] ([0..1] for throttle)
float controlsTime; // time of the last controls update

View File

@ -12,16 +12,16 @@ void step() {
dt = 0; // assume dt to be zero on first step and on reset
}
computeLoopFreq();
computeLoopRate();
}
void computeLoopFreq() {
void computeLoopRate() {
static float windowStart = 0;
static uint32_t freq = 0;
freq++;
static uint32_t rate = 0;
rate++;
if (t - windowStart >= 1) { // 1 second window
loopFreq = freq;
loopRate = rate;
windowStart = t;
freq = 0;
rate = 0;
}
}

View File

@ -21,7 +21,7 @@
float t = NAN;
float dt;
float loopFreq;
float loopRate;
float motors[4];
int16_t channels[16]; // raw rc channels
float controls[RC_CHANNELS];
@ -32,7 +32,7 @@ Vector rates;
Quaternion attitude;
// declarations
void computeLoopFreq();
void computeLoopRate();
void applyGyro();
void applyAcc();
void control();