|
libstp
Robotics library for Botball
|
#include <IRSensor.hpp>
Public Member Functions | |
| IRSensor (const int &port) | |
| bool | isCalibrated () const |
| bool | calibrate (const std::vector< float > &values) |
| void | setCalibration (float newBlackThreshold, float newWhiteThreshold) |
| bool | isOnWhite () const |
| virtual bool | isOnBlack () |
| float | probabilityOfBlack () const |
| float | probabilityOfWhite () const |
| Public Member Functions inherited from libstp::hal::analog::AnalogSensor | |
| AnalogSensor (int port) | |
| Create an analog sensor bound to a platform-defined port index. | |
| virtual | ~AnalogSensor () |
| virtual int | read () const |
| Read the current raw analog value from the selected platform. | |
Static Public Member Functions | |
| static float | mean (const std::vector< float > &v) |
| static float | stddev (const std::vector< float > &v) |
| static float | variance (const std::vector< float > &v, float m) |
Public Attributes | |
| float | whiteThreshold |
| float | blackThreshold |
| float | whiteMean = 0.0f |
| float | blackMean = 0.0f |
| float | whiteStdDev = 1.0f |
| float | blackStdDev = 1.0f |
| Public Attributes inherited from libstp::hal::analog::AnalogSensor | |
| int | port |
Reflectance sensor with black/white threshold classification helpers.
The class extends the generic HAL analog sensor with calibration state derived from observed black and white samples.
Definition at line 19 of file IRSensor.hpp.
|
explicit |
Construct an IR sensor on port.
On construction the sensor automatically applies any stored calibration for its port from the process-wide CalibrationStore (set "default_port<port>"). When no stored calibration is found the sensor stays uncalibrated and any black/white query will throw until it is calibrated.
| bool libstp::sensors::ir::IRSensor::calibrate | ( | const std::vector< float > & | values | ) |
Update thresholds and distribution statistics from raw readings.
|
nodiscard |
Return true once thresholds have been established (stored, loaded or live).
|
virtual |
Return true when the current reading is classified as black.
| bool libstp::sensors::ir::IRSensor::isOnWhite | ( | ) | const |
Return true when the current reading is classified as white.
|
static |
Compute the arithmetic mean of a sample set.
| float libstp::sensors::ir::IRSensor::probabilityOfBlack | ( | ) | const |
Estimate how likely the current reading belongs to the black cluster.
| float libstp::sensors::ir::IRSensor::probabilityOfWhite | ( | ) | const |
Estimate how likely the current reading belongs to the white cluster.
| void libstp::sensors::ir::IRSensor::setCalibration | ( | float | newBlackThreshold, |
| float | newWhiteThreshold ) |
Replace the classification thresholds without recomputing sample statistics.
|
static |
Compute the sample standard deviation of a sample set.
|
static |
Compute the variance of a sample set around a known mean.
| float libstp::sensors::ir::IRSensor::blackMean = 0.0f |
Definition at line 25 of file IRSensor.hpp.
| float libstp::sensors::ir::IRSensor::blackStdDev = 1.0f |
Definition at line 27 of file IRSensor.hpp.
| float libstp::sensors::ir::IRSensor::blackThreshold |
Definition at line 23 of file IRSensor.hpp.
| float libstp::sensors::ir::IRSensor::whiteMean = 0.0f |
Definition at line 24 of file IRSensor.hpp.
| float libstp::sensors::ir::IRSensor::whiteStdDev = 1.0f |
Definition at line 26 of file IRSensor.hpp.
| float libstp::sensors::ir::IRSensor::whiteThreshold |
Definition at line 22 of file IRSensor.hpp.