Smartcar Shield
 All Classes Namespaces Files Functions Variables Macros
Public Member Functions | List of all members
SmartCar Class Reference

A class to programmatically represent a vehicle equipped with odometers and a heading sensor. More...

#include <SmartCar.hpp>

Inheritance diagram for SmartCar:
Inheritance graph
Collaboration diagram for SmartCar:
Collaboration graph

Public Member Functions

 SmartCar (Control &control, HeadingSensor &headingSensor, Odometer &odometer, Runtime &runtime)
 
 SmartCar (Control &control, HeadingSensor &headingSensor, Odometer &odometerLeft, Odometer &odometerRight, Runtime &runtime)
 
virtual void update () override
 Adjusts the speed when cruise control is enabled and calculates the current heading. More...
 
- Public Member Functions inherited from DistanceCar
 DistanceCar (Control &control, Odometer &odometer, Runtime &runtime)
 
 DistanceCar (Control &control, Odometer &odometerLeft, Odometer &odometerRight, Runtime &runtime)
 
long getDistance ()
 Gets the car's travelled distance. More...
 
virtual 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...
 
virtual 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...
 
virtual ~SimpleCar ()=default
 
virtual void setAngle (int angle) override
 Set the car's driving angle. 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...
 
unsigned int getHeading ()
 Returns the car's current heading in degrees [0, 360) More...
 

Detailed Description

A class to programmatically represent a vehicle equipped with odometers and a heading sensor.

Examples:
automatedMovements.ino, and SmartCar.ino.

Definition at line 16 of file SmartCar.hpp.

Constructor & Destructor Documentation

SmartCar::SmartCar ( Control control,
HeadingSensor headingSensor,
Odometer odometer,
Runtime runtime 
)

Definition at line 3 of file SmartCar.cpp.

SmartCar::SmartCar ( Control control,
HeadingSensor headingSensor,
Odometer odometerLeft,
Odometer odometerRight,
Runtime runtime 
)

Definition at line 13 of file SmartCar.cpp.

Member Function Documentation

void SmartCar::update ( )
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:

void loop() {
// Update the car readings as often as possible
car.update();
// Other functionality
}

Reimplemented from DistanceCar.

Definition at line 24 of file SmartCar.cpp.

Here is the call graph for this function:


The documentation for this class was generated from the following files: