Smartcar Shield
Public Member Functions | List of all members
HeadingCar Class Reference

#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...
 
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...
 
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
 

Detailed Description

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

Definition at line 10 of file HeadingCar.hpp.

Constructor & Destructor Documentation

◆ HeadingCar()

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;
DifferentialControl control(leftMotor, rightMotor);
GY50 gyroscope(GYROSCOPE_OFFSET);

Definition at line 3 of file HeadingCar.cpp.

Member Function Documentation

◆ getHeading()

int HeadingCar::getHeading ( )

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

Returns
The car's current heading in degrees

Example:

auto currentHeading = gyroscope.getHeading();

Definition at line 9 of file HeadingCar.cpp.

Here is the call graph for this function:

◆ update()

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:
smartcarlib::pins::v2::leftMotorPins
const BrushedMotorPins leftMotorPins
Definition: Smartcar.h:50
BrushedMotor
Definition: BrushedMotor.hpp:41
GY50
Definition: GY50.hpp:33
DifferentialControl
Definition: DifferentialControl.hpp:11
smartcarlib::pins::v2::rightMotorPins
const BrushedMotorPins rightMotorPins
Definition: Smartcar.h:51