-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Solved my skyrocket issue by adding 2 new features #10308
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,9 @@ PG_RESET_TEMPLATE(positionEstimationConfig_t, positionEstimationConfig, | |
.reset_altitude_type = SETTING_INAV_RESET_ALTITUDE_DEFAULT, | ||
.reset_home_type = SETTING_INAV_RESET_HOME_DEFAULT, | ||
.gravity_calibration_tolerance = SETTING_INAV_GRAVITY_CAL_TOLERANCE_DEFAULT, // 5 cm/s/s calibration error accepted (0.5% of gravity) | ||
.dynamic_acc_weight = SETTING_DYNAMIC_ACC_WEIGHT_DEFAULT, | ||
.temp_correction_a = SETTING_TEMP_CORRECTION_A_DEFAULT, | ||
.temp_correction_b = SETTING_TEMP_CORRECTION_B_DEFAULT, | ||
.allow_dead_reckoning = SETTING_INAV_ALLOW_DEAD_RECKONING_DEFAULT, | ||
|
||
.max_surface_altitude = SETTING_INAV_MAX_SURFACE_ALTITUDE_DEFAULT, | ||
|
@@ -385,7 +388,11 @@ static void updateIMUTopic(timeUs_t currentTimeUs) | |
} | ||
else { | ||
/* Update acceleration weight based on vibration levels and clipping */ | ||
updateIMUEstimationWeight(dt); | ||
if (positionEstimationConfig()->dynamic_acc_weight) { | ||
updateIMUEstimationWeight(dt); | ||
} else { | ||
posEstimator.imu.accWeightFactor = 0.3f; | ||
} | ||
|
||
fpVector3_t accelBF; | ||
|
||
|
@@ -405,7 +412,19 @@ static void updateIMUTopic(timeUs_t currentTimeUs) | |
/* Read acceleration data in NEU frame from IMU */ | ||
posEstimator.imu.accelNEU.x = accelBF.x; | ||
posEstimator.imu.accelNEU.y = accelBF.y; | ||
posEstimator.imu.accelNEU.z = accelBF.z; | ||
const float baroTemperature = baroGetTemperature(); | ||
/* Some accelerometers may experience drifting caused by changing temperatures, | ||
you can use these 2 parameters to establish the linear relationship between the accelerometer drifting and the temperature | ||
(the baro needs to be in the FC, where the accelerometer is located) | ||
The formula is the following: f(x) = ax + b | ||
where f(x) is the calculated offset, a is how the offset varies for each degree, x is the barometer temperature in celsius and b would be the offset for 0ºC scenario | ||
What works well for me is: | ||
temp_correction_a = 4.834 | ||
temp_correction_b = -217.53 | ||
*/ | ||
const float acc_z_offset = ( positionEstimationConfig()->temp_correction_a * ( baroTemperature / 10.0f ) ) + positionEstimationConfig()->temp_correction_b; // f(x) = ax + b | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should be using the accelerometer temps, not the baro temps for this. The baro could be very far from the accelerometer and not be exposed to the same local temperature gradients. |
||
posEstimator.imu.accelNEU.z = accelBF.z + acc_z_offset; | ||
|
||
|
||
/* When unarmed, assume that accelerometer should measure 1G. Use that to correct accelerometer gain */ | ||
if (gyroConfig()->init_gyro_cal_enabled) { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure it this is needed. And if it is, it should not be hard coded to 0.3f when off.