Class DjiM3508

Nested Relationships

Nested Types

Inheritance Relationships

Base Type

  • public fang::motor::ISpeedMotor

Class Documentation

class DjiM3508 : public virtual fang::motor::ISpeedMotor

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

Public Functions

DjiM3508(Drivers &drivers, const Config &config)
DjiM3508(Drivers &drivers, tap::motor::MotorId motorId, tap::can::CanBus canBus, const char *name, bool inverted, double gearRatio, const DjiSpeedPid::Config &speedConfig)

drivers - the drivers struct motorId - the motor controller id canBus - the can bus the motor controller is on 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.

mockable void update () override

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

mockable void setTargetSpeed (const RPM &targetSpeed)

Sets the desired speed for the pid to target

mockable RPM getSpeed () const

Returns the last reported RPM from CAN

mockable void initialize () override

It must be called for the motor to properly function.

mockable void setDesiredOutput (DjiMotorOutput desiredOutput)

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

mockable bool isMotorOnline () const

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

mockable Celsius getTemperature () const

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

mockable tap::can::CanBus getCanBus () const
mockable const char * getName () const
mockable ~DjiM3508() = default

Public Static Attributes

static constexpr DjiMotorOutput k_maxOutput = {tap::motor::DjiMotor::MAX_OUTPUT_C620}

Maximum output that can be sent to the C620 controller.

static constexpr double k_factoryGearboxRatio = {tap::motor::DjiMotorEncoder::GEAR_RATIO_M3508}

The gear ratio for the gearbox that the m3508 ships with.

struct Config

Public Members

tap::motor::MotorId motorId
tap::can::CanBus canBus
const char *name
bool inverted
double gearRatio
DjiSpeedPid::Config speedPidConfig