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

Use this class when programming with a gyro sensor. More...

Inherits vex::__tridevice, and vex::guido.

Public Member Functions

 gyro (triport::port &port)
 Creates a new gyro object on the port specified in the parameter. More...
 
 ~gyro ()
 
int32_t value (analogUnits units)
 Gets the value of the gyro sensor. More...
 
double value (rotationUnits units)
 Gets the value of the gyro sensor. More...
 
int32_t value (percentUnits units)
 Gets the value of the gyro sensor. More...
 
void startCalibration (int32_t value=0)
 Starts recalibration of the gyro. Note that the gyro is automatically calibrated when the constructor is called. 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 absolute angle to 0 More...
 
void setHeading (double value, rotationUnits units)
 reset the gyro sensor angle to angle More...
 
double heading (rotationUnits units=rotationUnits::deg)
 Gets the angle of the gyro sensor. More...
 
double rotation (rotationUnits units=rotationUnits::deg)
 Gets the rotation (absolute angle) of the gyro sensor. More...
 
void setRotation (double value, rotationUnits units)
 set the gyro sensor rotation to angle More...
 
- Public Member Functions inherited from vex::guido
virtual ~guido ()
 

Detailed Description

Use this class when programming with a gyro sensor.

Constructor & Destructor Documentation

◆ gyro()

vex::gyro::gyro ( triport::port port)

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

Parameters
portA reference to a three wire port.

◆ ~gyro()

vex::gyro::~gyro ( )

Member Function Documentation

◆ value() [1/3]

int32_t vex::gyro::value ( analogUnits  units)

Gets the value of the gyro sensor.

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

◆ value() [2/3]

double vex::gyro::value ( rotationUnits  units)

Gets the value of the gyro sensor.

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

◆ value() [3/3]

int32_t vex::gyro::value ( percentUnits  units)
inline

Gets the value of the gyro sensor.

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

◆ startCalibration()

void vex::gyro::startCalibration ( int32_t  value = 0)

Starts recalibration of the gyro. Note that the gyro is automatically calibrated when the constructor is called.

Parameters
value(Optional) Sets the amount of calibration time. By default, this parameter is zero.

◆ isCalibrating()

bool vex::gyro::isCalibrating ( )
virtual

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.

Implements vex::guido.

◆ resetHeading()

void vex::gyro::resetHeading ( )

reset the gyro sensor angle to 0

◆ resetRotation()

void vex::gyro::resetRotation ( )

reset the gyro sensor absolute angle to 0

◆ setHeading()

void vex::gyro::setHeading ( double  value,
rotationUnits  units 
)
virtual

reset the gyro sensor angle to angle

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

Implements vex::guido.

◆ heading()

double vex::gyro::heading ( rotationUnits  units = rotationUnits::deg)
virtual

Gets the angle of the gyro sensor.

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

Implements vex::guido.

◆ rotation()

double vex::gyro::rotation ( rotationUnits  units = rotationUnits::deg)
virtual

Gets the rotation (absolute angle) of the gyro sensor.

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

Implements vex::guido.

◆ setRotation()

void vex::gyro::setRotation ( double  value,
rotationUnits  units 
)
virtual

set the gyro sensor rotation to angle

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

Implements vex::guido.