LightLib
PROS library for VEX V5: EKF/MCL localization, RAMSETE path following, high-level chassis API
Loading...
Searching...
No Matches
okapi::ADIGyro Class Reference

#include <adiGyro.hpp>

Inheritance diagram for okapi::ADIGyro:
okapi::ContinuousRotarySensor okapi::RotarySensor okapi::ControllerInput< double >

Public Member Functions

 ADIGyro (std::uint8_t iport, double imultiplier=1)
 A gyroscope on the given ADI port.
 
 ADIGyro (std::pair< std::uint8_t, std::uint8_t > iports, double imultiplier=1)
 A gyroscope on the given ADI port.
 
double get () const override
 Get the current sensor value.
 
double getRemapped (double iupperBound=1800, double ilowerBound=-1800) const
 Get the current sensor value remapped into the target range ([-1800, 1800] by default).
 
std::int32_t reset () override
 Reset the sensor to zero.
 
double controllerGet () override
 Get the sensor value for use in a control loop.
 
- Public Member Functions inherited from okapi::RotarySensor
virtual ~RotarySensor ()
 

Protected Attributes

pros::c::ext_adi_gyro_t gyro
 

Detailed Description

Definition at line 13 of file adiGyro.hpp.

Constructor & Destructor Documentation

◆ ADIGyro() [1/2]

okapi::ADIGyro::ADIGyro ( std::uint8_t  iport,
double  imultiplier = 1 
)

A gyroscope on the given ADI port.

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');
pros::c::ext_adi_gyro_t gyro
Definition adiGyro.hpp:80
Parameters
iportThe ADI port number ([1, 8], [a, h], [A, H]).
imultiplierA value multiplied by the gyro heading value.

◆ ADIGyro() [2/2]

okapi::ADIGyro::ADIGyro ( std::pair< std::uint8_t, std::uint8_t >  iports,
double  imultiplier = 1 
)

A gyroscope on the given ADI port.

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.

Parameters
iportsThe 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]).
imultiplierA value multiplied by the gyro heading value.

Member Function Documentation

◆ controllerGet()

double okapi::ADIGyro::controllerGet ( )
overridevirtual

Get the sensor value for use in a control loop.

This method might be automatically called in another thread by the controller.

Returns
the current sensor value, or PROS_ERR on a failure.

Implements okapi::ControllerInput< double >.

◆ get()

double okapi::ADIGyro::get ( ) const
overridevirtual

Get the current sensor value.

Returns
the current sensor value, or PROS_ERR on a failure.

Implements okapi::RotarySensor.

◆ getRemapped()

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
iupperBoundthe upper bound of the range.
ilowerBoundthe lower bound of the range.
Returns
the remapped sensor value.

◆ reset()

std::int32_t okapi::ADIGyro::reset ( )
overridevirtual

Reset the sensor to zero.

Returns
1 on success, PROS_ERR on fail

Implements okapi::ContinuousRotarySensor.

Member Data Documentation

◆ gyro

pros::c::ext_adi_gyro_t okapi::ADIGyro::gyro
protected

Definition at line 80 of file adiGyro.hpp.


The documentation for this class was generated from the following file: