XRPGyro

class xrp.XRPGyro

Bases: pybind11_object

Use a rate gyro to return the robots heading relative to a starting position.

This class is for the XRP onboard gyro, and will only work in simulation/XRP mode. Only one instance of a XRPGyro is supported.

Constructs an XRPGyro.

Only one instance of a XRPGyro is supported.

get_angle() wpimath.units.radians

Return the actual angle in radians that the robot is currently facing.

The angle is based on integration of the returned rate form the gyro. The angle is continuous, that is, it will continue from 2π->2.1π. This allows algorithms that wouldn’t want to see a discontinuity in the gyro output as it sweeps from 2π to 0 radians on the second time around.

Returns:

the current heading of the robot in radians.

get_angle_x() wpimath.units.radians

Gets the currently reported angle around the X-axis.

Returns:

current angle around X-axis in radians

get_angle_y() wpimath.units.radians

Gets the currently reported angle around the Y-axis.

Returns:

current angle around Y-axis in radians

get_angle_z() wpimath.units.radians

Gets the currently reported angle around the Z-axis.

Returns:

current angle around Z-axis in radians

get_rate() wpimath.units.radians_per_second

Return the rate of rotation of the gyro

The rate is based on the most recent reading of the gyro.

Returns:

the current rate in radians per second

get_rate_x() wpimath.units.radians_per_second

Gets the rate of turn in radians-per-second around the X-axis.

Returns:

rate of turn in radians-per-second

get_rate_y() wpimath.units.radians_per_second

Gets the rate of turn in radians-per-second around the Y-axis.

Returns:

rate of turn in radians-per-second

get_rate_z() wpimath.units.radians_per_second

Gets the rate of turn in radians-per-second around the Z-axis.

Returns:

rate of turn in radians-per-second

get_rotation2d() wpimath._wpimath.Rotation2d

Gets the angle the robot is facing.

Returns:

A wpi::math::Rotation2d with the current heading.

reset() None

Reset the gyro angles to 0.