Fang-Robotics-MCB
Fang Robotics Team Codebase
Loading...
Searching...
No Matches
trap::motor::DjiM3508 Class Reference

#include <dji_m3508.hpp>

Inheritance diagram for trap::motor::DjiM3508:
Collaboration diagram for trap::motor::DjiM3508:

Public Member Functions

 DjiMotor (Drivers &drivers, const Config &config)
 
 DjiMotor (Drivers &drivers, tap::motor::MotorId motorId, tap::can::CanBus canBus, const char *name, bool inverted, double externalEncoderGearRatio, bool currentControl)
 
- Public Member Functions inherited from trap::motor::DjiMotor
 DjiMotor (Drivers &drivers, const Config &config)
 
 DjiMotor (Drivers &drivers, tap::motor::MotorId motorId, tap::can::CanBus canBus, const char *name, bool inverted, double externalEncoderGearRatio, bool currentControl)
 
mockable ~DjiMotor ()
 
void initialize () override
 
void update () override
 left blank
 
Radians getAngularPosition () const override
 
RPM getAngularVelocity () const override
 
void setTargetOutput (const DjiMotorOutput &output) override
 
bool isMotorOnline () const
 
Celsius getTemperature () const
 
tap::can::CanBus getCanBus () const
 
const char * getName () const
 

Static Public Attributes

static constexpr DjiMotorOutput kMaxOutput {tap::motor::DjiMotor::MAX_OUTPUT_C620}
 
- Static Public Attributes inherited from trap::motor::DjiMotor
static constexpr DjiMotorOutput kMaxOutput {std::numeric_limits<DjiMotorOutput>::max()}
 

Detailed Description

Driver for a Dji M3508 motor controlled by a Dji C620 controller

Member Function Documentation

◆ DjiMotor() [1/2]

trap::motor::DjiMotor::DjiMotor ( Drivers drivers,
const Config config 
)

Recommended constructor for storing settings in a config file due to the convenicence of structs

The

◆ DjiMotor() [2/2]

trap::motor::DjiMotor::DjiMotor ( Drivers drivers,
tap::motor::MotorId  motorId,
tap::can::CanBus  canBus,
const char *  name,
bool  inverted,
double  externalEncoderGearRatio,
bool  currentControl 
)

drivers - the drivers struct motorId - the motor controller id canBus - the can bus the motor controller is on. THIS CANNOT BE HIGHER THAN 4 name - the name of the motor for the controller menu gearRatio - this should be set to one if you do not use an external encoder in the taproot styyle!!!!! pid config: make sure the maxOutput does not exceed DjiM3508 k_maxOutput. This would lead to undefined behavior. An assertion has been placed to prevent the code from continuing.

IMPORTANT if you are using GM6020 Why an ID not more thn 4? The GM6020 motor have their id offset by + 4 for some unholy DJI reason. (Ask their sages.) Taproot decided to keep the regular motor ids, which meant that if you place MotorID::Motor1, it gets mapped to MotorID::Motor5 implicitly (irl, the GM6020 motor id needs to be set to 1, but the tapproot codewise motorId must be 5) the enum does not go above Motor8, which means in order to access a Gm6020 with irl MotorId::Motor5, the codewise motorId needs to be 9, which is not supported.

Fortunately, this ancient ritual does not need any blood sacrifice.

Long story short:: traproot currently uses the correct motor ID, taproot does not, so keep this in mind.

This oddity is a rite of passage as it is not really mentioned until the initiate tries to move a GM6020. Although, as this is Fang Robotic's first year, and we had no elders to warn us of the dangers, we lost 4 hours to this ordeal.

However, taproot ended up keeping the regular motorID

Member Data Documentation

◆ kMaxOutput

constexpr DjiMotorOutput trap::motor::DjiM3508::kMaxOutput {tap::motor::DjiMotor::MAX_OUTPUT_C620}
staticconstexpr

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