SmartVehicle-Basis
SmartFactory
Drive Class Reference

Class Drive handels the Driving-System and provides basic functions. More...

#include <Drive.h>

Public Types

enum  Direction { Direction::Left, Direction::Right, Direction::Forward, Direction::Backward }
 Direction enum holds all possible directions. More...
 

Public Member Functions

 Drive (const int MotorPortRight, const int MotorPortLeft)
 Construct a new Drive object https://www.adafruit.com/product/2927. More...
 
void drive (Direction direction, unsigned int speed)
 Drive straight Forwards or Backwards. More...
 
void turn (Direction direction, unsigned int speed)
 Turn left or right. Speed will add to one Motor's actual speed and substract from the others depenig on which side it turns. More...
 
void turnonpoint (Direction direction, unsigned int speed)
 Turn on Point Drive on Motor Forward and the other Backward with the given speed. More...
 
void stop ()
 Power of the Motor. Does not apply breaking. More...
 

Private Member Functions

String decodeDirection (Direction direction)
 Decodes the Direction-Enum and returns a description. More...
 

Private Attributes

Adafruit_MotorShield pAFMS = Adafruit_MotorShield()
 
Adafruit_DCMotor * pMotorRight
 Pointer to right Motor Obj. More...
 
Adafruit_DCMotor * pMotorLeft
 Pointer to left Motor Obj. More...
 
int pSpeedLeft
 actual Speed of left Motor More...
 
int pSpeedRight
 actual Speed of right Motor More...
 
int pTurnSpeedLeft
 
int pTurnSpeedRight
 
Direction pWayVehicle = Direction::Forward
 Actual movingdirection Forward or Backward. More...
 

Detailed Description

Class Drive handels the Driving-System and provides basic functions.

Definition at line 42 of file Drive.h.

Member Enumeration Documentation

◆ Direction

enum Drive::Direction
strong

Direction enum holds all possible directions.

Enumerator
Left 

Left.

Right 

Right.

Forward 

Forward.

Backward 

Backward.

Definition at line 49 of file Drive.h.

Constructor & Destructor Documentation

◆ Drive()

Drive::Drive ( const int  MotorPortRight,
const int  MotorPortLeft 
)

Construct a new Drive object https://www.adafruit.com/product/2927.

Parameters
MotorPortRight- Port where the right Motor is connected on the MotorShield
MotorPortLeft- Port where the left Motor is connected on the MotorShield
Todo:
Add a variable to compensate for differences in engine speed with the same control

Definition at line 21 of file Drive.cpp.

Member Function Documentation

◆ drive()

void Drive::drive ( Direction  direction,
unsigned int  speed 
)

Drive straight Forwards or Backwards.

Parameters
direction- Movingdirection Forward or Backward
speed- Speed between 0 and 255

Definition at line 29 of file Drive.cpp.

◆ turn()

void Drive::turn ( Direction  direction,
unsigned int  speed 
)

Turn left or right. Speed will add to one Motor's actual speed and substract from the others depenig on which side it turns.

Parameters
direction- left or right
speed- Speed between 0 and 255

Definition at line 53 of file Drive.cpp.

◆ turnonpoint()

void Drive::turnonpoint ( Direction  direction,
unsigned int  speed 
)

Turn on Point Drive on Motor Forward and the other Backward with the given speed.

Parameters
direction- left or right
speed- Speed between 0 and 255

Definition at line 87 of file Drive.cpp.

◆ stop()

void Drive::stop ( )

Power of the Motor. Does not apply breaking.

Definition at line 110 of file Drive.cpp.

◆ decodeDirection()

String Drive::decodeDirection ( Direction  direction)
private

Decodes the Direction-Enum and returns a description.

Parameters
direction- enum Direction
Returns
String - State as String

Definition at line 124 of file Drive.cpp.

Member Data Documentation

◆ pAFMS

Adafruit_MotorShield Drive::pAFMS = Adafruit_MotorShield()
private

Definition at line 96 of file Drive.h.

◆ pMotorRight

Adafruit_DCMotor* Drive::pMotorRight
private

Pointer to right Motor Obj.

Definition at line 97 of file Drive.h.

◆ pMotorLeft

Adafruit_DCMotor* Drive::pMotorLeft
private

Pointer to left Motor Obj.

Definition at line 98 of file Drive.h.

◆ pSpeedLeft

int Drive::pSpeedLeft
private

actual Speed of left Motor

Definition at line 99 of file Drive.h.

◆ pSpeedRight

int Drive::pSpeedRight
private

actual Speed of right Motor

Definition at line 100 of file Drive.h.

◆ pTurnSpeedLeft

int Drive::pTurnSpeedLeft
private

Definition at line 101 of file Drive.h.

◆ pTurnSpeedRight

int Drive::pTurnSpeedRight
private

Definition at line 102 of file Drive.h.

◆ pWayVehicle

Direction Drive::pWayVehicle = Direction::Forward
private

Actual movingdirection Forward or Backward.

Definition at line 103 of file Drive.h.


The documentation for this class was generated from the following files: