Closed prashanthr05 closed 5 years ago
An alternative design you may consider is to have one C++ interface (i.e. virtual class) IAttitudeEstimator, and then three concrete classes implementing the actual filters.
My instincts were leaning towards this virtual class design. However, I had this idea of composition over inheritance, as well. But then, since we will be defining only a virtual class, it shouldnt come with the usual bottlenecks of inheritance. I will redesign the AttitudeEstimator
class to implement the virtual class interface, so that the generic methods are easily extensible to different types of filter.
In general virtual functions involve a runtime performance cost over normal functions
True. In the current design I proposed, I already had started thinking about the time constraints imposed by too many nested function calls. I think it would rather be efficient to have virtual functions and the derived classes implementing their own functionalities within these.
I think it is easier to have a configure/init call in which this options can be specified.
If you go to have a separate class for each orientation, a clean solution is to have a structure nested inside the class for handling the class options.
I think it would be good to have a method to get/set any kind of internal state of the filter, even in an opaque way.
I agree.
A first version implementation of IAttitudeEstimator interface implementing AttitudeMahonyFIlter can be found here. It's missing a clear documentation. It's yet to be tested. However, I will be testing it soon. I will update docs after running first tests on the filter.
A tested implementation of AttitudeMahonyFilter (explicit complementary filter on quaternions) and AttitudeQuaternionEKF is available in this branch. I shall make a PR once I cleanly document the code and the usage.
Meanwhile if someone wants to test the filters, QuaternionEKF can be as easily implemented with the steps described in this test. However, the propagateStates()
and updateFilterWithMeasurements()
method should be run in a loop , as opposed to the implementation in the test. Attention should be paid to the gains and initial state in the QEKF for getting desirable performance. These parameters are available in the AttitudeQuaternionEKFParameters
.
The Mahony Filter follows similar steps, except the fact that the update step is run first and the propagate states after. The gains are critical in getting a good performance here as well. However, the filter exhibits an asymptoticallly stable behavior, so it converges to the actual state whatever the inital state is (i.e. if the gains are good). The parameters are available in AttitudeMahonyFilterParameters
.
These classes were made available through the PR (https://github.com/robotology/idyntree/pull/516) merged into devel with this commit.
Closing this issue.
Prashanth said:
Silvio's pointers on the interface
Diego's comments,
Silvio replied
Prashanth said
SIlvio commented