okapi::ADIUltrasonic class

Base classes

template<typename T>
class ControllerInput

Constructors, destructors, conversion operators

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.
~ADIUltrasonic() virtual

Public functions

auto get() -> double virtual
Returns the current filtered sensor value.
auto controllerGet() -> double override
Get the sensor value for use in a control loop.

Protected variables

pros::c::ext_adi_ultrasonic_t ultra
std::unique_ptr<Filter> filter

Function documentation

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.

Parameters
iportPing The port connected to the orange OUTPUT cable. This must be in port 1, 3, 5, or 7 (A, C, E, or G).
iportEcho The port connected to the yellow INPUT cable. This must be in the next highest port following iportPing.
ifilter The filter to use for filtering the distance measurements.
auto ultra = ADIUltrasonic('A', 'B');
auto filteredUltra = ADIUltrasonic('A', 'B', std::make_unique<MedianFilter<5>>());

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.

Parameters
iports The 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.
ifilter The filter to use for filtering the distance measurements.
auto ultra = ADIUltrasonic({1, 'A', 'B'});
auto filteredUltra = ADIUltrasonic({1, 'A', 'B'}, std::make_unique<MedianFilter<5>>());

double okapi::ADIUltrasonic::get() virtual

Returns the current filtered sensor value.

Returns current value

double okapi::ADIUltrasonic::controllerGet() override

Get the sensor value for use in a control loop.

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