Smartcar Shield
Loading...
Searching...
No Matches
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.
 
void setSpeed (float speed) override
 Sets the car's driving speed as a percentage of the motors total speed where the sign indicates direction.
 
void setAngle (int angle) override
 Set the car's driving angle.
 
void overrideMotorSpeed (int firstMotorSpeed, int secondMotorSpeed) override
 Set the motor speed individually as a percentage of the motors` total power.
 
- 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)
explicit

Constructs a simple car.

Parameters
controlThe car's control

Example:

DifferentialControl control(leftMotor, rightMotor);
SimpleCar car(control);
A brushed motor is controlled via two wires where the flow of current determines the direction of rot...
Class to represent controling a vehicle by applying different speed on each side, like a tank.
A class to programmatically represent a very basic vehicle with two motors.
Definition SimpleCar.hpp:11
const BrushedMotorPins leftMotorPins
Definition Smartcar.h:50
const BrushedMotorPins rightMotorPins
Definition Smartcar.h:51

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.

Reimplemented in SmartCar.

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.

Reimplemented in SmartCar.

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: