ODrive用ライブラリ

Dependents:   ODriveTest

ODriveLibTest.h

Committer:
m204517
Date:
2019-09-13
Revision:
1:dc0c02b4a1b0
Parent:
0:c191cf9bf1a3

File content as of revision 1:dc0c02b4a1b0:


#ifndef ODriveLibTest_h
#define ODriveLibTest_h

#include "mbed.h"
#include "string"

//using std::string;

class ODriveLibTest {
public:
    enum AxisState_t {
        AXIS_STATE_UNDEFINED = 0,           //<! will fall through to idle
        AXIS_STATE_IDLE = 1,                //<! disable PWM and do nothing
        AXIS_STATE_STARTUP_SEQUENCE = 2, //<! the actual sequence is defined by the config.startup_... flags
        AXIS_STATE_FULL_CALIBRATION_SEQUENCE = 3,   //<! run all calibration procedures, then idle
        AXIS_STATE_MOTOR_CALIBRATION = 4,   //<! run motor calibration
        AXIS_STATE_SENSORLESS_CONTROL = 5,  //<! run sensorless control
        AXIS_STATE_ENCODER_INDEX_SEARCH = 6, //<! run encoder index search
        AXIS_STATE_ENCODER_OFFSET_CALIBRATION = 7, //<! run encoder offset calibration
        AXIS_STATE_CLOSED_LOOP_CONTROL = 8  //<! run closed loop control
    };

    ODriveLibTest(Stream& serial);

    // Commands
    void SetLimit(int motor_number, float vel_limit, float current_lim);
    void ODriveInit(int motor_number);
    //void SetPosition(int motor_number, float position);
    //void SetPosition(int motor_number, float position, float velocity_feedforward);
    void SetPosition(int motor_number, float position, float velocity_feedforward = 0.0f, float current_feedforward = 0.0f);
    void SetVelocity(int motor_number, float velocity);
    void SetVelocity(int motor_number, float velocity, float current_feedforward);
    void SetCurrent(int motor_number, float current);
    void TrapezoidalMove(int motor_number, float position);
    // Getters
    float GetVelocity(int motor_number);
    // General params
    float readFloat();
    int32_t readInt();

    // State helper
    bool run_state(int axis, int requested_state, bool wait);
private:
    string readString();

    Stream& serial_;
};

#endif //ODriveArduino_h