Delta Robot example

Dependencies:   BufferedSerial Eigen

Fork of TCPSocket_Example by mbed_example

odrive.h

Committer:
je310
Date:
2018-10-07
Revision:
4:778bc352c47f
Parent:
3:10fa3102c2d7

File content as of revision 4:778bc352c47f:

#ifndef ODrive_h
#define ODrive_h
#include <string>
#include <sstream>
#include <stdint.h>
#include "mbed.h"
#include <cstdlib>
#include "BufferedSerial.h"
class ODrive {
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
    };

    ODrive(BufferedSerial& serial);

    // Commands
    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, float current_feedforward);
    void SetVelocity(int motor_number, float velocity);
    void SetVelocity(int motor_number, float velocity, float current_feedforward);
    
    void FinishedSending();

    // General params
    float readFloat();
    int32_t readInt();
    float readBattery();

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

    BufferedSerial& serial_;
private:
    
};

#endif //ODrive_h