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

#include <adiUltrasonic.hpp>

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

Public Member Functions

 ADIUltrasonic (std::uint8_t iportPing, std::uint8_t iportEcho, std::unique_ptr< Filter > ifilter=std::make_unique< PassthroughFilter >())
 An ultrasonic sensor in the ADI (3-wire) ports.
 
 ADIUltrasonic (std::tuple< std::uint8_t, std::uint8_t, std::uint8_t > iports, std::unique_ptr< Filter > ifilter=std::make_unique< PassthroughFilter >())
 An ultrasonic sensor in the ADI (3-wire) ports.
 
virtual ~ADIUltrasonic ()
 
virtual double get ()
 Returns the current filtered sensor value.
 
virtual double controllerGet () override
 Get the sensor value for use in a control loop.
 

Protected Attributes

pros::c::ext_adi_ultrasonic_t ultra
 
std::unique_ptr< Filterfilter
 

Detailed Description

Definition at line 14 of file adiUltrasonic.hpp.

Constructor & Destructor Documentation

◆ ADIUltrasonic() [1/2]

okapi::ADIUltrasonic::ADIUltrasonic ( std::uint8_t  iportPing,
std::uint8_t  iportEcho,
std::unique_ptr< Filter ifilter = std::make_unique< PassthroughFilter >() 
)

An ultrasonic sensor in the ADI (3-wire) ports.

auto ultra = ADIUltrasonic('A', 'B');
auto filteredUltra = ADIUltrasonic('A', 'B', std::make_unique<MedianFilter<5>>());
pros::c::ext_adi_ultrasonic_t ultra
A filter which returns the median value of list of values.
Parameters
iportPingThe port connected to the orange OUTPUT cable. This must be in port 1, 3, 5, or 7 (A, C, E, or G).
iportEchoThe port connected to the yellow INPUT cable. This must be in the next highest port following iportPing.
ifilterThe filter to use for filtering the distance measurements.

◆ ADIUltrasonic() [2/2]

okapi::ADIUltrasonic::ADIUltrasonic ( std::tuple< std::uint8_t, std::uint8_t, std::uint8_t >  iports,
std::unique_ptr< Filter ifilter = std::make_unique< PassthroughFilter >() 
)

An ultrasonic sensor in the ADI (3-wire) ports.

auto ultra = ADIUltrasonic({1, 'A', 'B'});
auto filteredUltra = ADIUltrasonic({1, 'A', 'B'}, std::make_unique<MedianFilter<5>>());
Parameters
iportsThe ports the ultrasonic is plugged in to in the order {smart port, ping port, echo port}. The smart port is the smart port number ([1, 21]). The ping port is the port connected to the orange OUTPUT cable. This must be in port 1, 3, 5, or 7 (A, C, E, or G). The echo port is the port connected to the yellow INPUT cable. This must be in the next highest port following the ping port.
ifilterThe filter to use for filtering the distance measurements.

◆ ~ADIUltrasonic()

virtual okapi::ADIUltrasonic::~ADIUltrasonic ( )
virtual

Member Function Documentation

◆ controllerGet()

virtual double okapi::ADIUltrasonic::controllerGet ( )
overridevirtual

Get the sensor value for use in a control loop.

This method might be automatically called in another thread by the controller. Calls get().

Implements okapi::ControllerInput< double >.

◆ get()

virtual double okapi::ADIUltrasonic::get ( )
virtual

Returns the current filtered sensor value.

Returns
current value

Member Data Documentation

◆ filter

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

Definition at line 69 of file adiUltrasonic.hpp.

◆ ultra

pros::c::ext_adi_ultrasonic_t okapi::ADIUltrasonic::ultra
protected

Definition at line 68 of file adiUltrasonic.hpp.


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