#include <opticalSensor.hpp>
|
| | OpticalSensor (std::uint8_t iport, OpticalSensorOutput ioutput=OpticalSensorOutput::hue, bool idisableGestures=true, std::unique_ptr< Filter > ifilter=std::make_unique< PassthroughFilter >()) |
| | An optical sensor on a V5 port.
|
| |
| virtual | ~OpticalSensor ()=default |
| |
| double | get () |
| | Get the current filtered value of the selected output (configured by the constructor).
|
| |
| double | getHue () const |
| | Get the current hue value in the range [0, 360).
|
| |
| double | getBrightness () const |
| | Get the current brightness value in the range [0, 1].
|
| |
| double | getSaturation () const |
| | Get the current saturation value in the range [0, 1].
|
| |
| int32_t | getLedPWM () const |
| | Get the PWM value of the white LED in the range [0, 100].
|
| |
| int32_t | setLedPWM (std::uint8_t ivalue) const |
| | Set the PWM value of the white LED in the range [0, 100].
|
| |
| int32_t | getProximity () const |
| | Get the current proximity value in the range [0, 255].
|
| |
| pros::c::optical_rgb_s_t | getRGB () const |
| | Get the processed RGBC data from the sensor.
|
| |
| double | controllerGet () override |
| | Get the sensor value for use in a control loop.
|
| |
| int32_t | enableGestures () const |
| | Enable gestures.
|
| |
| int32_t | disableGestures () const |
| | Disable gestures.
|
| |
|
| double | getSelectedOutput () |
| | Gets the output directly from the sensor using the selected output.
|
| |
Definition at line 20 of file opticalSensor.hpp.
◆ OpticalSensor()
An optical sensor on a V5 port.
@ saturation
The color's intensity relative to its brightness.
- Parameters
-
| iport | The V5 port the device uses. |
| ioutput | Which sensor output to return from (okapi::OpticalSensor::get). |
| idisableGestures | Whether to automatically disable the gesture sensor. Typically, the gesture sensor should be disabled unless you are going to use gestures because the optical sensor does not update color information while detecting a gesture. |
| ifilter | The filter to use to filter the sensor output. Only the selected output (via ioutput) is filtered; the other outputs are untouched. |
◆ ~OpticalSensor()
| virtual okapi::OpticalSensor::~OpticalSensor |
( |
| ) |
|
|
virtualdefault |
◆ controllerGet()
| double okapi::OpticalSensor::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 >.
◆ disableGestures()
| int32_t okapi::OpticalSensor::disableGestures |
( |
| ) |
const |
Disable gestures.
- Returns
1 if the operation was successful or PROS_ERR if the operation failed, setting errno.
◆ enableGestures()
| int32_t okapi::OpticalSensor::enableGestures |
( |
| ) |
const |
Enable gestures.
- Returns
1 if the operation was successful or PROS_ERR if the operation failed, setting errno.
◆ get()
| double okapi::OpticalSensor::get |
( |
| ) |
|
Get the current filtered value of the selected output (configured by the constructor).
- Returns
- The current filtered value of the selected output (configured by the constructor).
◆ getBrightness()
| double okapi::OpticalSensor::getBrightness |
( |
| ) |
const |
Get the current brightness value in the range [0, 1].
- Returns
- The current brightness value in the range
[0, 1].
◆ getHue()
| double okapi::OpticalSensor::getHue |
( |
| ) |
const |
Get the current hue value in the range [0, 360).
- Returns
- The current hue value in the range
[0, 360).
◆ getLedPWM()
| int32_t okapi::OpticalSensor::getLedPWM |
( |
| ) |
const |
Get the PWM value of the white LED in the range [0, 100].
- Returns
- The PWM value of the white LED in the range
[0, 100] or PROS_ERR if the operation failed, setting errno.
◆ getProximity()
| int32_t okapi::OpticalSensor::getProximity |
( |
| ) |
const |
Get the current proximity value in the range [0, 255].
This is not available if gestures are being detected.
- Returns
- The current proximity value in the range
[0, 255].
◆ getRGB()
| pros::c::optical_rgb_s_t okapi::OpticalSensor::getRGB |
( |
| ) |
const |
Get the processed RGBC data from the sensor.
- Returns
- The RGBC value if the operation was successful. If the operation failed, all field are set to
PROS_ERR and errno is set.
◆ getSaturation()
| double okapi::OpticalSensor::getSaturation |
( |
| ) |
const |
Get the current saturation value in the range [0, 1].
- Returns
- The current saturation value in the range
[0, 1].
◆ getSelectedOutput()
| double okapi::OpticalSensor::getSelectedOutput |
( |
| ) |
|
|
protected |
Gets the output directly from the sensor using the selected output.
◆ setLedPWM()
| int32_t okapi::OpticalSensor::setLedPWM |
( |
std::uint8_t |
ivalue | ) |
const |
Set the PWM value of the white LED in the range [0, 100].
- Parameters
-
| value | The PWM value in the range [0, 100]. |
- Returns
1 if the operation was successful or PROS_ERR if the operation failed, setting errno.
◆ filter
| std::unique_ptr<Filter> okapi::OpticalSensor::filter |
|
protected |
◆ output
◆ port
| std::uint8_t okapi::OpticalSensor::port |
|
protected |
The documentation for this class was generated from the following file: