[Feature] IMU API ideas #998
Labels
enhancement
New feature or request
software: pybricks-micropython
Issues with Pybricks MicroPython firmware (or EV3 runtime)
topic: control
Issues involving control system algorithms
topic: sensors
Issues involving sensors
Now that we are working on the IMU, we can have a closer look at what the existing and new methods in the IMU API must do.
In particular, we have to choose where and when we want to use:
heading()
This seems to be mostly used in 1D applications like a DriveBase. Proposal: 1D, no fusion
In a horizontal 1D application, fusion with the accelerometer has only downsides, so the proposed variant makes it numerically the most accurate/stable. See #989
As a downside, you'd get less accuracy if you do robot missions with ramps. We could either add a keyword argument like
heading(fusion=False)
or instead recommend that users use therotation()
method below if they need full 3D-based heading. Thoughts?This 1D-no-fusion variant is usually also the most useful for things like balancers. You could use the heading around Z to drive and use the "heading" around X or Y for balance. So there could be a keyword-argument with
heading(axis=Axis.X)
, only this makes "heading" a bit of a misnomer (?).tilt()
We could potentially keep this as-is (accelerometer only), or optionally use the fused result. With accelerometer only, the advantage is that it always works, regardless of initial conditions, drift, and so on. The fused result would respond faster, but you could argue that you could use the method below if you really need that.
orientation()
This is a new method. This would give the fused, 3D orientation in a non-singular representation.
This is useful for free motion application (build your own drone, etc), at the price of reduced accuracy when used in pure 1D application.
I think returning the rotation matrix is the most useful, but we could alternatively return the internally used quaternion or MRP.
The user can still use this to derive "heading-based-on-3d-with-fusion" in just a few lines.
Assuming we make examples like this, we could consider keeping
heading
andtilt
rather simple (non-fused) as shown above.Sidenote... if anyone was wondering why we had the
geometry
module, now you know. This has been the plan all along -- a simple but effective way to manipulate orientation information.The text was updated successfully, but these errors were encountered: