LightLib
PROS library for VEX V5: EKF/MCL localization, RAMSETE path following, high-level chassis API
Loading...
Searching...
No Matches
okapi::DistanceSensor Class Reference

#include <distanceSensor.hpp>

Inheritance diagram for okapi::DistanceSensor:
okapi::ControllerInput< double >

Public Member Functions

 DistanceSensor (std::uint8_t iport, std::unique_ptr< Filter > ifilter=std::make_unique< PassthroughFilter >())
 A distance sensor on a V5 port.
 
virtual ~DistanceSensor ()=default
 
double get ()
 Get the current filtered sensor value in mm.
 
double controllerGet () override
 Get the sensor value for use in a control loop.
 
std::int32_t getConfidence () const
 Get the confidence in the distance reading.
 
std::int32_t getObjectSize () const
 Get the current guess at relative object size.
 
double getObjectVelocity () const
 Get the object velocity in m/s.
 

Protected Attributes

std::uint8_t port
 
std::unique_ptr< Filterfilter
 

Detailed Description

Definition at line 14 of file distanceSensor.hpp.

Constructor & Destructor Documentation

◆ DistanceSensor()

okapi::DistanceSensor::DistanceSensor ( std::uint8_t  iport,
std::unique_ptr< Filter ifilter = std::make_unique< PassthroughFilter >() 
)

A distance sensor on a V5 port.

auto ds = DistanceSensor(1);
auto filteredDistSensor = DistanceSensor(1, std::make_unique<MedianFilter<5>>());
A filter which returns the median value of list of values.
Parameters
iportThe V5 port the device uses.
ifilterThe filter to use for filtering the distance measurements.

◆ ~DistanceSensor()

virtual okapi::DistanceSensor::~DistanceSensor ( )
virtualdefault

Member Function Documentation

◆ controllerGet()

double okapi::DistanceSensor::controllerGet ( )
overridevirtual

Get the sensor value for use in a control loop.

This method might be automatically called in another thread by the controller.

Returns
The same as get.

Implements okapi::ControllerInput< double >.

◆ get()

double okapi::DistanceSensor::get ( )

Get the current filtered sensor value in mm.

Returns
The current filtered sensor value in mm.

◆ getConfidence()

std::int32_t okapi::DistanceSensor::getConfidence ( ) const

Get the confidence in the distance reading.

This value has a range of [0, 63]. 63 means high confidence, lower values imply less confidence. Confidence is only available when distance is greater than 200 mm.

Returns
The confidence value in the range [0, 63].

◆ getObjectSize()

std::int32_t okapi::DistanceSensor::getObjectSize ( ) const

Get the current guess at relative object size.

This value has a range of [0, 400]. A 18" x 30" grey card will return a value of approximately 75 in typical room lighting.

Returns
The size value in the range [0, 400] or PROS_ERR if the operation failed, setting errno.

◆ getObjectVelocity()

double okapi::DistanceSensor::getObjectVelocity ( ) const

Get the object velocity in m/s.

Returns
The object velocity in m/s.

Member Data Documentation

◆ filter

std::unique_ptr<Filter> okapi::DistanceSensor::filter
protected

Definition at line 74 of file distanceSensor.hpp.

◆ port

std::uint8_t okapi::DistanceSensor::port
protected

Definition at line 73 of file distanceSensor.hpp.


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