VEX IQ C++ API
Public Member Functions | List of all members
vex::gyro Class Reference

Gyro sensor device class. More...

Inherits vex::device.

Public Member Functions

 gyro (int32_t index, bool calibrate=true)
 Creates a new gyro object on the port specified in the parameter. More...
 
 ~gyro ()
 
void startCalibration (gyroCalibrationType type=gyroCalibrationType::quick, bool waitForCompletion=true)
 Starts recalibration of the gyro. More...
 
bool isCalibrating ()
 Returns true while the gyro sensor is performing a requested recalibration, changing to false once recalibration has completed. More...
 
void resetHeading ()
 reset the gyro sensor angle to 0 More...
 
void resetRotation ()
 reset the gyro sensor rotation to 0 More...
 
void setHeading (float value, rotationUnits units)
 set the gyro sensor angle to angle More...
 
void setRotation (float value, rotationUnits units)
 set the gyro sensor rotation to angle More...
 
float heading (rotationUnits units=rotationUnits::deg)
 Gets the angle of the gyro sensor. More...
 
float rotation (rotationUnits units=rotationUnits::deg)
 Gets the absolute angle of the gyro sensor. More...
 
float rate (rateUnits units=rateUnits::dps)
 Gets the turn rate of the gyro sensor. More...
 
- Public Member Functions inherited from vex::device
 device (int32_t index)
 
 ~device ()
 

Additional Inherited Members

- Protected Attributes inherited from vex::device
int32_t _index
 

Detailed Description

Gyro sensor device class.

Constructor & Destructor Documentation

◆ gyro()

vex::gyro::gyro ( int32_t  index,
bool  calibrate = true 
)

Creates a new gyro object on the port specified in the parameter.

Parameters
indexto the brain port.
calibratestart calibrating the gyro

◆ ~gyro()

vex::gyro::~gyro ( )
inline

Member Function Documentation

◆ startCalibration()

void vex::gyro::startCalibration ( gyroCalibrationType  type = gyroCalibrationType::quick,
bool  waitForCompletion = true 
)

Starts recalibration of the gyro.

Parameters
type(Optional) Sets the amount of calibration time. By default, this parameter is quick.
waitForCompletionwait for calibration to complete

◆ isCalibrating()

bool vex::gyro::isCalibrating ( )

Returns true while the gyro sensor is performing a requested recalibration, changing to false once recalibration has completed.

Returns
Returns true if gyro is still calibrating.

◆ resetHeading()

void vex::gyro::resetHeading ( )
inline

reset the gyro sensor angle to 0

◆ resetRotation()

void vex::gyro::resetRotation ( )
inline

reset the gyro sensor rotation to 0

◆ setHeading()

void vex::gyro::setHeading ( float  value,
rotationUnits  units 
)

set the gyro sensor angle to angle

Parameters
valueThe new heading for the gyro
unitsThe rotation unit for the heading

◆ setRotation()

void vex::gyro::setRotation ( float  value,
rotationUnits  units 
)

set the gyro sensor rotation to angle

Parameters
valueThe new absolute angle for the gyro
unitsThe rotation unit for the angle

◆ heading()

float vex::gyro::heading ( rotationUnits  units = rotationUnits::deg)

Gets the angle of the gyro sensor.

Returns
Returns a float that represents the unit value specified by the parameter of the gyro sensor.
Parameters
unitsThe measurement unit for the gyro device.

◆ rotation()

float vex::gyro::rotation ( rotationUnits  units = rotationUnits::deg)

Gets the absolute angle of the gyro sensor.

Returns
Returns a float that represents the unit value specified by the parameter of the gyro sensor.
Parameters
unitsThe measurement unit for the gyro device.

◆ rate()

float vex::gyro::rate ( rateUnits  units = rateUnits::dps)

Gets the turn rate of the gyro sensor.

Returns
Returns a float that represents the unit value specified by the parameter of the gyro sensor.
Parameters
unitsThe measurement unit for the gyro device.