ODrive用ライブラリ

Dependents:   ODriveTest

Committer:
m204517
Date:
Fri Sep 13 05:05:14 2019 +0000
Revision:
0:c191cf9bf1a3
operability confirmed

Who changed what in which revision?

UserRevisionLine numberNew contents of line
m204517 0:c191cf9bf1a3 1
m204517 0:c191cf9bf1a3 2 #ifndef ODriveLibTest_h
m204517 0:c191cf9bf1a3 3 #define ODriveLibTest_h
m204517 0:c191cf9bf1a3 4
m204517 0:c191cf9bf1a3 5 #include "mbed.h"
m204517 0:c191cf9bf1a3 6 #include "string"
m204517 0:c191cf9bf1a3 7
m204517 0:c191cf9bf1a3 8 //using std::string;
m204517 0:c191cf9bf1a3 9
m204517 0:c191cf9bf1a3 10 class ODriveLibTest {
m204517 0:c191cf9bf1a3 11 public:
m204517 0:c191cf9bf1a3 12 enum AxisState_t {
m204517 0:c191cf9bf1a3 13 AXIS_STATE_UNDEFINED = 0, //<! will fall through to idle
m204517 0:c191cf9bf1a3 14 AXIS_STATE_IDLE = 1, //<! disable PWM and do nothing
m204517 0:c191cf9bf1a3 15 AXIS_STATE_STARTUP_SEQUENCE = 2, //<! the actual sequence is defined by the config.startup_... flags
m204517 0:c191cf9bf1a3 16 AXIS_STATE_FULL_CALIBRATION_SEQUENCE = 3, //<! run all calibration procedures, then idle
m204517 0:c191cf9bf1a3 17 AXIS_STATE_MOTOR_CALIBRATION = 4, //<! run motor calibration
m204517 0:c191cf9bf1a3 18 AXIS_STATE_SENSORLESS_CONTROL = 5, //<! run sensorless control
m204517 0:c191cf9bf1a3 19 AXIS_STATE_ENCODER_INDEX_SEARCH = 6, //<! run encoder index search
m204517 0:c191cf9bf1a3 20 AXIS_STATE_ENCODER_OFFSET_CALIBRATION = 7, //<! run encoder offset calibration
m204517 0:c191cf9bf1a3 21 AXIS_STATE_CLOSED_LOOP_CONTROL = 8 //<! run closed loop control
m204517 0:c191cf9bf1a3 22 };
m204517 0:c191cf9bf1a3 23
m204517 0:c191cf9bf1a3 24 ODriveLibTest(Stream& serial);
m204517 0:c191cf9bf1a3 25
m204517 0:c191cf9bf1a3 26 // Commands
m204517 0:c191cf9bf1a3 27 void SetLimit(int motor_number, float vel_limit, float current_lim);
m204517 0:c191cf9bf1a3 28 void ODriveInit(int motor_number);
m204517 0:c191cf9bf1a3 29 //void SetPosition(int motor_number, float position);
m204517 0:c191cf9bf1a3 30 //void SetPosition(int motor_number, float position, float velocity_feedforward);
m204517 0:c191cf9bf1a3 31 void SetPosition(int motor_number, float position, float velocity_feedforward = 0.0f, float current_feedforward = 0.0f);
m204517 0:c191cf9bf1a3 32 void SetVelocity(int motor_number, float velocity);
m204517 0:c191cf9bf1a3 33 void SetVelocity(int motor_number, float velocity, float current_feedforward);
m204517 0:c191cf9bf1a3 34 void SetCurrent(int motor_number, float current);
m204517 0:c191cf9bf1a3 35 void TrapezoidalMove(int motor_number, float position);
m204517 0:c191cf9bf1a3 36 // Getters
m204517 0:c191cf9bf1a3 37 float GetVelocity(int motor_number);
m204517 0:c191cf9bf1a3 38 // General params
m204517 0:c191cf9bf1a3 39 float readFloat();
m204517 0:c191cf9bf1a3 40 int32_t readInt();
m204517 0:c191cf9bf1a3 41
m204517 0:c191cf9bf1a3 42 // State helper
m204517 0:c191cf9bf1a3 43 bool run_state(int axis, int requested_state, bool wait);
m204517 0:c191cf9bf1a3 44 private:
m204517 0:c191cf9bf1a3 45 string readString();
m204517 0:c191cf9bf1a3 46
m204517 0:c191cf9bf1a3 47 Stream& serial_;
m204517 0:c191cf9bf1a3 48 };
m204517 0:c191cf9bf1a3 49
m204517 0:c191cf9bf1a3 50 #endif //ODriveArduino_h