Skip to content

[Bug] Bad internal rounding causes gyro controller to be off by 0.3%. #1886

@laurensvalk

Description

@laurensvalk

Describe the bug / To reproduce

round(hub.imu.heading()) is supposed to be equal to robot.angle() when the gyro is used, but was not the case.

image

For example, 720.3 should round to 720, not 722.

This was linearly increasing for bigger rotations, adding to the apparent drift when there wasn't any.

Expected behavior
Round properly. And then later switch to floats in #1844.

We need to fix the rounding either way because this value is still used by the internal controllers, causing things like turn(360) be off to up to a degree.

Additional context
This issue has already been debugged, but opening this issue serves as a documentation of the issue and its fix. Fix incoming shortly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    software: pybricks-micropythonIssues with Pybricks MicroPython firmware (or EV3 runtime)topic: controlIssues involving control system algorithmstopic: imuIssues related to IMU/gyro/accelerometer

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions