VEXcode IQ C++ Unofficial documentation for version 3.0.4.1
Loading...
Searching...
No Matches
vex::gyro Class Reference
Inheritance diagram for vex::gyro:
vex::device

Public Member Functions

 gyro (int32_t index, bool calibrate=false, turnType dir=turnType::left)
 Creates a new gyro object on the port specified in the parameter.
 
bool installed ()
 
int32_t value ()
 Gets the angle of the gyro sensor.
 
double value (rotationUnits units=rotationUnits::deg)
 Gets the angle of the gyro sensor.
 
bool startCalibration (gyroCalibrationType value=gyroCalibrationType::calNormal, bool waitForCompletion=true)
 Starts recalibration of the gyro.
 
void calibrate (gyroCalibrationType value=gyroCalibrationType::calNormal, bool waitForCompletion=true)
 
bool isCalibrating ()
 Returns true while the gyro sensor is performing a requested recalibration, changing to false once recalibration has completed.
 
void resetHeading ()
 reset the gyro sensor angle to 0
 
void resetRotation ()
 reset the gyro sensor rotation to 0
 
void setHeading (double value, rotationUnits units)
 set the gyro sensor angle to angle
 
void setRotation (double value, rotationUnits units)
 set the gyro sensor rotation to angle
 
double angle (rotationUnits units=rotationUnits::deg)
 Gets the angle of the gyro sensor.
 
double heading (rotationUnits units=rotationUnits::deg)
 Gets the angle of the gyro sensor.
 
double rotation (rotationUnits units=rotationUnits::deg)
 Gets the absolute angle of the gyro sensor.
 
double rate (rateUnits units=rateUnits::dps)
 Gets the turn rate of the gyro sensor.
 
void changed (void(*callback)(void))
 Calls a function when the gyro sensor value changes.
 
void setTurnType (turnType dir)
 Set direction for positive angles.
 
turnType getTurnType ()
 Get direction for positive angles.
 
- Public Member Functions inherited from vex::device
 device (int32_t index)
 
IQ_DeviceType type ()
 
int32_t index ()
 
void init (int32_t index)
 
int32_t readDigitalPin ()
 
int32_t readAnalogPin ()
 

Additional Inherited Members

- Protected Member Functions inherited from vex::device
void setPollInterval (int32_t value)
 
bool pollValid (bool bSave)
 
- Protected Attributes inherited from vex::device
int16_t _index
 

Detailed Description

Definition at line 26 of file vex_gyro.h.

Constructor & Destructor Documentation

◆ gyro()

vex::gyro::gyro ( int32_t index,
bool calibrate = false,
turnType dir = turnType::left )

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

Parameters
portindex to the brain port.

Member Function Documentation

◆ angle()

double vex::gyro::angle ( rotationUnits units = rotationUnits::deg)

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.

◆ calibrate()

void vex::gyro::calibrate ( gyroCalibrationType value = gyroCalibrationType::calNormal,
bool waitForCompletion = true )
inline

Definition at line 58 of file vex_gyro.h.

◆ changed()

void vex::gyro::changed ( void(* callback )(void))

Calls a function when the gyro sensor value changes.

Parameters
callbackA reference to a function.

◆ getTurnType()

turnType vex::gyro::getTurnType ( )

Get direction for positive angles.

Returns
turnType::right or turnType::left

◆ heading()

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

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.

◆ installed()

bool vex::gyro::installed ( )
virtual

Reimplemented from vex::device.

◆ 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.

◆ rate()

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

Gets the turn rate 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.

◆ rotation()

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

Gets the 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.

◆ setHeading()

void vex::gyro::setHeading ( double 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 ( double value,
rotationUnits units )

set the gyro sensor rotation to angle

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

◆ setTurnType()

void vex::gyro::setTurnType ( turnType dir)

Set direction for positive angles.

Parameters
dirturnType::right or turnType::left

◆ startCalibration()

bool vex::gyro::startCalibration ( gyroCalibrationType value = gyroCalibrationType::calNormal,
bool waitForCompletion = true )

Starts recalibration of the gyro.

Parameters
value(Optional) Sets the amount of calibration time. By default, this parameter is quick.
waitForCompletionwait for calibration to complete @motes the IQ startCalibration method will block until calibration is finished.

◆ value() [1/2]

int32_t vex::gyro::value ( )
virtual

Gets the angle of the gyro sensor.

Returns
Returns an integer that represents the angle of the gyro sensor

Reimplemented from vex::device.

◆ value() [2/2]

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

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.

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