Skip to content

[Bug] imu.angular_velocity() returns accelerometer values rather than gyroscope values (Technic Hub) #885

@CasperClarke

Description

@CasperClarke

Describe the bug
When using imu.angular_velocity() on a technic hub accelerometer values are returned rather than gyroscope values.

To reproduce
In the Pybricks online IDE type the following code;

from pybricks.hubs import TechnicHub
from pybricks.tools import wait
from pybricks.geometry import Axis

# Initialize the hub.
hub = TechnicHub()

# Get the acceleration or angular_velocity along a single axis.
# If you need only one value, this is more memory efficient.
while True:

    # Read the forward acceleration.
    #forward_acceleration = hub.imu.acceleration(Axis.X)

    # Read the yaw rate.
    G_rateX = hub.imu.angular_velocity(Axis.X)
    G_rateY = hub.imu.angular_velocity(Axis.Y)
    G_rateZ = hub.imu.angular_velocity(Axis.Z)
    A_rateX = hub.imu.acceleration(Axis.X)
    A_rateY = hub.imu.acceleration(Axis.Y)
    A_rateZ = hub.imu.acceleration(Axis.Z)


    # Print the yaw rate.
    print(" Gyro: ",yaw_rateX,yaw_rateY,yaw_rateZ)
    print("Accel: ",A_rateX,A_rateY,A_rateZ)
    wait(100)

Running the code produces the result:

 Gyro:  1826.347 -3906.421 9126.949
Accel:  1826.347 -3906.421 9126.949
 Gyro:  1831.135 -3915.995 9047.959
Accel:  1831.135 -3915.995 9047.959

The produced Gyro and accelerometer values are the same.

Expected behavior
The expected result would be an angular velocity in deg/s would be returned from the lsm6dso in the form of 3 values along each axis.
In my testing case the technic hub was static, meaning the expected values for the gyro should have been near zero.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions