Open FFBoard
Open source force feedback firmware
MotorDriver Class Reference

#include <MotorDriver.h>

Inheritance diagram for MotorDriver:
ChoosableClass MotorPWM MotorSimplemotion ODriveCAN RmdMotorCAN TMC4671 VescCAN MotorSimplemotion1 MotorSimplemotion2 ODriveCAN1 ODriveCAN2 RmdMotorCAN1 RmdMotorCAN2 TMC_1 TMC_2 VESC_1 VESC_2

Public Member Functions

 MotorDriver ()
 
virtual ~MotorDriver ()
 
const ClassIdentifier getInfo ()
 
const ClassType getClassType () override
 returns the used classchooser selection id of this instance More...
 
virtual void turn (int16_t power)
 
virtual void stopMotor ()
 
virtual void startMotor ()
 
virtual void emergencyStop (bool reset=false)
 
virtual bool motorReady ()
 
virtual EncodergetEncoder ()
 
virtual void setEncoder (std::shared_ptr< Encoder > &encoder)
 
virtual bool hasIntegratedEncoder ()
 
- Public Member Functions inherited from ChoosableClass
virtual ~ChoosableClass ()
 
uint16_t getSelectionID ()
 

Static Public Attributes

static ClassIdentifier info ={.name = "None" , .id=CLSID_MOT_NONE, .visibility = ClassVisibility::visible}
 
static const std::vector< class_entry< MotorDriver > > all_drivers
 
- Static Public Attributes inherited from ChoosableClass
static ClassIdentifier info
 

Protected Attributes

std::shared_ptr< EncoderdrvEncoder = std::make_shared<Encoder>()
 
- Protected Attributes inherited from ChoosableClass
uint16_t selectionId
 Should only be written by ClassChooser during creation. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from ChoosableClass
static bool isCreatable ()
 

Detailed Description

Definition at line 18 of file MotorDriver.h.

Constructor & Destructor Documentation

◆ MotorDriver()

MotorDriver::MotorDriver ( )
inline

Definition at line 20 of file MotorDriver.h.

◆ ~MotorDriver()

virtual MotorDriver::~MotorDriver ( )
inlinevirtual

Definition at line 21 of file MotorDriver.h.

Member Function Documentation

◆ emergencyStop()

void MotorDriver::emergencyStop ( bool  reset = false)
virtual

Request an emergency stop if something critical happened or the emergency button is triggered Should stop the motor immediately in a safe way.

Reimplemented in TMC4671.

Definition at line 60 of file MotorDriver.cpp.

◆ getClassType()

const ClassType MotorDriver::getClassType ( )
inlineoverridevirtual

returns the used classchooser selection id of this instance

Type of this class. Mainclass, motordriver... Should be implemented by the parent class so it is not in the info struct

Reimplemented from ChoosableClass.

Reimplemented in TMC4671.

Definition at line 25 of file MotorDriver.h.

◆ getEncoder()

Encoder * MotorDriver::getEncoder ( )
virtual

Returns the encoder of this motor driver. Either the integrated encoder or an external encoder assigned to this motor driver passed externally

Reimplemented in MotorSimplemotion, ODriveCAN, RmdMotorCAN, TMC4671, and VescCAN.

Definition at line 111 of file MotorDriver.cpp.

◆ getInfo()

const ClassIdentifier MotorDriver::getInfo ( )
virtual

◆ hasIntegratedEncoder()

bool MotorDriver::hasIntegratedEncoder ( )
virtual

If returned true it signals that this motor driver contains its own encoder and does not require an external encoder

Reimplemented in MotorSimplemotion, ODriveCAN, RmdMotorCAN, TMC4671, and VescCAN.

Definition at line 75 of file MotorDriver.cpp.

◆ motorReady()

bool MotorDriver::motorReady ( )
virtual

Reimplemented in MotorSimplemotion, RmdMotorCAN, TMC4671, ODriveCAN, and VescCAN.

Definition at line 68 of file MotorDriver.cpp.

◆ setEncoder()

virtual void MotorDriver::setEncoder ( std::shared_ptr< Encoder > &  encoder)
inlinevirtual

Can pass an external encoder if driver has no integrated encoder This allows a driver to get an external encoder assigned if it requires one and has the capability of using external encoders

Reimplemented in TMC4671.

Definition at line 41 of file MotorDriver.h.

◆ startMotor()

void MotorDriver::startMotor ( )
virtual

Enable the motor driver

Reimplemented in MotorPWM, TMC4671, MotorSimplemotion, ODriveCAN, RmdMotorCAN, and VescCAN.

Definition at line 97 of file MotorDriver.cpp.

◆ stopMotor()

void MotorDriver::stopMotor ( )
virtual

Disable the motor driver

Reimplemented in MotorPWM, TMC4671, MotorSimplemotion, ODriveCAN, RmdMotorCAN, and VescCAN.

Definition at line 103 of file MotorDriver.cpp.

◆ turn()

void MotorDriver::turn ( int16_t  val)
virtual

Turn the motor with positive/negative power. Range should be full signed 16 bit A value of 0 should have no torque. The sign is the direction.

Reimplemented in MotorPWM, TMC4671, MotorSimplemotion, ODriveCAN, RmdMotorCAN, and VescCAN.

Definition at line 90 of file MotorDriver.cpp.

Member Data Documentation

◆ all_drivers

const std::vector< class_entry< MotorDriver > > MotorDriver::all_drivers
static

Add available motor drivers here. ID must be unique to a motor driver. 0-63

Definition at line 26 of file MotorDriver.h.

◆ drvEncoder

std::shared_ptr<Encoder> MotorDriver::drvEncoder = std::make_shared<Encoder>()
protected

Definition at line 46 of file MotorDriver.h.

◆ info

ClassIdentifier MotorDriver::info ={.name = "None" , .id=CLSID_MOT_NONE, .visibility = ClassVisibility::visible}
static

Definition at line 23 of file MotorDriver.h.


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