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

Use the distance class to control the distance sensor. More...

Inherits vex::device.

Public Member Functions

 distance (int32_t index)
 Creates a new distance sensor object on the port specified. More...
 
 ~distance ()
 
bool installed ()
 
int32_t value ()
 
double objectDistance (distanceUnits units)
 Gets the detected object distance. More...
 
sizeType objectSize (void)
 Gets an estimate of the detected object size. More...
 
int32_t objectRawSize (void)
 Gets an estimate of the detected object size. More...
 
double objectVelocity (void)
 Gets an estimate of the detected object velocity. More...
 
bool isObjectDetected (void)
 Check for object in range of the distance sensor. More...
 
- Public Member Functions inherited from vex::device
 device ()
 
 device (int32_t index)
 
 ~device ()
 
V5_DeviceType type ()
 
void init (int32_t index)
 

Additional Inherited Members

- Protected Attributes inherited from vex::device
int32_t _index
 

Detailed Description

Use the distance class to control the distance sensor.

Constructor & Destructor Documentation

◆ distance()

vex::distance::distance ( int32_t  index)

Creates a new distance sensor object on the port specified.

Parameters
indexThe port index for this sensor. The index is zero-based.

◆ ~distance()

vex::distance::~distance ( )

Member Function Documentation

◆ installed()

bool vex::distance::installed ( )
virtual

Reimplemented from vex::device.

◆ value()

int32_t vex::distance::value ( )
virtual

Reimplemented from vex::device.

◆ objectDistance()

double vex::distance::objectDistance ( distanceUnits  units)

Gets the detected object distance.

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

◆ objectSize()

sizeType vex::distance::objectSize ( void  )

Gets an estimate of the detected object size.

Returns
the estimated object size

◆ objectRawSize()

int32_t vex::distance::objectRawSize ( void  )

Gets an estimate of the detected object size.

Returns
an integer that represent a relative object size, 0 to 400

◆ objectVelocity()

double vex::distance::objectVelocity ( void  )

Gets an estimate of the detected object velocity.

Returns
a double with object velocity in m/s

◆ isObjectDetected()

bool vex::distance::isObjectDetected ( void  )

Check for object in range of the distance sensor.

Returns
true if an object is detected