Smartcar Shield
|
#include <DirectionalOdometer.hpp>
Public Member Functions | |
DirectionalOdometer (Runtime &runtime, uint8_t pulsePin, uint8_t forwardWhenLowPin, InterruptCallback callback, unsigned long pulsesPerMeter) | |
Constructs an odometer that can measure distance, speed and direction. More... | |
DirectionalOdometer (Runtime &runtime, DirectionalOdometerPins pins, InterruptCallback callback, unsigned long pulsesPerMeter) | |
Constructs an odometer that can measure distance, speed and direction. More... | |
void | reset () override |
Resets the total travelled distance and speed to 0 More... | |
void | update () override |
Conducts the distance and speed measurements. More... | |
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 | providesDirection () const override |
Return whether the sensor is capable of inferring the direction of movement. More... | |
int8_t | getDirection () const |
Get the direction of movement. More... | |
Public Member Functions inherited from DirectionlessOdometer | |
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... | |
Public Member Functions inherited from Odometer | |
virtual | ~Odometer ()=default |
Additional Inherited Members | |
Protected Attributes inherited from DirectionlessOdometer | |
const float | mPulsesPerMeterRatio |
volatile unsigned long | mPulsesCounter { 0 } |
volatile unsigned long | mPreviousPulse { 0 } |
volatile unsigned long | mDt { 0 } |
A class to represent directional Odometers. These sensors typically expose three signals lines, as opposed to two in the directionless counterparts. Depending on the state of this third signal, the direction of movement can be inferred.
Definition at line 32 of file DirectionalOdometer.hpp.
DirectionalOdometer::DirectionalOdometer | ( | Runtime & | runtime, |
uint8_t | pulsePin, | ||
uint8_t | forwardWhenLowPin, | ||
InterruptCallback | callback, | ||
unsigned long | pulsesPerMeter | ||
) |
Constructs an odometer that can measure distance, speed and direction.
runtime | The runtime environment you want to run the class for |
pulsePin | The pin that receives the pulses |
forwardWhenLowPin | The pin that is set to LOW when moving forward |
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 12 of file DirectionalOdometer.cpp.
DirectionalOdometer::DirectionalOdometer | ( | Runtime & | runtime, |
DirectionalOdometerPins | pins, | ||
InterruptCallback | callback, | ||
unsigned long | pulsesPerMeter | ||
) |
Constructs an odometer that can measure distance, speed and direction.
pins | The DirectionalOdometerPins object with the pins of the odometer |
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 26 of file DirectionalOdometer.cpp.
int8_t DirectionalOdometer::getDirection | ( | ) | const |
Get the direction of movement.
1
if travelling forward -1
if travelling backwardExample:
Definition at line 83 of file DirectionalOdometer.cpp.
|
overridevirtual |
Returns the travelled distance in centimeters where sign can indicate direction if there is hardware support.
Example:
Implements Odometer.
Definition at line 72 of file DirectionalOdometer.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 78 of file DirectionalOdometer.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 89 of file DirectionalOdometer.cpp.
|
overridevirtual |
Resets the total travelled distance and speed to 0
Reimplemented from DirectionlessOdometer.
Definition at line 34 of file DirectionalOdometer.cpp.
|
overridevirtual |
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 from DirectionlessOdometer.
Definition at line 40 of file DirectionalOdometer.cpp.