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
initializefunction is called, this object’saddMotorToManagerfunction 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
encodeAndSendCanDatafunction.Public Functions
-
mockable ~DjiMotorTxHandler() = default¶
- mockable 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
- mockable 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.
- mockable void removeFromMotorManager (const DjiMotor &motor)
Removes the motor from the motor manager.
- mockable DjiMotor const * getCan1Motor (MotorId motorId)
- mockable DjiMotor const * getCan2Motor (MotorId motorId)
Public Static Attributes
-
static constexpr int DJI_MOTORS_PER_CAN = 8¶
Number of motors on each CAN bus.
-
static constexpr int CAN_DJI_MESSAGE_SEND_LENGTH = 8¶
CAN message length of each motor control message.
-
static constexpr uint32_t CAN_DJI_LOW_IDENTIFIER = 0X200¶
CAN message identifier for “low” segment (low 4 CAN motor IDs) of control message.
-
static constexpr uint32_t CAN_DJI_HIGH_IDENTIFIER = 0X1FF¶
CAN message identifier for “high” segment (high 4 CAN motor IDs) of control message.
-
static constexpr uint32_t CAN_DJI_6020_CURRENT_IDENTIFIER = 0x1FE¶
CAN message identifier for 6020s in current mode of control message.
Protected Functions
Protected Attributes
-
DjiMotor *can1MotorStore[DJI_MOTORS_PER_CAN] = {0}¶
-
DjiMotor *can2MotorStore[DJI_MOTORS_PER_CAN] = {0}¶
-
mockable ~DjiMotorTxHandler() = default¶