VEXcode Doxygen
Public Member Functions | List of all members
vex::distance Class Reference

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

#include <vex_distance.h>

Inheritance diagram for vex::distance:
vex::device

Public Member Functions

 distance (int32_t index)
 Creates a new distance sensor object on the port specified. More...
 
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...
 
void changed (void(*callback)(void))
 Calls a function when the distance value changes. More...
 
- Public Member Functions inherited from vex::device
 device (int32_t index)
 
V5_DeviceType type ()
 
int32_t index ()
 
void init (int32_t index)
 
uint32_t timestamp ()
 

Additional Inherited Members

- Protected Attributes inherited from vex::device
int32_t _index
 
int32_t _threadID
 

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.

Member Function Documentation

◆ changed()

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

Calls a function when the distance value changes.

Parameters
callbackA reference to a function.

◆ isObjectDetected()

bool vex::distance::isObjectDetected ( void  )

check for object in range of the distance sensor

Returns
Returns true if an object is detected

◆ objectDistance()

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

Gets the detected object distance.

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

◆ objectRawSize()

int32_t vex::distance::objectRawSize ( void  )

Gets an estimate of the detected object size.

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

◆ objectSize()

sizeType vex::distance::objectSize ( void  )

Gets an estimate of the detected object size.

Returns
Returns the estimated object size

◆ objectVelocity()

double vex::distance::objectVelocity ( void  )

Gets an estimate of the detected object velocity.

Returns
Returns a double with object velocity in m/s

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