Skip to content
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

Merged
merged 3 commits into from
Sep 28, 2016
Merged

Conversation

stephanbro
Copy link
Contributor

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:

  • Increase MPU6500 range to 16g's
  • Set on chip DLPF to 42Hz
  • Add a 2-pole low pass filter w/ 30Hz cutoff

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:
stock_acc
After:
filtered_acc

Copy link
Member

@tobbeanton tobbeanton left a 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);
Copy link
Member

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.

Copy link
Contributor Author

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);
Copy link
Member

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?

Copy link
Contributor Author

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);
Copy link
Member

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))
Copy link
Member

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?

@tobbeanton tobbeanton merged commit 6b24168 into bitcraze:master Sep 28, 2016
@tobbeanton
Copy link
Member

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.

@stephanbro
Copy link
Contributor Author

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.

@stephanbro
Copy link
Contributor Author

@carlin-psvl were you able to get any test flight in today?

@carlin-psvl
Copy link
Contributor

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.

@stephanbro stephanbro deleted the master.accel_config_changes branch October 3, 2016 16:36
@krichardsson krichardsson added this to the Next version milestone Dec 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants