Fang-Robotics-MCB
Fang Robotics Team Codebase
Loading...
Searching...
No Matches
dji_motor_tx_handler.hpp
Go to the documentation of this file.
1/*****************************************************************************/
2/********** !!! WARNING: CODE GENERATED BY TAPROOT. DO NOT EDIT !!! **********/
3/*****************************************************************************/
4
5/*
6 * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington <robomstr@uw.edu>
7 *
8 * This file is part of Taproot.
9 *
10 * Taproot is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * Taproot is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with Taproot. If not, see <https://www.gnu.org/licenses/>.
22 */
23
24#ifndef TAPROOT_DJI_MOTOR_TX_HANDLER_HPP_
25#define TAPROOT_DJI_MOTOR_TX_HANDLER_HPP_
26
27#include <limits.h>
28
29#include "tap/util_macros.hpp"
30
31#include "modm/architecture/interface/can_message.hpp"
32
33#include "dji_motor_ids.hpp"
34
35namespace tap
36{
37class Drivers;
38}
39
40namespace tap::motor
41{
42class DjiMotor;
43
50#define DJI_MOTOR_TO_NORMALIZED_ID(id) \
51 static_cast<uint32_t>( \
52 (id < tap::motor::MOTOR1) ? (tap::motor::DjiMotorTxHandler::DJI_MOTORS_PER_CAN) \
53 : (id - tap::motor::MOTOR1))
54
60#define NORMALIZED_ID_TO_DJI_MOTOR(idx) \
61 static_cast<tap::motor::MotorId>(idx + static_cast<int32_t>(tap::motor::MotorId::MOTOR1))
62
74{
75public:
77 static constexpr int DJI_MOTORS_PER_CAN = 8;
79 static constexpr int CAN_DJI_MESSAGE_SEND_LENGTH = 8;
81 static constexpr uint32_t CAN_DJI_LOW_IDENTIFIER = 0X200;
83 static constexpr uint32_t CAN_DJI_HIGH_IDENTIFIER = 0X1FF;
85 static constexpr uint32_t CAN_DJI_6020_CURRENT_IDENTIFIER = 0x1FE;
86
90
91
96
103
108
109 mockable DjiMotor const* getCan1Motor(MotorId motorId);
110
111 mockable DjiMotor const* getCan2Motor(MotorId motorId);
112
113protected:
115
118
119 void addMotorToManager(DjiMotor** canMotorStore, DjiMotor* const motor);
120
122 DjiMotor** canMotorStore,
123 modm::can::Message* messageLow,
124 modm::can::Message* messageHigh,
125 modm::can::Message* message6020Current,
126 bool* validMotorMessageLow,
127 bool* validMotorMessageHigh,
128 bool* validMotorMessage6020Current);
129
130 void removeFromMotorManager(const DjiMotor& motor, DjiMotor** motorStore);
131};
132
133} // namespace tap::motor
134
135#endif // TAPROOT_DJI_MOTOR_TX_HANDLER_HPP_
Definition drivers.hpp:70
Definition dji_motor_tx_handler.hpp:74
mockable void addMotorToManager(DjiMotor *motor)
Definition dji_motor_tx_handler.cpp:49
DjiMotor * can1MotorStore[DJI_MOTORS_PER_CAN]
Definition dji_motor_tx_handler.hpp:116
static constexpr int DJI_MOTORS_PER_CAN
Definition dji_motor_tx_handler.hpp:77
static constexpr uint32_t CAN_DJI_6020_CURRENT_IDENTIFIER
Definition dji_motor_tx_handler.hpp:85
mockable void removeFromMotorManager(const DjiMotor &motor)
Definition dji_motor_tx_handler.cpp:198
static constexpr uint32_t CAN_DJI_HIGH_IDENTIFIER
Definition dji_motor_tx_handler.hpp:83
mockable void encodeAndSendCanData()
Definition dji_motor_tx_handler.cpp:64
mockable DjiMotor const * getCan1Motor(MotorId motorId)
Definition dji_motor_tx_handler.cpp:221
mockable ~DjiMotorTxHandler()=default
static constexpr uint32_t CAN_DJI_LOW_IDENTIFIER
Definition dji_motor_tx_handler.hpp:81
void serializeMotorStoreSendData(DjiMotor **canMotorStore, modm::can::Message *messageLow, modm::can::Message *messageHigh, modm::can::Message *message6020Current, bool *validMotorMessageLow, bool *validMotorMessageHigh, bool *validMotorMessage6020Current)
Definition dji_motor_tx_handler.cpp:164
static constexpr int CAN_DJI_MESSAGE_SEND_LENGTH
Definition dji_motor_tx_handler.hpp:79
DjiMotorTxHandler(Drivers *drivers)
Definition dji_motor_tx_handler.hpp:87
DjiMotor * can2MotorStore[DJI_MOTORS_PER_CAN]
Definition dji_motor_tx_handler.hpp:117
mockable DjiMotor const * getCan2Motor(MotorId motorId)
Definition dji_motor_tx_handler.cpp:227
Drivers * drivers
Definition dji_motor_tx_handler.hpp:114
Definition dji_motor.hpp:71
Definition brushlessutils.cpp:4
Definition dji_motor.cpp:41
MotorId
Definition dji_motor_ids.hpp:38
Definition ballistics.cpp:29
tap::Drivers Drivers
Definition drivers.hpp:11
#define mockable
Wrap class functions that are not already virtual in this function if you wish to mock them.
Definition util_macros.hpp:38
#define DISALLOW_COPY_AND_ASSIGN(Typename)
Definition util_macros.hpp:27