Adding a New Motor Type¶
Motor.h¶
Create a class for your new motor type that inherits its interface from the
_Motorclass:class _YourMotorType : public _Motor { public: _YourMotorType(config_defs::joint_id id, ExoData* exo_data, int enable_pin); virtual ~_YourMotorType(){}; void transaction(float torque); void read_data(); void send_data(float torque); void on_off(); bool enable(); bool enable(bool overide); void zero(); protected: ... };
Add any protected member variables or functions that will be needed to operate your motor.
Create a specific motor class of this type that inherits the motor type class you just created:
class ANewMotor : public _YourMotorType { public: ANewMotor(config_defs::joint_id id, ExoData* exo_data, int enable_pin); // constructor: type is the motor type ~ANewMotor(){}; };
Add any additional protected member variables or functions needed to operate your motor.
Motor.cpp¶
Define the behavior of the member functions of
_YourMotorType. - Ideally, these behaviors will be shared by all motors of this type.Define the behavior of the member functions and any class-specific variables for
ANewMotor.
Connect to Everything Else¶
Follow the steps in AddingNewCanMotor to connect this new motor type to the rest of the codebase. - This step is detailed in the referenced document so that you only need to update information in one place.