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

Use the rotation class to control absolute encoder devices. More...

Inherits vex::device.

Public Member Functions

 rotation (int32_t index, bool reverse=false)
 Creates a new rotation object on the port specified. More...
 
 ~rotation ()
 
bool installed ()
 
int32_t value ()
 
void setReversed (bool value)
 Sets the encoder mode to "reverse", position and angle will change in the opposite direction. More...
 
double angle (rotationUnits units=rotationUnits::deg)
 Gets the angle of the absolute encoder. More...
 
void resetPosition (void)
 Resets the value of the absolute encoder to zero. More...
 
void setPosition (double value, rotationUnits units)
 Sets the value of the absolute encoder to the value specified in the parameter. More...
 
double position (rotationUnits units)
 Gets the current position of the absolute encoder. More...
 
double velocity (velocityUnits units)
 Gets the current velocity of the absolute encoder. More...
 
- Public Member Functions inherited from vex::device
 device ()
 
 device (int32_t index)
 
 ~device ()
 
V5_DeviceType type ()
 
void init (int32_t index)
 

Protected Member Functions

int32_t status ()
 

Additional Inherited Members

- Protected Attributes inherited from vex::device
int32_t _index
 

Detailed Description

Use the rotation class to control absolute encoder devices.

Constructor & Destructor Documentation

◆ rotation()

vex::rotation::rotation ( int32_t  index,
bool  reverse = false 
)

Creates a new rotation object on the port specified.

Parameters
indexThe port index for this rotation sensor. The index is zero-based.
reverseIf set to true, the encoder counts in reverse

◆ ~rotation()

vex::rotation::~rotation ( )

Member Function Documentation

◆ installed()

bool vex::rotation::installed ( )
virtual

Reimplemented from vex::device.

◆ value()

int32_t vex::rotation::value ( )
virtual

Reimplemented from vex::device.

◆ setReversed()

void vex::rotation::setReversed ( bool  value)

Sets the encoder mode to "reverse", position and angle will change in the opposite direction.

Parameters
valueIf set to true, the encoder counts in reverse

◆ angle()

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

Gets the angle of the absolute encoder.

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

◆ resetPosition()

void vex::rotation::resetPosition ( void  )

Resets the value of the absolute encoder to zero.

◆ setPosition()

void vex::rotation::setPosition ( double  value,
rotationUnits  units 
)

Sets the value of the absolute encoder to the value specified in the parameter.

Parameters
valueSets the current position of the absolute encoder.
unitsThe measurement unit for the position value.

◆ position()

double vex::rotation::position ( rotationUnits  units)

Gets the current position of the absolute encoder.

Parameters
unitsThe measurement unit for the position.
Returns
a double that represents the current position of the encoder in the units defined in the parameter.

◆ velocity()

double vex::rotation::velocity ( velocityUnits  units)

Gets the current velocity of the absolute encoder.

Parameters
unitsThe measurement unit for the velocity.
Returns
a double that represents the current velocity of the encoder in the units defined in the parameter.

◆ status()

int32_t vex::rotation::status ( )
protected