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

#include <dji_gm6020_old.hpp>

Inheritance diagram for trap::motor::DjiGM6020Old:
Collaboration diagram for trap::motor::DjiGM6020Old:

Classes

struct  Config
 

Public Member Functions

 DjiGM6020Old (Drivers &drivers, const Config &config)
 
 DjiGM6020Old (Drivers &drivers, tap::motor::MotorId motorId, tap::can::CanBus canBus, const char *name, bool inverted, double gearRatio, const DjiSpeedPid::Config &speedConfig, bool currentControl)
 
mockable ~DjiGM6020Old ()=default
 
mockable void update () override
 
mockable void setTargetPosition (const Radians &targetPosition) override
 
mockable Radians getPosition () const
 
mockable void initialize () override
 
mockable void setDesiredOutput (DjiMotorOutput desiredOutput)
 
mockable bool isMotorOnline () const
 
mockable Celsius getTemperature () const
 
mockable tap::can::CanBus getCanBus () const
 
mockable const char * getName () const
 

Static Public Attributes

static const DjiMotorOutput k_maxOutput {tap::motor::DjiMotor::MAX_OUTPUT_GM6020}
 

Detailed Description

Wrapper for DJI motor for the DJI M3508 on a CAN bus

Constructor & Destructor Documentation

◆ DjiGM6020Old() [1/2]

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

◆ DjiGM6020Old() [2/2]

trap::motor::DjiGM6020Old::DjiGM6020Old ( Drivers drivers,
tap::motor::MotorId  motorId,
tap::can::CanBus  canBus,
const char *  name,
bool  inverted,
double  gearRatio,
const DjiSpeedPid::Config speedConfig,
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 - the ratio of input revolutions per output revolution 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.

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

◆ ~DjiGM6020Old()

mockable trap::motor::DjiGM6020Old::~DjiGM6020Old ( )
default

Member Function Documentation

◆ getCanBus()

tap::can::CanBus trap::motor::DjiGM6020Old::getCanBus ( ) const

◆ getName()

const char * trap::motor::DjiGM6020Old::getName ( ) const

◆ getPosition()

Radians trap::motor::DjiGM6020Old::getPosition ( ) const

Returns the last reported RPM from CAN

◆ getTemperature()

Celsius trap::motor::DjiGM6020Old::getTemperature ( ) const

Returns the reported temperature in celsius. The temperature was provided in an int8_t

◆ initialize()

void trap::motor::DjiGM6020Old::initialize ( )
override

It must be called for the motor to properly function.

◆ isMotorOnline()

bool trap::motor::DjiGM6020Old::isMotorOnline ( ) const

true if a can message has been received within the last MOTOR_DISCONNECT_TIME.

◆ setDesiredOutput()

void trap::motor::DjiGM6020Old::setDesiredOutput ( DjiMotorOutput  desiredOutput)

The desired motor output. It must be limited to a 16 bit int.

◆ setTargetPosition()

void trap::motor::DjiGM6020Old::setTargetPosition ( const Radians targetPosition)
override

Sets the desired speed for the pid to target

◆ update()

void trap::motor::DjiGM6020Old::update ( )
override

Must be called regularly to update the motor pid and set the motor output

Member Data Documentation

◆ k_maxOutput

const DjiMotorOutput trap::motor::DjiGM6020Old::k_maxOutput {tap::motor::DjiMotor::MAX_OUTPUT_GM6020}
static

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