![]() |
Open FFBoard
Open source force feedback firmware
|
#include <ODriveCAN.h>
Public Member Functions | |
| ODriveCAN (uint8_t id) | |
| virtual | ~ODriveCAN () |
| const ClassIdentifier | getInfo ()=0 |
| void | turn (int16_t power) override |
| void | stopMotor () override |
| void | startMotor () override |
| Encoder * | getEncoder () override |
| bool | hasIntegratedEncoder () |
| template<class T> | |
| void | sendMsg (uint8_t cmd, T value) |
| void | sendMsg (uint8_t cmd, float value) |
| void | requestMsg (uint8_t cmd) |
| bool | motorReady () override |
| void | startAnticogging () |
| void | Run () |
| void | setTorque (float torque) |
| void | canRxPendCallback (CANPort *port, CAN_rx_msg &msg) override |
| void | canErrorCallback (CANPort *port, uint32_t errcode) |
| float | getPos_f () override |
| uint32_t | getCpr () override |
| int32_t | getPos () override |
| void | setPos (int32_t pos) override |
| EncoderType | getEncoderType () override |
| void | setMode (ODriveControlMode controlMode, ODriveInputMode inputMode) |
| void | setState (ODriveState state) |
| void | readyCb () |
| void | saveFlash () override |
| void | restoreFlash () override |
| CommandStatus | command (const ParsedCommand &cmd, std::vector< CommandReply > &replies) override |
| void | registerCommands () |
| std::string | getHelpstring () |
| void | setCanFilter () |
Public Member Functions inherited from MotorDriver | |
| MotorDriver () | |
| virtual | ~MotorDriver () |
| const ClassType | getClassType () override |
| returns the used classchooser selection id of this instance | |
| virtual void | emergencyStop (bool reset=false) |
| virtual void | setEncoder (std::shared_ptr< Encoder > &encoder) |
Public Member Functions inherited from ChoosableClass | |
| virtual | ~ChoosableClass () |
| uint16_t | getSelectionID () |
Public Member Functions inherited from PersistentStorage | |
| PersistentStorage () | |
| virtual | ~PersistentStorage () |
| void | restoreFlashDelayed () |
Public Member Functions inherited from Encoder | |
| Encoder () | |
| virtual | ~Encoder () |
| virtual int32_t | getPosAbs () |
| virtual float | getPosAbs_f () |
| virtual const ClassType | getClassType () override |
| returns the used classchooser selection id of this instance | |
Public Member Functions inherited from CanHandler | |
| CanHandler () | |
| virtual | ~CanHandler () |
| virtual void | canRxFullCallback (CANPort *port, uint32_t fifo) |
| virtual void | canTxCpltCallback (CANPort *port, uint32_t mailbox) |
| virtual void | canTxAbortCallback (CANPort *port, uint32_t mailbox) |
Public Member Functions inherited from CommandHandler | |
| 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 | 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) |
Private Attributes | |
| CANPort * | port = &canport |
| float | lastPos = 0 |
| float | lastSpeed = 0 |
| float | posOffset = 0 |
| float | lastVoltage = 0 |
| uint32_t | lastVoltageUpdate = 0 |
| uint32_t | lastCanMessage = 0 |
| uint32_t | lastPosTime = 0 |
| bool | posWaiting = false |
| bool | reloadPosAfterStartup = false |
| int8_t | nodeId = 0 |
| int8_t | motorId = 0 |
| volatile ODriveState | odriveCurrentState = ODriveState::AXIS_STATE_UNDEFINED |
| volatile uint32_t | errors = 0 |
| volatile uint32_t | odriveMotorFlags = 0 |
| volatile uint32_t | odriveEncoderFlags = 0 |
| volatile uint32_t | odriveControllerFlags = 0 |
| float | maxTorque = 1.0 |
| volatile bool | waitReady = true |
| bool | active = false |
| int32_t | filterId = 0 |
| volatile ODriveLocalState | state = ODriveLocalState::IDLE |
| bool | connected = false |
Additional Inherited Members | |
Static Public Member Functions inherited from ChoosableClass | |
| static bool | isCreatable () |
Static Public Member Functions inherited from PersistentStorage | |
| static std::vector< PersistentStorage * > & | getFlashHandlers () |
| static void | restoreFlashStartupCb () |
Static Public Member Functions inherited from CanHandler | |
| static std::vector< CanHandler * > & | getCANHandlers () |
Static Public Member Functions inherited from CommandHandler | |
| static void | logSerial (std::string string) |
| Send a log formatted sequence. | |
| static void | logSerialDebug (std::string string) |
| Send a log formatted sequence if debug is on. | |
| 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 Public Attributes inherited from MotorDriver | |
| 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 |
Static Public Attributes inherited from Encoder | |
| static ClassIdentifier | info ={.name = "None" , .id=CLSID_ENCODER_NONE, .visibility = ClassVisibility::visible} |
| static const std::vector< class_entry< Encoder > > | all_encoders |
Static Public Attributes inherited from CommandHandler | |
| static bool | logEnabled = true |
Protected Member Functions inherited from CommandHandler | |
| void | setInstance (uint8_t instance) |
| virtual void | addCommandHandler () |
| virtual void | removeCommandHandler () |
Static Protected Member Functions inherited from CommandHandler | |
| static std::vector< uint16_t > & | getCommandHandlerIds () |
Protected Attributes inherited from MotorDriver | |
| std::shared_ptr< Encoder > | drvEncoder = std::make_shared<Encoder>() |
Protected Attributes inherited from ChoosableClass | |
| uint16_t | selectionId |
| Should only be written by ClassChooser during creation. | |
Protected Attributes inherited from PersistentStorage | |
| bool | restoreDelayedFlag = false |
Protected Attributes inherited from Encoder | |
| uint32_t | cpr = 0 |
Protected Attributes inherited from CommandHandler | |
| bool | commandsEnabled = true |
| std::vector< CmdHandlerCommanddef > | registeredCommands |
| CmdHandlerInfo | cmdHandlerInfo |
Static Protected Attributes inherited from PersistentStorage | |
| static bool | startupComplete = false |
Private Member Functions inherited from cpp_freertos::Thread | |
| 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) |
Static Private Member Functions inherited from cpp_freertos::Thread | |
| static void | Yield () |
| static void | StartScheduler () |
| static void | EndScheduler () |
Definition at line 35 of file ODriveCAN.h.
| ODriveCAN::ODriveCAN | ( | uint8_t | id | ) |
Definition at line 40 of file ODriveCAN.cpp.
|
virtual |
Definition at line 61 of file ODriveCAN.cpp.
|
virtual |
Error during can transfer
Reimplemented from CanHandler.
Definition at line 385 of file ODriveCAN.cpp.
|
overridevirtual |
New message received in fifo number
Reimplemented from CanHandler.
Definition at line 389 of file ODriveCAN.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 306 of file ODriveCAN.cpp.
|
overridevirtual |
Gets the amount of counts per full rotation of the encoder
Reimplemented from Encoder.
Definition at line 268 of file ODriveCAN.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 230 of file ODriveCAN.cpp.
|
overridevirtual |
Returns the type of the encoder. Must override this and NOT return NONE in other classes
Reimplemented from Encoder.
Definition at line 277 of file ODriveCAN.cpp.
|
inlinevirtual |
Returns a description of this class
Reimplemented from CommandHandler.
Definition at line 94 of file ODriveCAN.h.
|
pure virtual |
Reimplemented from MotorDriver.
Implemented in ODriveCAN1, and ODriveCAN2.
|
overridevirtual |
Returns the encoder position as raw counts
Reimplemented from Encoder.
Definition at line 263 of file ODriveCAN.cpp.
|
overridevirtual |
Returns a float position in rotations
Reimplemented from Encoder.
Definition at line 251 of file ODriveCAN.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 49 of file ODriveCAN.h.
|
overridevirtual |
Reimplemented from MotorDriver.
Definition at line 260 of file ODriveCAN.cpp.
| void ODriveCAN::readyCb | ( | ) |
| void ODriveCAN::registerCommands | ( | ) |
Definition at line 79 of file ODriveCAN.cpp.
| void ODriveCAN::requestMsg | ( | uint8_t | cmd | ) |
Definition at line 243 of file ODriveCAN.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 92 of file ODriveCAN.cpp.
|
virtual |
Implementation of your actual thread code. You must override this function.
Implements cpp_freertos::Thread.
Definition at line 150 of file ODriveCAN.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 121 of file ODriveCAN.cpp.
| void ODriveCAN::sendMsg | ( | uint8_t | cmd, |
| float | value ) |
|
inline |
Definition at line 52 of file ODriveCAN.h.
| void ODriveCAN::setCanFilter | ( | ) |
Definition at line 67 of file ODriveCAN.cpp.
| void ODriveCAN::setMode | ( | ODriveControlMode | controlMode, |
| ODriveInputMode | inputMode ) |
Definition at line 282 of file ODriveCAN.cpp.
|
overridevirtual |
Must be in encoder cpr if not just used to zero the axis
Reimplemented from Encoder.
Definition at line 237 of file ODriveCAN.cpp.
| void ODriveCAN::setState | ( | ODriveState | state | ) |
Definition at line 287 of file ODriveCAN.cpp.
| void ODriveCAN::setTorque | ( | float | torque | ) |
Definition at line 271 of file ODriveCAN.cpp.
| void ODriveCAN::startAnticogging | ( | ) |
Sends the start anticogging command
Definition at line 301 of file ODriveCAN.cpp.
|
overridevirtual |
Enable the motor driver
Reimplemented from MotorDriver.
Definition at line 224 of file ODriveCAN.cpp.
|
overridevirtual |
Disable the motor driver
Reimplemented from MotorDriver.
Definition at line 217 of file ODriveCAN.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 292 of file ODriveCAN.cpp.
|
private |
Definition at line 124 of file ODriveCAN.h.
|
private |
Definition at line 128 of file ODriveCAN.h.
|
private |
Definition at line 115 of file ODriveCAN.h.
|
private |
Definition at line 126 of file ODriveCAN.h.
|
private |
Definition at line 105 of file ODriveCAN.h.
|
private |
Definition at line 100 of file ODriveCAN.h.
|
private |
Definition at line 107 of file ODriveCAN.h.
|
private |
Definition at line 101 of file ODriveCAN.h.
|
private |
Definition at line 103 of file ODriveCAN.h.
|
private |
Definition at line 104 of file ODriveCAN.h.
|
private |
Definition at line 121 of file ODriveCAN.h.
|
private |
Definition at line 112 of file ODriveCAN.h.
|
private |
Definition at line 111 of file ODriveCAN.h.
|
private |
Definition at line 119 of file ODriveCAN.h.
|
private |
Definition at line 114 of file ODriveCAN.h.
|
private |
Definition at line 118 of file ODriveCAN.h.
|
private |
Definition at line 117 of file ODriveCAN.h.
Definition at line 99 of file ODriveCAN.h.
|
private |
Definition at line 102 of file ODriveCAN.h.
|
private |
Definition at line 108 of file ODriveCAN.h.
|
private |
Definition at line 109 of file ODriveCAN.h.
|
private |
Definition at line 127 of file ODriveCAN.h.
|
private |
Definition at line 122 of file ODriveCAN.h.