Smartcar Shield
|
#include <SmartCar.hpp>
Public Member Functions | |
SmartCar (Runtime &runtime, Control &control, HeadingSensor &headingSensor, Odometer &odometer) | |
Constructs a car equipped with a heading sensor and an odometer. More... | |
SmartCar (Runtime &runtime, Control &control, HeadingSensor &headingSensor, Odometer &odometerLeft, Odometer &odometerRight) | |
Constructs a car equipped with a heading sensor and two odometers. More... | |
void | update () override |
Adjusts the speed when cruise control is enabled and calculates the current heading. 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... | |
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... | |
Public Member Functions inherited from DistanceCar | |
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... | |
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 |
Public Member Functions inherited from HeadingCar | |
HeadingCar (Control &control, HeadingSensor &headingSensor) | |
Constructs a car equipped with a heading sensor. More... | |
int | getHeading () |
Returns the car's current heading in degrees [0, 360) More... | |
A class to programmatically represent a vehicle equipped with odometers and a heading sensor
Definition at line 11 of file SmartCar.hpp.
SmartCar::SmartCar | ( | Runtime & | runtime, |
Control & | control, | ||
HeadingSensor & | headingSensor, | ||
Odometer & | odometer | ||
) |
Constructs a car equipped with a heading sensor and an odometer.
runtime | The runtime environment you want to run the class for |
control | The car's control |
headingSensor | The heading sensor |
odometer | The odometer |
Example:
Definition at line 3 of file SmartCar.cpp.
SmartCar::SmartCar | ( | Runtime & | runtime, |
Control & | control, | ||
HeadingSensor & | headingSensor, | ||
Odometer & | odometerLeft, | ||
Odometer & | odometerRight | ||
) |
Constructs a car equipped with a heading sensor and two odometers.
runtime | The runtime environment you want to run the class for |
control | The car's control |
headingSensor | The heading sensor |
odometerLeft | The left odometer |
odometerRight | The right odometer |
Example:
Definition at line 13 of file SmartCar.cpp.
|
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.
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:
Definition at line 210 of file DistanceCar.cpp.
|
override |
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):
Definition at line 42 of file DistanceCar.cpp.
|
overridevirtual |
Adjusts the speed when cruise control is enabled and calculates the current heading.
You must have this being executed as often as possible for highest accuracy of heading calculations and cruise control.
Example:
Reimplemented from DistanceCar.
Definition at line 24 of file SmartCar.cpp.