ADIGyro class
Contents
Base classes
- class ContinuousRotarySensor
Constructors, destructors, conversion operators
Public functions
- auto get() const -> double override
- Get the current sensor value.
- 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 reset() -> std::int32_t override
- Reset the sensor to zero.
- auto controllerGet() -> double override
- Get the sensor value for use in a control loop.
Protected variables
- pros::c::ext_adi_gyro_t gyro
Function documentation
okapi:: ADIGyro:: ADIGyro(std::uint8_t iport,
double imultiplier = 1)
A gyroscope on the given ADI port.
| Parameters | |
|---|---|
| iport | The ADI port number ([1, 8], [a, h], [A, H]). |
| imultiplier | A value multiplied by the gyro heading value. |
If the port has not previously been configured as a gyro, then the constructor will block for 1 second for calibration. The gyro measures in tenths of a degree, so there are 3600 measurement points per revolution.
auto gyro = ADIGyro('A');
okapi:: ADIGyro:: ADIGyro(std::pair<std::uint8_t, std::uint8_t> iports,
double imultiplier = 1)
A gyroscope on the given ADI port.
| Parameters | |
|---|---|
| iports | The ports the gyro is plugged in to in the order {smart port, gyro port}. The smart port is the smart port number ([1, 21]). The gyro port is the ADI port number ([1, 8], [a, h], [A, H]). |
| imultiplier | A value multiplied by the gyro heading value. |
If the port has not previously been configured as a gyro, then the constructor will block for 1 second for calibration. The gyro measures in tenths of a degree, so there are 3600 measurement points per revolution.
auto gyro = ADIGyro({1, 'A'}, 1);
Note to developers: Keep the default value on imultiplier so that users get an error if they do ADIGyro({1, 'A'}). Without it, this calls the non-ext-adi constructor.
double okapi:: ADIGyro:: get() const override
Get the current sensor value.
| Returns | the current sensor value, or PROS_ERR on a failure. |
|---|
double okapi:: ADIGyro:: 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. |
std::int32_t okapi:: ADIGyro:: reset() override
Reset the sensor to zero.
| Returns | 1 on success, PROS_ERR on fail |
|---|
double okapi:: ADIGyro:: controllerGet() override
Get the sensor value for use in a control loop.
| Returns | the current sensor value, or PROS_ERR on a failure. |
|---|
This method might be automatically called in another thread by the controller.