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

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

#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...
 
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 Control
virtual ~Control ()=default
 

Detailed Description

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

Examples:
automatedMovements.ino, DistanceCar.ino, FullSerialControl.ino, HeadingCar.ino, manualControl.ino, manualWithCruiseControl.ino, PidControllerMonitor.ino, rotateOnSpot.ino, shieldMotorsTest.ino, SimpleCar.ino, and SmartCar.ino.

Definition at line 11 of file DifferentialControl.hpp.

Constructor & Destructor Documentation

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:

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

Definition at line 9 of file DifferentialControl.cpp.

Member Function Documentation

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 48 of file DifferentialControl.cpp.

Here is the call graph for this function:

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:

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: