Smartcar Shield
|
#include <DirectionlessOdometer.hpp>
Public Member Functions | |
DirectionlessOdometer (Runtime &runtime, uint8_t pulsePin, InterruptCallback callback, unsigned long pulsesPerMeter) | |
Constructs an odometer that can measure distance, speed but not direction. More... | |
~DirectionlessOdometer () override=default | |
long | getDistance () override |
Returns the travelled distance in centimeters where sign can indicate direction if there is hardware support. More... | |
float | getSpeed () override |
Returns the current speed in meters/sec where sign can indicate direction if there is hardware support. More... | |
bool | isAttached () const override |
Returns whether the sensor has been properly attached. More... | |
bool | providesDirection () const override |
Return whether the sensor is capable of inferring the direction of movement. More... | |
virtual void | reset () |
Resets the total travelled distance and speed to 0 More... | |
virtual void | update () |
Conducts the distance and speed measurements. More... | |
Public Member Functions inherited from Odometer | |
virtual | ~Odometer ()=default |
Protected Attributes | |
const float | mPulsesPerMeterRatio |
volatile unsigned long | mPulsesCounter { 0 } |
volatile unsigned long | mPreviousPulse { 0 } |
volatile unsigned long | mDt { 0 } |
A class to represent the common - directionless - Odometers (speed encoders) that can be used to primarily measure the travelled distance of the car as well as its speed.
Definition at line 14 of file DirectionlessOdometer.hpp.
DirectionlessOdometer::DirectionlessOdometer | ( | Runtime & | runtime, |
uint8_t | pulsePin, | ||
InterruptCallback | callback, | ||
unsigned long | pulsesPerMeter | ||
) |
Constructs an odometer that can measure distance, speed but not direction.
runtime | The runtime environment you want to run the class for |
pulsePin | The pin that receives the pulses |
callback | The callback to be invoked when a pulse is received (see example) |
pulsesPerMeter | The amount of odometer pulses that constitute a meter |
Example:
Definition at line 14 of file DirectionlessOdometer.cpp.
|
overridedefault |
|
overridevirtual |
Returns the travelled distance in centimeters where sign can indicate direction if there is hardware support.
Example:
Implements Odometer.
Definition at line 32 of file DirectionlessOdometer.cpp.
|
overridevirtual |
Returns the current speed in meters/sec where sign can indicate direction if there is hardware support.
Example:
Implements Odometer.
Definition at line 37 of file DirectionlessOdometer.cpp.
|
overridevirtual |
Returns whether the sensor has been properly attached.
Implements Odometer.
Definition at line 44 of file DirectionlessOdometer.cpp.
|
overridevirtual |
Return whether the sensor is capable of inferring the direction of movement.
true
if the sensor supports direction readings otherwise false
Example:
Implements Odometer.
Definition at line 77 of file DirectionlessOdometer.cpp.
|
virtual |
Resets the total travelled distance and speed to 0
Reimplemented in DirectionalOdometer.
Definition at line 49 of file DirectionlessOdometer.cpp.
|
virtual |
Conducts the distance and speed measurements.
Updates the current dt with the time difference between the last two pulses and increases the pulse counter. Do not call it directly in your sketch! Instead, pass it in a lambda to the constructor.
Reimplemented in DirectionalOdometer.
Definition at line 56 of file DirectionlessOdometer.cpp.
|
protected |
Definition at line 74 of file DirectionlessOdometer.hpp.
|
protected |
Definition at line 73 of file DirectionlessOdometer.hpp.
|
protected |
Definition at line 72 of file DirectionlessOdometer.hpp.
|
protected |
Definition at line 71 of file DirectionlessOdometer.hpp.