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

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

#include <HeadingCar.hpp>

Inheritance diagram for HeadingCar:
Inheritance graph
Collaboration diagram for HeadingCar:
Collaboration graph

Public Member Functions

 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...
 
virtual void update ()
 Updates the readings from the heading sensor. More...
 
- Public Member Functions inherited from SimpleCar
 SimpleCar (Control &control)
 Constructs a simple car. More...
 
virtual ~SimpleCar ()=default
 
virtual 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...
 
virtual void setAngle (int angle) override
 Set the car's driving angle. More...
 
virtual 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
 

Detailed Description

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

Examples:
HeadingCar.ino, and rotateOnSpot.ino.

Definition at line 10 of file HeadingCar.hpp.

Constructor & Destructor Documentation

HeadingCar::HeadingCar ( Control control,
HeadingSensor headingSensor 
)

Constructs a car equipped with a heading sensor.

Parameters
controlThe car's control
headingSensorThe heading sensor

Example:

const int GYROSCOPE_OFFSET = 37;
BrushedMotor leftMotor(8, 10, 9);
BrushedMotor rightMotor(12, 13, 11);
DifferentialControl control(leftMotor, rightMotor);
GY50 gyroscope(GYROSCOPE_OFFSET);

Definition at line 3 of file HeadingCar.cpp.

Member Function Documentation

unsigned int HeadingCar::getHeading ( )

Returns the car's current heading in degrees [0, 360)

Returns
The car's current heading in degrees

Example:

unsigned int currentHeading = gyroscope.getHeading();

Definition at line 9 of file HeadingCar.cpp.

Here is the call graph for this function:

void HeadingCar::update ( )
virtual

Updates the readings from the heading sensor.

You must have this being executed as often as possible to get accurate heading readings.

Example:

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

Reimplemented in SmartCar.

Definition at line 14 of file HeadingCar.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:


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