|
Fang-Robotics-MCB
Fang Robotics Team Codebase
|
#include <dji_motor_tx_handler.hpp>

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 | |
| Drivers * | drivers |
| DjiMotor * | can1MotorStore [DJI_MOTORS_PER_CAN] = {0} |
| DjiMotor * | can2MotorStore [DJI_MOTORS_PER_CAN] = {0} |
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.
|
inline |
|
default |
|
protected |
| 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
| 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.
| void tap::motor::DjiMotorTxHandler::removeFromMotorManager | ( | const DjiMotor & | motor | ) |
Removes the motor from the motor manager.
|
protected |
|
protected |
|
protected |
|
protected |
|
staticconstexpr |
CAN message identifier for 6020s in current mode of control message.
|
staticconstexpr |
CAN message identifier for "high" segment (high 4 CAN motor IDs) of control message.
|
staticconstexpr |
CAN message identifier for "low" segment (low 4 CAN motor IDs) of control message.
|
staticconstexpr |
CAN message length of each motor control message.
|
staticconstexpr |
Number of motors on each CAN bus.
|
protected |