Fang-Robotics-MCB
Fang Robotics Team Codebase
Loading...
Searching...
No Matches
tap::motor::DjiMotorTxHandler Class Reference

#include <dji_motor_tx_handler.hpp>

Collaboration diagram for tap::motor::DjiMotorTxHandler:

Public Member Functions

 DjiMotorTxHandler (Drivers *drivers)
 
mockable ~DjiMotorTxHandler ()=default
 
mockable void addMotorToManager (DjiMotor *motor)
 
mockable void encodeAndSendCanData ()
 
mockable void removeFromMotorManager (const DjiMotor &motor)
 
mockable DjiMotor const * getCan1Motor (MotorId motorId)
 
mockable DjiMotor const * getCan2Motor (MotorId motorId)
 

Static Public Attributes

static constexpr int DJI_MOTORS_PER_CAN = 8
 
static constexpr int CAN_DJI_MESSAGE_SEND_LENGTH = 8
 
static constexpr uint32_t CAN_DJI_LOW_IDENTIFIER = 0X200
 
static constexpr uint32_t CAN_DJI_HIGH_IDENTIFIER = 0X1FF
 
static constexpr uint32_t CAN_DJI_6020_CURRENT_IDENTIFIER = 0x1FE
 

Protected Member Functions

void addMotorToManager (DjiMotor **canMotorStore, DjiMotor *const motor)
 
void serializeMotorStoreSendData (DjiMotor **canMotorStore, modm::can::Message *messageLow, modm::can::Message *messageHigh, modm::can::Message *message6020Current, bool *validMotorMessageLow, bool *validMotorMessageHigh, bool *validMotorMessage6020Current)
 
void removeFromMotorManager (const DjiMotor &motor, DjiMotor **motorStore)
 

Protected Attributes

Driversdrivers
 
DjiMotorcan1MotorStore [DJI_MOTORS_PER_CAN] = {0}
 
DjiMotorcan2MotorStore [DJI_MOTORS_PER_CAN] = {0}
 

Detailed Description

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's addMotorToManager 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.

Constructor & Destructor Documentation

◆ DjiMotorTxHandler()

tap::motor::DjiMotorTxHandler::DjiMotorTxHandler ( Drivers drivers)
inline

◆ ~DjiMotorTxHandler()

mockable tap::motor::DjiMotorTxHandler::~DjiMotorTxHandler ( )
default

Member Function Documentation

◆ addMotorToManager() [1/2]

void tap::motor::DjiMotorTxHandler::addMotorToManager ( DjiMotor **  canMotorStore,
DjiMotor *const  motor 
)
protected

◆ addMotorToManager() [2/2]

void tap::motor::DjiMotorTxHandler::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

◆ encodeAndSendCanData()

void tap::motor::DjiMotorTxHandler::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.

◆ getCan1Motor()

DjiMotor const * tap::motor::DjiMotorTxHandler::getCan1Motor ( MotorId  motorId)

◆ getCan2Motor()

DjiMotor const * tap::motor::DjiMotorTxHandler::getCan2Motor ( MotorId  motorId)

◆ removeFromMotorManager() [1/2]

void tap::motor::DjiMotorTxHandler::removeFromMotorManager ( const DjiMotor motor)

Removes the motor from the motor manager.

◆ removeFromMotorManager() [2/2]

void tap::motor::DjiMotorTxHandler::removeFromMotorManager ( const DjiMotor motor,
DjiMotor **  motorStore 
)
protected

◆ serializeMotorStoreSendData()

void tap::motor::DjiMotorTxHandler::serializeMotorStoreSendData ( DjiMotor **  canMotorStore,
modm::can::Message *  messageLow,
modm::can::Message *  messageHigh,
modm::can::Message *  message6020Current,
bool *  validMotorMessageLow,
bool *  validMotorMessageHigh,
bool *  validMotorMessage6020Current 
)
protected

Member Data Documentation

◆ can1MotorStore

DjiMotor* tap::motor::DjiMotorTxHandler::can1MotorStore[DJI_MOTORS_PER_CAN] = {0}
protected

◆ can2MotorStore

DjiMotor* tap::motor::DjiMotorTxHandler::can2MotorStore[DJI_MOTORS_PER_CAN] = {0}
protected

◆ CAN_DJI_6020_CURRENT_IDENTIFIER

constexpr uint32_t tap::motor::DjiMotorTxHandler::CAN_DJI_6020_CURRENT_IDENTIFIER = 0x1FE
staticconstexpr

CAN message identifier for 6020s in current mode of control message.

◆ CAN_DJI_HIGH_IDENTIFIER

constexpr uint32_t tap::motor::DjiMotorTxHandler::CAN_DJI_HIGH_IDENTIFIER = 0X1FF
staticconstexpr

CAN message identifier for "high" segment (high 4 CAN motor IDs) of control message.

◆ CAN_DJI_LOW_IDENTIFIER

constexpr uint32_t tap::motor::DjiMotorTxHandler::CAN_DJI_LOW_IDENTIFIER = 0X200
staticconstexpr

CAN message identifier for "low" segment (low 4 CAN motor IDs) of control message.

◆ CAN_DJI_MESSAGE_SEND_LENGTH

constexpr int tap::motor::DjiMotorTxHandler::CAN_DJI_MESSAGE_SEND_LENGTH = 8
staticconstexpr

CAN message length of each motor control message.

◆ DJI_MOTORS_PER_CAN

constexpr int tap::motor::DjiMotorTxHandler::DJI_MOTORS_PER_CAN = 8
staticconstexpr

Number of motors on each CAN bus.

◆ drivers

Drivers* tap::motor::DjiMotorTxHandler::drivers
protected

The documentation for this class was generated from the following files: