Fang-Robotics-MCB
Fang Robotics Team Codebase
Loading...
Searching...
No Matches
dji_motor_encoder.hpp
Go to the documentation of this file.
1/*****************************************************************************/
2/********** !!! WARNING: CODE GENERATED BY TAPROOT. DO NOT EDIT !!! **********/
3/*****************************************************************************/
4
5/*
6 * Copyright (c) 2024 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_ENCODER_HPP_
25#define TAPROOT_DJI_MOTOR_ENCODER_HPP_
26
29#include "tap/util_macros.hpp"
30
31#include "modm/architecture/interface/can_message.hpp"
32#include "modm/math/geometry/angle.hpp"
33
34namespace tap::motor
35{
55{
56public:
57 // 0 - 8191 for dji motors
58 static constexpr uint16_t ENC_RESOLUTION = 8192;
59
60 // Internal gear ratio of the following motors
61 static constexpr float GEAR_RATIO_M3508 = 3591.0f / 187.0f;
62 static constexpr float GEAR_RATIO_GM3510_L1 = 3.7f / 1.0f;
63 static constexpr float GEAR_RATIO_GM3510_L2 = 5.2f / 1.0f;
64 static constexpr float GEAR_RATIO_GM3510_L3 = 19.0f / 1.0f;
65 static constexpr float GEAR_RATIO_GM3510_L4 = 27.0f / 1.0f;
66 static constexpr float GEAR_RATIO_M2006 = 36.0f / 1.0f;
67 static constexpr float GEAR_RATIO_GM6020 = 1.0f / 1.0f;
68
77 DjiMotorEncoder(bool isInverted, float gearRatio = 1, uint32_t encoderHomePosition = 0);
78
79 void initialize() override{};
80
81 bool isOnline() const override;
82
83 float getVelocity() const override;
84
88 mockable int16_t getShaftRPM() const;
89
91
92
99 mockable void processMessage(const modm::can::Message& message);
100
101private:
102 // wait time before the motor is considered disconnected, in milliseconds
103 static const uint32_t MOTOR_DISCONNECT_TIME = 100;
104
105 tap::arch::MilliTimeout encoderDisconnectTimeout;
106
107 int16_t shaftRPM;
108};
109
110} // namespace tap::motor
111
112#endif // TAPROOT_DJI_MOTOR_ENCODER_HPP_
Definition timeout.hpp:44
Definition wrapped_encoder.hpp:36
const float gearRatio
Definition wrapped_encoder.hpp:95
Definition dji_motor_encoder.hpp:55
static constexpr float GEAR_RATIO_GM6020
Definition dji_motor_encoder.hpp:67
static constexpr float GEAR_RATIO_GM3510_L3
Definition dji_motor_encoder.hpp:64
static constexpr float GEAR_RATIO_GM3510_L1
Definition dji_motor_encoder.hpp:62
mockable void processMessage(const modm::can::Message &message)
Definition dji_motor_encoder.cpp:39
static constexpr float GEAR_RATIO_M2006
Definition dji_motor_encoder.hpp:66
void initialize() override
Definition dji_motor_encoder.hpp:79
static constexpr float GEAR_RATIO_GM3510_L2
Definition dji_motor_encoder.hpp:63
static constexpr float GEAR_RATIO_M3508
Definition dji_motor_encoder.hpp:61
bool isOnline() const override
Definition dji_motor_encoder.cpp:51
mockable int16_t getShaftRPM() const
Definition dji_motor_encoder.cpp:66
static constexpr float GEAR_RATIO_GM3510_L4
Definition dji_motor_encoder.hpp:65
static constexpr uint16_t ENC_RESOLUTION
Definition dji_motor_encoder.hpp:58
float getVelocity() const override
Definition dji_motor_encoder.cpp:61
Definition dji_motor.cpp:41
#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