-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Accelerometer Filtering #151
Conversation
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.
Thanks for the changes! Please have a look at my comments.
// Set digital low-pass bandwidth | ||
mpu6500SetDLPFMode(MPU6500_DLPF_BW_98); | ||
mpu6500SetDLPFMode(MPU6500_DLPF_BW_42); |
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.
This will set the gyro DLPF. Is that what you intended to do or you wanted to change the accel DLPF? I think this setting might slow down the system.
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.
You are right, I don't think we want to change the DLPF on the gyro.
@@ -335,10 +339,9 @@ static void sensorsDeviceInit(void) | |||
// Set accelerometer full scale range | |||
mpu6500SetFullScaleAccelRange(SENSORS_ACCEL_FS_CFG); | |||
#ifdef ESTIMATOR_TYPE_complementary | |||
mpu6500SetRate(0); | |||
mpu6500SetAccelDLPF(MPU6500_ACCEL_DLPF_BW_20); |
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.
This is the accel DLPF setting. Probably what you want to change?
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.
Good catch. I think that's likely the case.
@@ -348,9 +351,13 @@ static void sensorsDeviceInit(void) | |||
// To low DLPF bandwidth might cause instability and decrease agility | |||
// but it works well for handling vibrations and unbalanced propellers | |||
// Set output rate (1): 1000 / (1 + 1) = 500Hz | |||
mpu6500SetRate(1); | |||
mpu6500SetRate(0); |
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.
This will change setting to 1kHz sampling output right? Please update comment above if that is the case. Also does 1kHz sample output improve anything, latency maybe?
@@ -398,7 +405,7 @@ static void sensorsSetupSlaveRead(void) | |||
// SMPLRT_DIV is only used for 1kHz internal sampling." Slowest update rate is then 500Hz. | |||
mpu6500SetSlave4MasterDelay(15); // read slaves at 500Hz = (8000Hz / (1 + 15)) | |||
#else | |||
mpu6500SetSlave4MasterDelay(4); // read slaves at 100Hz = (500Hz / (1 + 4)) | |||
mpu6500SetSlave4MasterDelay(9); // read slaves at 100Hz = (500Hz / (1 + 4)) |
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.
Please update comment as well. Faster sampling rate might improve latency? Reason why you set it to 100Hz?
I was eager and merged the changes plus the suggested review points and some other position control improvements. Can you please try the changes @stephanbro? Now the more aggressive PID is active for kalman filter as well. It makes it nervous but more precise. |
Sorry I didn't get back sooner about your comments; I've been out sick unfortunately. I know you guys have the maker faire coming up this weekend, so I will see what I can do to get your changes tested today. |
@carlin-psvl were you able to get any test flight in today? |
I wasn't able to gather more accelerometer data but I did test some quick test flights. Qualitatively speaking, height control is improved over my previous flights. I needed to add an integral limit to to the position PIDs, without them the CF had a tendency to build up a lot of integral momentum and orbit its goal point. |
In an attempt to improve the Z estimate, I've added some filtering to the accelerometer's output values that is based on the PX4 MPU9250 driver (BSD-licensed).
The changes are as follows:
The results look positive and while flying using the LPS, I did not have a large deviation in Z estimate vs actual as I had prior to filtering. Both of the plots show below consist of a takeoff, hovering in place, and a landing.
Before:
After: