-
-
Notifications
You must be signed in to change notification settings - Fork 61
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
Enable 1D gyro heading measurement and drivebase control #156
Conversation
This was giving bad values, including for the existing test, because the scale and/or sign was ignored.
This is needed to capture fast twists.
This is an experimental implementation to evaluate heading performance.
These values are expected to be PDRV_CONFIG constants ultimately, but we'd like to gather some user input to get sensible defaults. This adds a temporary setter that we can remove when we've figured out what the thresholds should be.
Todo: - This needs to be split into several commits - Generalize the gyro input as callable - Fix range of rotations (now limited to +/- 1000 full turns)
Based on user feedback, the current defaults are good enough. pybricks/support#989
This removes the remaining unused references to pbdrv.
A couple of things to review:
We probably need to verify what the actual sampling rate is, or measure it as we go. Similarly, we'll want to check if we are occasionally missing a few samples or not. We'll also need to check this on Technic Hub, where the I2C setup is slightly different, in case there are any difference. Once that is settled, we may need to experimentally verify There is currently no adjustment for misalignment of the chip within the hub. This is possible using a calibration routine (see pybricks/support#943), but the benefit is fairly small for everyday users. However, it may be useful to do this locally when we test for sample rates as above, to ensure we register the full Z measurement when tweaking In |
A similar debug function was previously dropped. However, users have requested to keep this control available in [1]. This makes a setter available in proper units, and sets defaults. [1] pybricks/support#989
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.
Really nice work on this. It is well documented and easy to follow for such a big changeset.
Mostly just comments on organization (separation of concerns) and a few nitpicks.
Thanks for the review! I'll update this and get it merged. |
Addresses feedback from #156
This contains only pure functions and will get optimized out when not used. See #156 (comment)
This contains only pure functions and will get optimized out when not used. The IMU part with a state can still be disabled.
This addresses the REVISIT for reading the heading. Additionally, this avoids pulling in floating point code on platforms that don't support it. This lets us drop the config guard for this step.
This ensures the gyro will work with the drivebase even if the hub and imu are not explicitly initialized.
Based on feedback in #156
Addresses feedback from #156
This was accidentally added within the motor process guard.
Now that all pure orientation functions have been moved to pbio/geometry only the orientation_imu functions remain. So we can just rename it imu, and make it an independent module that can be enabled just like other hardware modules.
I deferred some pending issues to pybricks/support#1022. Everything else is addressed, so I'll go ahead and merge this. |
Addresses feedback from #156
This contains only pure functions and will get optimized out when not used. See #156 (comment)
Addresses feedback from #156
This implements a first version of the
heading()
andreset_heading()
methods in theIMU
class.Limitation: This is only 1D rotation, like driving around on a flat table. 3D attitude estimation is in progress, but we wanted to make sure we have a useful starting point for FLL in the mean time.
Automatic calibration
The sensor incrementally updates its internal calibration whenever it is not moving. No user action is necessary. The hub does not need to be stationary on boot. A method
hub.imu.stationary()
is available so users can verify that it is stationary.Accurate heading reading with drift correction
VID_20230321_214216.mp4
The heading value does not drift while stationary because of the constant re-calibration.
While heading estimation is limited 1D, you can still mount the hub at an arbitrary rotation in your robot, as shown in the video above.
The
imu.angular_velocity()
value is now also automatically accounted for drift, in case you want to build your own balancers, etc.Builtin drivebase motion adjustment
The gyro can be used in the
DriveBase
class for automatic corrections while driving.Example of just driving
straight()
:VID_20230316_141516.mp4
Example of making fast, accurate turns. Code below:
VID_20230316_205400.mp4