Open FFBoard
Open source force feedback firmware
MotorDriver.h
Go to the documentation of this file.
1/*
2 * MotorDriver.h
3 *
4 * Created on: Feb 1, 2020
5 * Author: Yannick
6 */
7
8#ifndef MOTORDRIVER_H_
9#define MOTORDRIVER_H_
10
11#include "cppmain.h"
12#include "ChoosableClass.h"
13#include "PersistentStorage.h"
14#include "Encoder.h"
15#include "memory"
16
17class Encoder;
19public:
21 virtual ~MotorDriver(){};
22
25 const ClassType getClassType() override {return ClassType::Motordriver;};
26 static const std::vector<class_entry<MotorDriver>> all_drivers;
27
28 virtual void turn(int16_t power);
29 virtual void stopMotor();
30 virtual void startMotor();
31 virtual void emergencyStop(bool reset = false);
32
33 virtual bool motorReady(); // Returns true if the driver is active and ready to receive commands
34
35 virtual Encoder* getEncoder(); // Encoder is managed by the motor driver. Must always return an encoder
36
41 virtual void setEncoder(std::shared_ptr<Encoder>& encoder){drvEncoder = encoder;}
42 virtual bool hasIntegratedEncoder(); // Returns true if the driver has an integrated encoder. If false the axis will pass one to the driver
43
44
45protected:
46 std::shared_ptr<Encoder> drvEncoder = std::make_shared<Encoder>(); // Dummy encoder
47};
48
49
50
51#endif /* MOTORDRIVER_H_ */
ClassType
Definition: ClassIDs.h:12
virtual void setEncoder(std::shared_ptr< Encoder > &encoder)
Definition: MotorDriver.h:41
virtual void turn(int16_t power)
Definition: MotorDriver.cpp:90
virtual ~MotorDriver()
Definition: MotorDriver.h:21
const ClassIdentifier getInfo()
Definition: MotorDriver.cpp:80
virtual bool motorReady()
Definition: MotorDriver.cpp:68
const ClassType getClassType() override
returns the used classchooser selection id of this instance
Definition: MotorDriver.h:25
virtual void emergencyStop(bool reset=false)
Definition: MotorDriver.cpp:60
virtual void startMotor()
Definition: MotorDriver.cpp:97
static ClassIdentifier info
Definition: MotorDriver.h:21
virtual bool hasIntegratedEncoder()
Definition: MotorDriver.cpp:75
static const std::vector< class_entry< MotorDriver > > all_drivers
Definition: MotorDriver.h:25
std::shared_ptr< Encoder > drvEncoder
Definition: MotorDriver.h:46
virtual Encoder * getEncoder()
virtual void stopMotor()