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

#include <DifferentialControl.hpp>

Inheritance diagram for DifferentialControl:
Inheritance graph
Collaboration diagram for DifferentialControl:
Collaboration graph

Public Member Functions

 DifferentialControl (Motor &leftMotor, Motor &rightMotor)
 Constructs an Ackerman way of controlling the vehicle. More...
 
void setAngle (int angle) override
 Sets the driving angle in degrees [-90, 90]. More...
 
void setSpeed (int speed) override
 Sets the driving speed as percentage of the total motor speed where the sign represents the direction of movement [-100, 100]. 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 Control
virtual ~Control ()=default
 

Detailed Description

Class to represent controling a vehicle by applying different speed on each side, like a tank.

Definition at line 11 of file DifferentialControl.hpp.

Constructor & Destructor Documentation

◆ DifferentialControl()

DifferentialControl::DifferentialControl ( Motor leftMotor,
Motor rightMotor 
)

Constructs an Ackerman way of controlling the vehicle.

Parameters
steeringThe motor that controls the steering
throttlingThe motor that controls the throttling

Example:

Definition at line 9 of file DifferentialControl.cpp.

Member Function Documentation

◆ overrideMotorSpeed()

void DifferentialControl::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 first motor speed [-100, 100]
secondMotorSpeedThe second motor speed [-100, 100]

Example:

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

Implements Control.

Definition at line 49 of file DifferentialControl.cpp.

Here is the call graph for this function:

◆ setAngle()

void DifferentialControl::setAngle ( int  angle)
overridevirtual

Sets the driving angle in degrees [-90, 90].

Parameters
angleThe driving angle

Example:

control.setAngle(90);

Implements Control.

Definition at line 17 of file DifferentialControl.cpp.

Here is the call graph for this function:

◆ setSpeed()

void DifferentialControl::setSpeed ( int  speed)
overridevirtual

Sets the driving speed as percentage of the total motor speed where the sign represents the direction of movement [-100, 100].

Parameters
speedThe driving speed

Example:

control.setSpeed(-100); // Full speed backward

Implements Control.

Definition at line 23 of file DifferentialControl.cpp.

Here is the call 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