![]() |
Open FFBoard
Open source force feedback firmware
|
#include <RmdMotorCAN.h>
Classes | |
union | ErrorStatus |
Public Member Functions | |
RmdMotorCAN (uint8_t instance) | |
virtual | ~RmdMotorCAN () |
const ClassIdentifier | getInfo ()=0 |
Command handlers always have class infos. Works well with ChoosableClass. More... | |
void | turn (int16_t power) override |
void | stopMotor () override |
void | startMotor () override |
Encoder * | getEncoder () override |
bool | hasIntegratedEncoder () |
void | setTorque (int16_t torque) |
bool | motorReady () |
void | Run () |
void | saveFlash () override |
void | restoreFlash () override |
uint32_t | getCpr () override |
int32_t | getPos () override |
void | setPos (int32_t pos) override |
EncoderType | getEncoderType () override |
void | setCanFilter () |
void | updateRequestMode (bool activerequests) |
void | sendMsg (std::array< uint8_t, 8 > &data, uint8_t len=8) |
void | sendCmd (uint8_t cmd) |
void | canRxPendCallback (CANPort *port, CAN_rx_msg &msg) override |
void | updateStatus () |
void | requestConstantReports (uint8_t cmd, bool enable, uint16_t interval_10ms) |
void | registerCommands () |
CommandStatus | command (const ParsedCommand &cmd, std::vector< CommandReply > &replies) override |
![]() | |
MotorDriver () | |
virtual | ~MotorDriver () |
const ClassType | getClassType () override |
returns the used classchooser selection id of this instance More... | |
virtual void | emergencyStop (bool reset=false) |
virtual void | setEncoder (std::shared_ptr< Encoder > &encoder) |
![]() | |
virtual | ~ChoosableClass () |
uint16_t | getSelectionID () |
![]() | |
PersistentStorage () | |
virtual | ~PersistentStorage () |
void | restoreFlashDelayed () |
![]() | |
Encoder () | |
virtual | ~Encoder () |
virtual float | getPos_f () |
virtual int32_t | getPosAbs () |
virtual float | getPosAbs_f () |
virtual const ClassType | getClassType () override |
returns the used classchooser selection id of this instance More... | |
![]() | |
CanHandler () | |
virtual | ~CanHandler () |
virtual void | canErrorCallback (CANPort *port, uint32_t errcode) |
virtual void | canRxFullCallback (CANPort *port, uint32_t fifo) |
virtual void | canTxCpltCallback (CANPort *port, uint32_t mailbox) |
virtual void | canTxAbortCallback (CANPort *port, uint32_t mailbox) |
![]() | |
virtual const ClassType | getClassType () |
CommandHandler (const char *clsname, uint16_t clsid, uint8_t instance=0) | |
virtual | ~CommandHandler () |
virtual bool | hasCommands () |
virtual void | setCommandsEnabled (bool enable) |
void | registerCommands () |
virtual CommandStatus | internalCommand (const ParsedCommand &cmd, std::vector< CommandReply > &replies) |
virtual std::string | getHelpstring () |
virtual std::string | getCommandsHelpstring () |
virtual std::string | getCsvHelpstring () |
virtual uint8_t | getCommandHandlerInstance () |
void | broadcastCommandReply (CommandReply reply, uint32_t cmdId, CMDtype type) |
void | sendCommandReplyAsync (CommandReply reply, uint32_t cmdId, CMDtype type, CommandInterface *interface=nullptr) |
virtual uint16_t | getCommandHandlerID () |
virtual CmdHandlerInfo * | getCommandHandlerInfo () |
virtual bool | isValidCommandId (uint32_t cmdid, uint32_t ignoredFlags=0, uint32_t requiredFlag=0) |
virtual CmdHandlerCommanddef * | getCommandFromName (const std::string &cmd, uint32_t ignoredFlags=0) |
virtual CmdHandlerCommanddef * | getCommandFromId (const uint32_t id, uint32_t ignoredFlags=0) |
template<typename ID > | |
void | registerCommand (const char *cmd, const ID cmdid, const char *help=nullptr, uint32_t flags=0) |
Public Attributes | |
const uint32_t | angleUpdateMs = 10 |
Private Member Functions | |
void | errorCb (ErrorStatus &errors) |
![]() | |
Thread (const std::string Name, uint16_t StackDepth, UBaseType_t Priority) | |
Thread (const char *Name, uint16_t StackDepth, UBaseType_t Priority) | |
Thread (uint16_t StackDepth, UBaseType_t Priority) | |
bool | Start () |
virtual | ~Thread () |
TaskHandle_t | GetHandle () |
void | Suspend () |
void | Resume () |
void | ResumeFromISR () |
void | Notify () |
void | NotifyFromISR () |
uint32_t | WaitForNotification (TickType_t Timeout=portMAX_DELAY) |
UBaseType_t | GetPriority () |
UBaseType_t | GetPriorityFromISR () |
void | SetPriority (UBaseType_t NewPriority) |
std::string | GetName () |
char * | GetName () |
virtual void | Cleanup () |
void | Delay (const TickType_t Delay) |
void | DelayUntil (const TickType_t Period) |
void | ResetDelayUntil () |
bool | Wait (ConditionVariable &Cv, Mutex &CvLock, TickType_t Timeout=portMAX_DELAY) |
Private Attributes | |
CANPort * | port = &canport |
uint8_t | nodeId = 1 |
uint8_t | motorId = 0 |
bool | active = false |
bool | nextAvailable = false |
bool | available = false |
bool | activerequests = false |
bool | requestConstantReportEnable = false |
char | modelName [8] = {0} |
uint32_t | lastAngleUpdate = 0 |
uint32_t | lastTorqueStatusUpdate_us = 0 |
float | lastPos = 0 |
uint16_t | maxTorque = 1000 |
int32_t | filterId = -2 |
int16_t | curCurrent = 0 |
uint8_t | curTemp = 0 |
uint16_t | curVoltage = 0 |
ErrorStatus | lastErrors = {0} |
int32_t | posOffset = 0 |
Additional Inherited Members | |
![]() | |
static bool | isCreatable () |
![]() | |
static std::vector< PersistentStorage * > & | getFlashHandlers () |
static void | restoreFlashStartupCb () |
![]() | |
static std::vector< CanHandler * > & | getCANHandlers () |
![]() | |
static void | logSerial (std::string string) |
Send a log formatted sequence. More... | |
static void | logSerialDebug (std::string string) |
Send a log formatted sequence if debug is on. More... | |
static bool | logsEnabled () |
static void | setLogsEnabled (bool enabled) |
static uint32_t | getClassIdFromName (const char *name) |
static const char * | getClassNameFromId (const uint32_t id) |
static CommandHandler * | getHandlerFromHandlerId (const uint16_t cmdhandlerID) |
static CommandHandler * | getHandlerFromId (const uint16_t id, const uint8_t instance=0xFF) |
static CommandHandler * | getHandlerFromClassName (const char *name, const uint8_t instance=0xFF) |
static std::vector< CommandHandler * > | getHandlersFromClassName (const char *name) |
static std::vector< CommandHandler * > | getHandlersFromId (const uint16_t id) |
static bool | isInHandlerList (CommandHandler *handler) |
static std::string | getAllHelpstrings () |
static std::vector< CommandHandler * > & | getCommandHandlers () |
template<typename TVal > | |
static CommandStatus | handleGetSet (const ParsedCommand &cmd, std::vector< CommandReply > &replies, TVal &value) |
template<typename TVal , class cls , class cls1 > | |
static CommandStatus | handleGetSetFunc (const ParsedCommand &cmd, std::vector< CommandReply > &replies, TVal &value, void(cls1::*setfunc)(TVal), cls *obj) |
template<typename TVal , class cls , class cls1 , class cls2 > | |
static CommandStatus | handleGetFuncSetFunc (const ParsedCommand &cmd, std::vector< CommandReply > &replies, TVal(cls1::*getfunc)(), void(cls2::*setfunc)(TVal), cls *obj) |
template<typename TVal , class cls , class cls1 > | |
static CommandStatus | handleGetFuncSet (const ParsedCommand &cmd, std::vector< CommandReply > &replies, TVal &value, TVal(cls1::*getfunc)(), cls *obj) |
![]() | |
static ClassIdentifier | info ={.name = "None" , .id=CLSID_MOT_NONE, .visibility = ClassVisibility::visible} |
static const std::vector< class_entry< MotorDriver > > | all_drivers |
![]() | |
static ClassIdentifier | info |
![]() | |
static ClassIdentifier | info ={.name = "None" , .id=CLSID_ENCODER_NONE, .visibility = ClassVisibility::visible} |
static const std::vector< class_entry< Encoder > > | all_encoders |
![]() | |
static bool | logEnabled = true |
![]() | |
void | setInstance (uint8_t instance) |
virtual void | addCommandHandler () |
virtual void | removeCommandHandler () |
![]() | |
static std::vector< uint16_t > & | getCommandHandlerIds () |
![]() | |
std::shared_ptr< Encoder > | drvEncoder = std::make_shared<Encoder>() |
![]() | |
uint16_t | selectionId |
Should only be written by ClassChooser during creation. More... | |
![]() | |
bool | restoreDelayedFlag = false |
![]() | |
uint32_t | cpr = 0 |
![]() | |
bool | commandsEnabled = true |
std::vector< CmdHandlerCommanddef > | registeredCommands |
CmdHandlerInfo | cmdHandlerInfo |
![]() | |
static bool | startupComplete = false |
![]() | |
static void | Yield () |
static void | StartScheduler () |
static void | EndScheduler () |
Definition at line 28 of file RmdMotorCAN.h.
RmdMotorCAN::RmdMotorCAN | ( | uint8_t | instance | ) |
Definition at line 42 of file RmdMotorCAN.cpp.
|
virtual |
Definition at line 61 of file RmdMotorCAN.cpp.
|
overridevirtual |
New message received in fifo number
Reimplemented from CanHandler.
Definition at line 240 of file RmdMotorCAN.cpp.
|
overridevirtual |
[in] | cmd | The parsed command to be executed. |
[out] | replies | A vector to return one or multiple reply objects into. Replies to the interface will be generated based on the reply objects. A string reply may not contain start, end and separation markers: [,],| Other characters are allowed. |
Reimplemented from CommandHandler.
Definition at line 334 of file RmdMotorCAN.cpp.
|
private |
Definition at line 223 of file RmdMotorCAN.cpp.
|
overridevirtual |
Gets the amount of counts per full rotation of the encoder
Reimplemented from Encoder.
Definition at line 161 of file RmdMotorCAN.cpp.
|
overridevirtual |
Returns the encoder of this motor driver. Either the integrated encoder or an external encoder assigned to this motor driver passed externally
Reimplemented from MotorDriver.
Definition at line 151 of file RmdMotorCAN.cpp.
|
overridevirtual |
Returns the type of the encoder. Must override this and NOT return NONE in other classes
Reimplemented from Encoder.
Definition at line 219 of file RmdMotorCAN.cpp.
|
pure virtual |
Command handlers always have class infos. Works well with ChoosableClass.
Implements CommandHandler.
Implemented in RmdMotorCAN1, and RmdMotorCAN2.
|
overridevirtual |
Returns the encoder position as raw counts
Reimplemented from Encoder.
Definition at line 165 of file RmdMotorCAN.cpp.
|
inlinevirtual |
If returned true it signals that this motor driver contains its own encoder and does not require an external encoder
Reimplemented from MotorDriver.
Definition at line 38 of file RmdMotorCAN.h.
|
virtual |
Reimplemented from MotorDriver.
Definition at line 155 of file RmdMotorCAN.cpp.
void RmdMotorCAN::registerCommands | ( | ) |
Definition at line 322 of file RmdMotorCAN.cpp.
void RmdMotorCAN::requestConstantReports | ( | uint8_t | cmd, |
bool | enable, | ||
uint16_t | interval_10ms | ||
) |
Request constant automatic replies interval 0 = 10ms, 1= 20ms...
Definition at line 233 of file RmdMotorCAN.cpp.
|
overridevirtual |
Should be implemented to restore settings. This is not automatically called and should be called when appropriate.
Reimplemented from PersistentStorage.
Definition at line 67 of file RmdMotorCAN.cpp.
|
virtual |
Implementation of your actual thread code. You must override this function.
Implements cpp_freertos::Thread.
Definition at line 98 of file RmdMotorCAN.cpp.
|
overridevirtual |
Called when the user uses the "save" command and presses the save button in the configurator Automatically called by the command parser thread for every class that inherits from PersistentStorage
Reimplemented from PersistentStorage.
Definition at line 85 of file RmdMotorCAN.cpp.
void RmdMotorCAN::sendCmd | ( | uint8_t | cmd | ) |
Definition at line 187 of file RmdMotorCAN.cpp.
void RmdMotorCAN::sendMsg | ( | std::array< uint8_t, 8 > & | data, |
uint8_t | len = 8 |
||
) |
Definition at line 177 of file RmdMotorCAN.cpp.
void RmdMotorCAN::setCanFilter | ( | ) |
Definition at line 123 of file RmdMotorCAN.cpp.
|
overridevirtual |
Change the position of the encoder Can be used to reset the center
Reimplemented from Encoder.
Definition at line 173 of file RmdMotorCAN.cpp.
void RmdMotorCAN::setTorque | ( | int16_t | torque | ) |
Torque 0.01A * torque
Definition at line 205 of file RmdMotorCAN.cpp.
|
overridevirtual |
Enable the motor driver
Reimplemented from MotorDriver.
Definition at line 144 of file RmdMotorCAN.cpp.
|
overridevirtual |
Disable the motor driver
Reimplemented from MotorDriver.
Definition at line 138 of file RmdMotorCAN.cpp.
|
overridevirtual |
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 from MotorDriver.
Definition at line 210 of file RmdMotorCAN.cpp.
void RmdMotorCAN::updateRequestMode | ( | bool | activerequests | ) |
Definition at line 305 of file RmdMotorCAN.cpp.
void RmdMotorCAN::updateStatus | ( | ) |
Requests Status1 update Contains voltage, errors and temperature
Definition at line 198 of file RmdMotorCAN.cpp.
|
private |
Definition at line 90 of file RmdMotorCAN.h.
|
private |
Definition at line 93 of file RmdMotorCAN.h.
const uint32_t RmdMotorCAN::angleUpdateMs = 10 |
Definition at line 67 of file RmdMotorCAN.h.
|
private |
Definition at line 92 of file RmdMotorCAN.h.
|
private |
Definition at line 106 of file RmdMotorCAN.h.
|
private |
Definition at line 107 of file RmdMotorCAN.h.
|
private |
Definition at line 108 of file RmdMotorCAN.h.
|
private |
Definition at line 104 of file RmdMotorCAN.h.
|
private |
Definition at line 98 of file RmdMotorCAN.h.
|
private |
Definition at line 110 of file RmdMotorCAN.h.
|
private |
Definition at line 101 of file RmdMotorCAN.h.
|
private |
Definition at line 99 of file RmdMotorCAN.h.
|
private |
Definition at line 102 of file RmdMotorCAN.h.
|
private |
Definition at line 96 of file RmdMotorCAN.h.
|
private |
Definition at line 89 of file RmdMotorCAN.h.
|
private |
Definition at line 91 of file RmdMotorCAN.h.
|
private |
Definition at line 88 of file RmdMotorCAN.h.
Definition at line 87 of file RmdMotorCAN.h.
|
private |
Definition at line 112 of file RmdMotorCAN.h.
|
private |
Definition at line 94 of file RmdMotorCAN.h.