![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Delta Robot example
Dependencies: BufferedSerial Eigen
Fork of TCPSocket_Example by
Diff: odrive.h
- Revision:
- 3:10fa3102c2d7
- Child:
- 4:778bc352c47f
diff -r 50f1485931f1 -r 10fa3102c2d7 odrive.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/odrive.h Fri Oct 05 15:57:55 2018 +0000 @@ -0,0 +1,46 @@ +#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(); + + // State helper + bool run_state(int axis, int requested_state, bool wait); +private: + std::string readString(); + + BufferedSerial& serial_; +}; + +#endif //ODrive_h \ No newline at end of file