Class DjiMotorEncoder¶
Defined in File dji_motor_encoder.hpp
Inheritance Relationships¶
Base Type¶
public tap::encoder::WrappedEncoder(Class WrappedEncoder)
Class Documentation¶
-
class DjiMotorEncoder : public tap::encoder::WrappedEncoder¶
A class designed to interface with the encoder for DJI brand motors and motor controllers over CAN. This includes the C610 and C620 motor controllers and the GM6020 motor (that has a built-in motor controller).
DJI motor encoders store a consistent encoding for a given angle across power-cycles. This means the encoder angle reported by the motor can have meaning if the encoding for an angle is unique as it is for the GM6020s. However for geared motors like the M3508 where a full encoder revolution does not correspond 1:1 to a shaft revolution, it is impossible to know the orientation of the shaft given just the encoder value.
Combining them with some form of absolute encoder on the output shaft would give you knowledge of the orientation of the output shaft.
Note
: the default positive rotation direction (i.e.: when
this->isMotorInverted() == false) is counter clockwise when looking at the shaft from the side opposite the motor. This is specified in the C620 user manual (page 18).Public Functions
-
DjiMotorEncoder(bool isInverted, float gearRatio = 1, uint32_t encoderHomePosition = 0)¶
- Parameters:
isInverted – if
falsethe positive rotation direction of the shaft is counter-clockwise when looking at the shaft from. Iftruethen the positive rotation direction will be clockwise.encoderResolution – the number of encoder ticks before the value wraps.
gearRatio – the ratio of input revolutions to output revolutions of this encoder.
encoderHomePosition – the zero position for the encoder in encoder ticks.
-
inline virtual void initialize() override¶
-
virtual bool isOnline() const override¶
-
virtual float getVelocity() const override¶
- mockable int16_t getShaftRPM () const
The current RPM reported by the motor controller.
- mockable void processMessage (const modm::can::Message &message)
Overrides virtual method in the can class, called every time a message with the CAN message id this class is attached to is received by the can receive handler. Parses the data in the message and updates this class’s fields accordingly.
- Parameters:
message – [in] the message to be processed.
Public Static Attributes
-
static constexpr uint16_t ENC_RESOLUTION = 8192¶
-
static constexpr float GEAR_RATIO_M3508 = 3591.0f / 187.0f¶
-
static constexpr float GEAR_RATIO_GM3510_L1 = 3.7f / 1.0f¶
-
static constexpr float GEAR_RATIO_GM3510_L2 = 5.2f / 1.0f¶
-
static constexpr float GEAR_RATIO_GM3510_L3 = 19.0f / 1.0f¶
-
static constexpr float GEAR_RATIO_GM3510_L4 = 27.0f / 1.0f¶
-
static constexpr float GEAR_RATIO_M2006 = 36.0f / 1.0f¶
-
static constexpr float GEAR_RATIO_GM6020 = 1.0f / 1.0f¶
-
DjiMotorEncoder(bool isInverted, float gearRatio = 1, uint32_t encoderHomePosition = 0)¶