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

#include <SimpleCar.hpp>

Inheritance diagram for SimpleCar:
Inheritance graph
Collaboration diagram for SimpleCar:
Collaboration graph

Public Member Functions

 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 very basic vehicle with two motors

Definition at line 10 of file SimpleCar.hpp.

Constructor & Destructor Documentation

◆ SimpleCar()

SimpleCar::SimpleCar ( Control control)

Constructs a simple car.

Parameters
controlThe car's control

Example:

Definition at line 7 of file SimpleCar.cpp.

Member Function Documentation

◆ overrideMotorSpeed()

void SimpleCar::overrideMotorSpeed ( int  firstMotorSpeed,
int  secondMotorSpeed 
)
overridevirtual

Set the motor speed individually as a percentage of the motors` total power.

Use this with caution.

Parameters
firstMotorSpeedThe speed of the motor passed as first argument argument to the car's control class [-100, 100]
secondMotorSpeedThe speed of the motor passed as second argument argument to the car's control class [-100, 100]

Example:

car.overrideMotorSpeed(100, -100); // Make the car spin around clockwise

Implements Car.

Definition at line 22 of file SimpleCar.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setAngle()

void SimpleCar::setAngle ( int  angle)
overridevirtual

Set the car's driving angle.

Parameters
angleThe car's angle in degrees [-90, 90]

Example:

car.setAngle(20);

Implements Car.

Definition at line 17 of file SimpleCar.cpp.

Here is the call graph for this function:

◆ setSpeed()

void SimpleCar::setSpeed ( float  speed)
overridevirtual

Sets the car's driving speed as a percentage of the motors total speed where the sign indicates direction.

Parameters
speedThe car's speed [-100, 100]

Example:

car.setSpeed(-100); // Full speed backward
car.setSpeed(0); // Car immobilized
car.setSpeed(50); // Car with half speed forward

Implements Car.

Definition at line 12 of file SimpleCar.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
DifferentialControl
Definition: DifferentialControl.hpp:11
smartcarlib::pins::v2::rightMotorPins
const BrushedMotorPins rightMotorPins
Definition: Smartcar.h:51
SimpleCar
Definition: SimpleCar.hpp:10