EEEN21000
GROUP 30 Line Following Buggy
Loading...
Searching...
No Matches
Sensor Class Reference

Sensor class to handle the sensor readings. More...

#include <sensor.h>

Public Member Functions

 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 Public Attributes

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...
 

Private Attributes

BusOut m_pins
 Array of sensors DigitalOut. More...
 
std::array< AnalogIn, 6 > m_analog
 Array of sensors AnalogIn. More...
 
std::array< float, 6 > m_reading {}
 Array of sensors readings. More...
 
std::array< float, 6 > m_noise {}
 Array of sensors noise. More...
 
float m_distance {0}
 Sensor position. More...
 
int m_notrackcounter {0}
 No track counter. More...
 

Detailed Description

Sensor class to handle the sensor readings.

This class handles the sensor readings and provides the data in terms of position from white line.

Constructor & Destructor Documentation

◆ 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,p6Array of sensors DigitalOut.
in1,in2,in3,in4,in5,in6Array of sensors AnalogIn.

Member Function Documentation

◆ read()

float Sensor::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.

Member Data Documentation

◆ m_pins

BusOut Sensor::m_pins
private

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

Array of sensors noise.

◆ m_distance

float Sensor::m_distance {0}
private

Sensor position.

◆ m_notrackcounter

int Sensor::m_notrackcounter {0}
private

No track counter.

◆ 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

bool Sensor::s_run
static

Debugging flag for printing headers.


The documentation for this class was generated from the following file: