ArPiRobot-CoreLib C++
C++ library for ArPiRobot robots
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
arpirobot::MotorController Class Referenceabstract

#include <arpirobot/core/device/MotorController.hpp>

Inheritance diagram for arpirobot::MotorController:
arpirobot::BaseDevice arpirobot::AdafruitMotorHatMotor arpirobot::DRV8833Motor arpirobot::L298NMotor arpirobot::TB6612Motor

Public Member Functions

bool isInverted ()
 
void setInverted (bool inverted)
 
bool isBrakeMode ()
 
void setBrakeMode (bool brakeMode)
 
double getSpeed ()
 
void setSpeed (double speed)
 
- Public Member Functions inherited from arpirobot::BaseDevice
virtual std::string getDeviceName ()
 
bool isLockedByAction (std::shared_ptr< Action > action=nullptr)
 Check if a given action locks the device. More...
 
bool isLockedByAction (Action &action)
 Check if a given action locks the device. More...
 

Protected Member Functions

bool isEnabled () override
 
bool shouldMatchRobotState () override
 
bool shouldDisableWithWatchdog () override
 
void enable () override
 
void disable () override
 
virtual void run ()=0
 
- Protected Member Functions inherited from arpirobot::BaseDevice
virtual void begin ()=0
 

Protected Attributes

double speed = 0
 
std::mutex lock
 
bool enabled = false
 
bool brakeMode = false
 
int8_t speedFactor = 1
 
- Protected Attributes inherited from arpirobot::BaseDevice
bool initialized = false
 
std::string deviceName
 

Detailed Description

Base class for motor controllers.

Member Function Documentation

◆ getSpeed()

double arpirobot::MotorController::getSpeed ( )

Get the current speed of the motor

Returns
the motor's speed

◆ isBrakeMode()

bool arpirobot::MotorController::isBrakeMode ( )

Check if brake mode is enabled. When enabled motors with a speed of zero will resist motion.

Returns
true if enabled, else false

◆ isInverted()

bool arpirobot::MotorController::isInverted ( )

Check if the motor direction is inverted (positive and negative speed switched)

Returns
true if inverted, else false

◆ setBrakeMode()

void arpirobot::MotorController::setBrakeMode ( bool  brakeMode)

Set if brake mode is enabled

Parameters
brakeModetrue for enabled, false for disabled

◆ setInverted()

void arpirobot::MotorController::setInverted ( bool  inverted)

Set the motor direction to inverted or non-inverted (positive and negative speed switched)

Parameters
invertedTrue for inverted, false for non-inverted

◆ setSpeed()

void arpirobot::MotorController::setSpeed ( double  speed)

Set the current speed of the motor (no effect if motor is disabled)

Parameters
speedThe motor's speed (between -1.0 and 1.0)

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