Class DjiMotorTxHandler
Defined in File dji_motor_tx_handler.hpp
Class Documentation
-
class DjiMotorTxHandler
Uses modm can interface to send CAN packets to
DjiMotor
’s connected to the two CAN buses.To use this class properly, declare a motor somewhere, then call the initialize method, which allows one to start interacting with a motor connected via CAN bus. When the motor’s
initialize
function is called, this object’saddMotorToManager
function is called and the motor is ready to have its control information sent to the motor on the bus.To send messages, call this class’s
encodeAndSendCanData
function.Public Functions
-
inline DjiMotorTxHandler(Drivers *drivers)
-
~DjiMotorTxHandler() = default
-
void addMotorToManager(DjiMotor *motor)
Adds the motor to the manager so that it can receive motor messages from the CAN bus. If there is already a motor with the same ID in the manager, the program will abort
-
void encodeAndSendCanData()
Sends motor commands across the CAN bus. Sends up to 4 messages (2 per CAN bus), though it may send less depending on which motors have been registered with the motor manager. Each messages encodes motor controller command information for up to 4 motors.
Public Static Attributes
-
static int DJI_MOTORS_PER_CAN = 8
Number of motors on each CAN bus.
-
static int CAN_DJI_MESSAGE_SEND_LENGTH = 8
CAN message length of each motor control message.
-
static uint32_t CAN_DJI_LOW_IDENTIFIER = 0X200
CAN message identifier for “low” segment (low 4 CAN motor IDs) of control message.
-
static uint32_t CAN_DJI_HIGH_IDENTIFIER = 0X1FF
CAN message identifier for “high” segment (high 4 CAN motor IDs) of control message.
-
static uint32_t CAN_DJI_6020_CURRENT_IDENTIFIER = 0x1FE
CAN message identifier for 6020s in current mode of control message.
Protected Functions
Protected Attributes
-
Drivers *drivers
-
DjiMotor *can1MotorStore[DJI_MOTORS_PER_CAN] = {0}
-
DjiMotor *can2MotorStore[DJI_MOTORS_PER_CAN] = {0}
-
inline DjiMotorTxHandler(Drivers *drivers)