|
Smartcar Shield
|
A class to programmatically represent a vehicle equipped with odometers and a heading sensor. More...
#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. | |
| SmartCar (Runtime &runtime, Control &control, HeadingSensor &headingSensor, Odometer &odometerLeft, Odometer &odometerRight) | |
| Constructs a car equipped with a heading sensor and two odometers. | |
| void | update () override |
| Adjusts the speed when cruise control is enabled and calculates the current heading. | |
| 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. | |
| 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. | |
Public Member Functions inherited from DistanceCar | |
| DistanceCar (Runtime &runtime, Control &control, Odometer &odometer) | |
| Constructs a car equipped with a distance sensor. | |
| DistanceCar (Runtime &runtime, Control &control, Odometer &odometerLeft, Odometer &odometerRight) | |
| Constructs a car equipped with a distance sensor. | |
| long | getDistance () |
| Gets the car's travelled distance. | |
| float | getSpeed () |
| Gets the car's current speed in meters per second. | |
| 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. | |
| void | disableCruiseControl () |
| Disable cruise control. | |
Public Member Functions inherited from SimpleCar | |
| SimpleCar (Control &control) | |
| Constructs a simple car. | |
| void | setAngle (int angle) override |
| Set the car's driving angle. | |
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. | |
| int | getHeading () |
| Returns the car's current heading in degrees [0, 360) | |
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.
|
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:
Reimplemented from DistanceCar.
Definition at line 187 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):
Reimplemented from DistanceCar.
Definition at line 113 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.
