|
Fang-Robotics-MCB
Fang Robotics Team Codebase
|
#include <analog_distance_sensor.hpp>


Public Member Functions | |
| AnalogDistanceSensor (Drivers *drivers, float minDistance, float maxDistance, float m, float b, float offset, gpio::Analog::Pin pin) | |
| float | read () override |
| bool | validReading () const override |
Public Member Functions inherited from tap::sensors::DistanceSensor | |
| DistanceSensor (float minDistance, float maxDistance) | |
| virtual | ~DistanceSensor ()=default |
| virtual void | init ()=0 |
| float | getMinDistance () const |
| float | getMaxDistance () const |
| float | getDistance () const |
Additional Inherited Members | |
Protected Attributes inherited from tap::sensors::DistanceSensor | |
| float | distance |
| Distance from sensor. | |
| float | minDistance |
| Lower boundary for reliable readings. | |
| float | maxDistance |
| Upper boundary for reliable readings. | |
Basic analog IR Sensor.
See here (https://i.stack.imgur.com/babQg.png) for a graph of what an IR sensor should look like. Datasheets will have specifics for what the distance curve should look like. Thsi class gives a general curve fit that first calculates a linear fit from the raw voltage of the form
and then the output is put into the equation
.
| tap::sensors::AnalogDistanceSensor::AnalogDistanceSensor | ( | Drivers * | drivers, |
| float | minDistance, | ||
| float | maxDistance, | ||
| float | m, | ||
| float | b, | ||
| float | offset, | ||
| gpio::Analog::Pin | pin | ||
| ) |
Constructor to initialize the analog IR boundary, distance conversion, and analog pin.
| [in] | minDistance | the sensor's min valid distance |
| [in] | maxDistance | the sensor's max valid distance |
| [in] | m | the slope of the linear model that describes the relationship between analog input and distance. |
| [in] | b | the y intercept of the linear model that describes the relationship between analog input and distance. |
| [in] | offset | the offset in the non-linear portion of the model. |
| [in] | pin | the analog pin that the sensor is connected to. |
|
overridevirtual |
Reads the sensor, updates the current distance, and returns this reading.
Implements tap::sensors::DistanceSensor.
|
overridevirtual |
Checks if current reading is within bounds.
true if the reading is within the min and max distance, exclusive. Returns false otherwise. Implements tap::sensors::DistanceSensor.