class
IMU
Contents
Base classes
- class ContinuousRotarySensor
Constructors, destructors, conversion operators
-
IMU(std::uint8_t iport,
IMUAxes iaxis = IMUAxes::
z) - An inertial sensor on the given port.
Public functions
- auto get() const -> double override
- Get the current rotation about the configured axis.
- auto getRemapped(double iupperBound = 1800, double ilowerBound = -1800) const -> double
- Get the current sensor value remapped into the target range (
[-1800, 1800]
by default). - auto getAcceleration() const -> double
- Get the current acceleration along the configured axis.
- auto reset() -> std::int32_t override
- Reset the rotation value to zero.
- auto reset(double inewAngle) -> std::int32_t
- Resets rotation value to desired value For example,
reset(0)
will reset the sensor to zero. - auto calibrate() -> std::int32_t
- Calibrate the IMU.
- auto controllerGet() -> double override
- Get the sensor value for use in a control loop.
- auto isCalibrating() const -> bool
Protected functions
- auto readAngle() const -> double
- Get the current rotation about the configured axis.
Protected variables
Function documentation
okapi:: IMU:: IMU(std::uint8_t iport,
IMUAxes iaxis = IMUAxes:: z)
An inertial sensor on the given port.
Parameters | |
---|---|
iport | The port number in the range [1, 21] . |
iaxis | The axis of the inertial sensor to measure, default IMUAxes:: . |
The IMU returns an angle about the selected axis in degrees.
auto imuZ = IMU(1); auto imuX = IMU(1, IMUAxes::x);
double okapi:: IMU:: get() const override
Get the current rotation about the configured axis.
Returns | The current sensor value or PROS_ERR . |
---|
double okapi:: IMU:: getRemapped(double iupperBound = 1800,
double ilowerBound = -1800) const
Get the current sensor value remapped into the target range ([-1800, 1800]
by default).
Parameters | |
---|---|
iupperBound | The upper bound of the range. |
ilowerBound | The lower bound of the range. |
Returns | The remapped sensor value. |
double okapi:: IMU:: getAcceleration() const
Get the current acceleration along the configured axis.
Returns | The current sensor value or PROS_ERR . |
---|
std::int32_t okapi:: IMU:: reset(double inewAngle)
Resets rotation value to desired value For example, reset(0)
will reset the sensor to zero.
Parameters | |
---|---|
inewAngle | desired reset value |
Returns | 1 or PROS_ERR . |
But reset(90)
will reset the sensor to 90 degrees.
double okapi:: IMU:: controllerGet() override
Get the sensor value for use in a control loop.
Returns | The current sensor value or PROS_ERR . |
---|
This method might be automatically called in another thread by the controller.
bool okapi:: IMU:: isCalibrating() const
Returns | Whether the IMU is calibrating. |
---|
double okapi:: IMU:: readAngle() const protected
Get the current rotation about the configured axis.
Returns | The current sensor value or PROS_ERR . |
---|
The internal offset is not accounted for or modified. This just reads from the sensor.