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

A class to programmatically represent a very basic vehicle with two motors. More...

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

Examples:
FullSerialControl.ino, manualControl.ino, SerialControlServoESC.ino, shieldMotorsTest.ino, and SimpleCar.ino.

Definition at line 10 of file SimpleCar.hpp.

Constructor & Destructor Documentation

SimpleCar::SimpleCar ( Control control)

Constructs a simple car.

Parameters
controlThe car's control

Example:

BrushedMotor leftMotor(8, 10, 9);
BrushedMotor rightMotor(12, 13, 11);
DifferentialControl control(leftMotor, rightMotor);
SimpleCar car(control);

Definition at line 7 of file SimpleCar.cpp.

virtual SimpleCar::~SimpleCar ( )
virtualdefault

Member Function Documentation

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.

Reimplemented in DistanceCar.

Definition at line 22 of file SimpleCar.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

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:

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.

Reimplemented in DistanceCar.

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: