Smartcar Shield
|
#include <DistanceCar.hpp>
Public Member Functions | |
DistanceCar (Runtime &runtime, Control &control, Odometer &odometer) | |
Constructs a car equipped with a distance sensor. More... | |
DistanceCar (Runtime &runtime, Control &control, Odometer &odometerLeft, Odometer &odometerRight) | |
Constructs a car equipped with a distance sensor. More... | |
long | getDistance () |
Gets the car's travelled distance. More... | |
void | setSpeed (float speed) override |
Sets the car's speed in meters per second if cruise control is enabled otherwise as a percentage of the motor speed. More... | |
float | getSpeed () |
Gets the car's current speed in meters per second. More... | |
void | enableCruiseControl (float proportional=smartcarlib::constants::car::kDefaultProportional, float integral=smartcarlib::constants::car::kDefaultIntegral, float derivative=smartcarlib::constants::car::kDefaultDerivative, unsigned long frequency=smartcarlib::constants::car::kDefaultPidFrequency) |
Enables the car to move with a stable speed using the odometers. More... | |
virtual void | update () |
Adjusts the cruise control speed. More... | |
void | disableCruiseControl () |
Disable cruise control. More... | |
void | overrideMotorSpeed (int firstMotorSpeed, int secondMotorSpeed) override |
Sets the motor speed individually as a percentage of the motors` total power unless cruise control is enabled in which case has no effect. More... | |
Public Member Functions inherited from SimpleCar | |
SimpleCar (Control &control) | |
Constructs a simple car. More... | |
void | setSpeed (float speed) override |
Sets the car's driving speed as a percentage of the motors total speed where the sign indicates direction. More... | |
void | setAngle (int angle) override |
Set the car's driving angle. More... | |
void | overrideMotorSpeed (int firstMotorSpeed, int secondMotorSpeed) override |
Set the motor speed individually as a percentage of the motors` total power. More... | |
Public Member Functions inherited from Car | |
virtual | ~Car ()=default |
A class to programmatically represent a vehicle equipped with odometers
Definition at line 27 of file DistanceCar.hpp.
Constructs a car equipped with a distance sensor.
runtime | The runtime environment you want to run the class for |
control | The car's control |
odometer | The odometer |
Example:
Definition at line 17 of file DistanceCar.cpp.
DistanceCar::DistanceCar | ( | Runtime & | runtime, |
Control & | control, | ||
Odometer & | odometerLeft, | ||
Odometer & | odometerRight | ||
) |
Constructs a car equipped with a distance sensor.
runtime | The runtime environment you want to run the class for |
control | The car's control |
odometerLeft | The left odometer |
odometerRight | The right odometer |
Example:
Definition at line 25 of file DistanceCar.cpp.
void DistanceCar::disableCruiseControl | ( | ) |
Disable cruise control.
Example:
Definition at line 183 of file DistanceCar.cpp.
void DistanceCar::enableCruiseControl | ( | float | proportional = smartcarlib::constants::car::kDefaultProportional , |
float | integral = smartcarlib::constants::car::kDefaultIntegral , |
||
float | derivative = smartcarlib::constants::car::kDefaultDerivative , |
||
unsigned long | frequency = smartcarlib::constants::car::kDefaultPidFrequency |
||
) |
Enables the car to move with a stable speed using the odometers.
proportional | The proportional value of the PID controller |
integral | The integral value of the PID controller |
derivative | The derivative value of the PID controller |
frequency | How often to adjust the speed using update() |
Example:
Definition at line 188 of file DistanceCar.cpp.
long DistanceCar::getDistance | ( | ) |
Gets the car's travelled distance.
Example:
Definition at line 36 of file DistanceCar.cpp.
float DistanceCar::getSpeed | ( | ) |
Gets the car's current speed in meters per second.
Example:
Definition at line 177 of file DistanceCar.cpp.
|
overridevirtual |
Sets the motor speed individually as a percentage of the motors` total power unless cruise control is enabled in which case has no effect.
Use with caution.
firstMotorSpeed | The speed of the motor passed as first argument argument to the car's control class [-100, 100] |
secondMotorSpeed | The speed of the motor passed as second argument argument to the car's control class [-100, 100] |
Example:
Implements Car.
Definition at line 210 of file DistanceCar.cpp.
|
overridevirtual |
Sets the car's speed in meters per second if cruise control is enabled otherwise as a percentage of the motor speed.
Sign in both cases determines direction.
speed | The car's speed |
Example (with cruise control):
Example (without cruise control):
Implements Car.
Definition at line 42 of file DistanceCar.cpp.
|
virtual |
Adjusts the cruise control speed.
You must have this being executed as often as possible when having cruise control enabled. When cruise control is not enabled this has no effect.
Example:
Reimplemented in SmartCar.
Definition at line 112 of file DistanceCar.cpp.