I know that Copter -> AP_AHRS -> DCM or EKF are for attitude control

I have 3 small question

1- What does the DCM mean?

2- how much state does the EKF3 contain?

3-what is the difference between EKF2 and EKF3? and what is the best between them?

PS:I want to use a PX4flow and a range finder for attitude control

My go-to hobbyists guide to state estimation is http://www.olliw.eu/2013/imu-data-fusing/

For the specific implementations in ArduPilot, Paul Riseborough has the ekf derivations in his GitHub repo, (ekf2 is 22 state, ekf3 has a couple more iirc) and Bill Premerlaniâ€™s dcm is published in a paper somewhere.

http://ardupilot.org/dev/docs/ekf2-estimation-system.html#what-is-the-ekf2-estimation-system

EKF2 is 24 state, but thatâ€™s close enough.

Additionally, a Kalman Filter operates primarily on Euler Angles, although it also uses Quartenions and DCM within (well some do, not sure if this one does). Direction Cosign Matrix is considerably less intuitive than Euler Angles, because it is hard to visualize them.

Picking apart my manual on Kalman filters, probably the easiest way to compare the two is:

A DCM is a matrices operation which allows you to transform a vector from one coordinate system to another. It requires initial conditions. It is a single calculation which doesnâ€™t take into account multiple sources of change. (Iâ€™m probably simplifying that too much)

A KF utilizes multiple sources of change (IMU, GPS, flow, etc), with provided covariances to weight each source based on reliability, to make â€śpositionâ€ť changes. (It isnâ€™t really tracking position though, thatâ€™s integrated later). A Kalman filter will provide the optimal estimate of the state of a linear system corrupted by white Gaussian noise. Since it doesnâ€™t need to store past measurements to provide current estimate, it is known as recursive.

Relevant to ArduPilot, the DCM implementation is less accurate than the EKF when everything is working, but as it doesnâ€™t use the accelerometer, in some cases deals with vibration better.

Also, when you lose gps (which is used, amongst other things, to compensate for imu drift), the estimate of the EKF will decay exponentially with time, whilst the DCM decays linearly (which is why it is used as a fallback in Plane).

@james_pattison, Pardon me if my statement appears of newbie.

From what I understand, DCM, Quaternion etc are just ways to store/represent orientation of the vehicle.

So, when you say DCM implementation, Iâ€™m assuming you mean complimentary filter implementation.

With that, complimentary filters DO use accel data too for angles estimation. Why do you say that it does not?