Sensor class to handle the sensor readings.
More...
#include <sensor.h>
|
| Sensor (PinName p1, PinName p2, PinName p3, PinName p4, PinName p5, PinName p6, PinName in1, PinName in2, PinName in3, PinName in4, PinName in5, PinName in6) |
| Constructor. More...
|
|
float | read () |
| Read the sensor values. More...
|
|
float | getDistance () const |
| Get the distance. More...
|
|
int | getNoTrackCounter () const |
| Get the no track counter value. More...
|
|
void | calibrateBlack () |
| Calibrate the sensors on black area of the track. More...
|
|
void | calibrateWhite () |
| Calibrate the sensors on white area of the track. More...
|
|
|
static std::array< float, 6 > | WEIGHTS |
| Array of constant weights for sensors. More...
|
|
static std::array< float, 6 > | BLACK_TRESHOLD |
| Array of constant black threshold for sensors. More...
|
|
static std::array< float, 6 > | SCALE_FACTOR |
| Array of constant scale factor for sensors. More...
|
|
static bool | s_run |
| Debugging flag for printing headers. More...
|
|
Sensor class to handle the sensor readings.
This class handles the sensor readings and provides the data in terms of position from white line.
◆ Sensor()
Sensor::Sensor |
( |
PinName |
p1, |
|
|
PinName |
p2, |
|
|
PinName |
p3, |
|
|
PinName |
p4, |
|
|
PinName |
p5, |
|
|
PinName |
p6, |
|
|
PinName |
in1, |
|
|
PinName |
in2, |
|
|
PinName |
in3, |
|
|
PinName |
in4, |
|
|
PinName |
in5, |
|
|
PinName |
in6 |
|
) |
| |
Constructor.
Construct a new Sensor object.
- Parameters
-
p1,p2,p3,p4,p5,p6 | Array of sensors DigitalOut. |
in1,in2,in3,in4,in5,in6 | Array of sensors AnalogIn. |
◆ read()
Read the sensor values.
Read the sensor values and normalise them.
◆ getDistance()
float Sensor::getDistance |
( |
| ) |
const |
Get the distance.
Get the distance from the center line.
- Returns
- float Distance from the center line.
◆ getNoTrackCounter()
int Sensor::getNoTrackCounter |
( |
| ) |
const |
Get the no track counter value.
- Returns
- int m_no_track_counter
◆ calibrateBlack()
void Sensor::calibrateBlack |
( |
| ) |
|
Calibrate the sensors on black area of the track.
◆ calibrateWhite()
void Sensor::calibrateWhite |
( |
| ) |
|
Calibrate the sensors on white area of the track.
◆ m_pins
Array of sensors DigitalOut.
◆ m_analog
std::array<AnalogIn, 6> Sensor::m_analog |
|
private |
Array of sensors AnalogIn.
◆ m_reading
std::array<float, 6> Sensor::m_reading {} |
|
private |
Array of sensors readings.
◆ m_noise
std::array<float, 6> Sensor::m_noise {} |
|
private |
◆ m_distance
float Sensor::m_distance {0} |
|
private |
◆ m_notrackcounter
int Sensor::m_notrackcounter {0} |
|
private |
◆ WEIGHTS
std::array<float, 6> Sensor::WEIGHTS |
|
static |
Array of constant weights for sensors.
◆ BLACK_TRESHOLD
std::array<float, 6> Sensor::BLACK_TRESHOLD |
|
static |
Array of constant black threshold for sensors.
◆ SCALE_FACTOR
std::array<float, 6> Sensor::SCALE_FACTOR |
|
static |
Array of constant scale factor for sensors.
◆ s_run
Debugging flag for printing headers.
The documentation for this class was generated from the following file:
- /github/workspace/include/sensor/sensor.h