Delta Robot example
Dependencies: BufferedSerial Eigen
Fork of TCPSocket_Example by
odrive.h@3:10fa3102c2d7, 2018-10-05 (annotated)
- Committer:
- je310
- Date:
- Fri Oct 05 15:57:55 2018 +0000
- Revision:
- 3:10fa3102c2d7
- Child:
- 4:778bc352c47f
Delta firmware using odrives.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
je310 | 3:10fa3102c2d7 | 1 | #ifndef ODrive_h |
je310 | 3:10fa3102c2d7 | 2 | #define ODrive_h |
je310 | 3:10fa3102c2d7 | 3 | #include <string> |
je310 | 3:10fa3102c2d7 | 4 | #include <sstream> |
je310 | 3:10fa3102c2d7 | 5 | #include <stdint.h> |
je310 | 3:10fa3102c2d7 | 6 | #include "mbed.h" |
je310 | 3:10fa3102c2d7 | 7 | #include <cstdlib> |
je310 | 3:10fa3102c2d7 | 8 | #include "BufferedSerial.h" |
je310 | 3:10fa3102c2d7 | 9 | class ODrive { |
je310 | 3:10fa3102c2d7 | 10 | public: |
je310 | 3:10fa3102c2d7 | 11 | enum AxisState_t { |
je310 | 3:10fa3102c2d7 | 12 | AXIS_STATE_UNDEFINED = 0, //<! will fall through to idle |
je310 | 3:10fa3102c2d7 | 13 | AXIS_STATE_IDLE = 1, //<! disable PWM and do nothing |
je310 | 3:10fa3102c2d7 | 14 | AXIS_STATE_STARTUP_SEQUENCE = 2, //<! the actual sequence is defined by the config.startup_... flags |
je310 | 3:10fa3102c2d7 | 15 | AXIS_STATE_FULL_CALIBRATION_SEQUENCE = 3, //<! run all calibration procedures, then idle |
je310 | 3:10fa3102c2d7 | 16 | AXIS_STATE_MOTOR_CALIBRATION = 4, //<! run motor calibration |
je310 | 3:10fa3102c2d7 | 17 | AXIS_STATE_SENSORLESS_CONTROL = 5, //<! run sensorless control |
je310 | 3:10fa3102c2d7 | 18 | AXIS_STATE_ENCODER_INDEX_SEARCH = 6, //<! run encoder index search |
je310 | 3:10fa3102c2d7 | 19 | AXIS_STATE_ENCODER_OFFSET_CALIBRATION = 7, //<! run encoder offset calibration |
je310 | 3:10fa3102c2d7 | 20 | AXIS_STATE_CLOSED_LOOP_CONTROL = 8 //<! run closed loop control |
je310 | 3:10fa3102c2d7 | 21 | }; |
je310 | 3:10fa3102c2d7 | 22 | |
je310 | 3:10fa3102c2d7 | 23 | ODrive(BufferedSerial& serial); |
je310 | 3:10fa3102c2d7 | 24 | |
je310 | 3:10fa3102c2d7 | 25 | // Commands |
je310 | 3:10fa3102c2d7 | 26 | void SetPosition(int motor_number, float position); |
je310 | 3:10fa3102c2d7 | 27 | void SetPosition(int motor_number, float position, float velocity_feedforward); |
je310 | 3:10fa3102c2d7 | 28 | void SetPosition(int motor_number, float position, float velocity_feedforward, float current_feedforward); |
je310 | 3:10fa3102c2d7 | 29 | void SetVelocity(int motor_number, float velocity); |
je310 | 3:10fa3102c2d7 | 30 | void SetVelocity(int motor_number, float velocity, float current_feedforward); |
je310 | 3:10fa3102c2d7 | 31 | |
je310 | 3:10fa3102c2d7 | 32 | void FinishedSending(); |
je310 | 3:10fa3102c2d7 | 33 | |
je310 | 3:10fa3102c2d7 | 34 | // General params |
je310 | 3:10fa3102c2d7 | 35 | float readFloat(); |
je310 | 3:10fa3102c2d7 | 36 | int32_t readInt(); |
je310 | 3:10fa3102c2d7 | 37 | |
je310 | 3:10fa3102c2d7 | 38 | // State helper |
je310 | 3:10fa3102c2d7 | 39 | bool run_state(int axis, int requested_state, bool wait); |
je310 | 3:10fa3102c2d7 | 40 | private: |
je310 | 3:10fa3102c2d7 | 41 | std::string readString(); |
je310 | 3:10fa3102c2d7 | 42 | |
je310 | 3:10fa3102c2d7 | 43 | BufferedSerial& serial_; |
je310 | 3:10fa3102c2d7 | 44 | }; |
je310 | 3:10fa3102c2d7 | 45 | |
je310 | 3:10fa3102c2d7 | 46 | #endif //ODrive_h |