My modifications/additions to the code
Dependencies: ADXL345 ADXL345_I2C IMUfilter ITG3200 Servo fishgait mbed-rtos mbed pixy_cam
Fork of robotic_fish_ver_4_8 by
motor_controller.h@9:8dd7a76756e2, 2014-01-31 (annotated)
- Committer:
- rkk
- Date:
- Fri Jan 31 04:53:10 2014 +0000
- Revision:
- 9:8dd7a76756e2
- Parent:
- 8:0574a5db1fc4
- Child:
- 10:d9f1037f0cb0
added more code to the sinusoidal driving
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sandwich | 0:ff9bc5f69c57 | 1 | #pragma once |
sandwich | 0:ff9bc5f69c57 | 2 | #include "mbed.h" |
rkk | 6:a4d6f3e4bf28 | 3 | #define MATH_PI 3.14159265359 |
rkk | 6:a4d6f3e4bf28 | 4 | #define FREQ_MIN 0.5 //Hz |
sandwich | 7:e005cfaff8d1 | 5 | #define FREQ_MAX 3 //Hz |
sandwich | 7:e005cfaff8d1 | 6 | |
sandwich | 7:e005cfaff8d1 | 7 | float sigm(float input); |
sandwich | 0:ff9bc5f69c57 | 8 | |
sandwich | 0:ff9bc5f69c57 | 9 | class PololuMController |
sandwich | 0:ff9bc5f69c57 | 10 | { |
sandwich | 0:ff9bc5f69c57 | 11 | private: |
sandwich | 0:ff9bc5f69c57 | 12 | PwmOut* pwm; |
sandwich | 0:ff9bc5f69c57 | 13 | DigitalOut* outA; |
sandwich | 0:ff9bc5f69c57 | 14 | DigitalOut* outB; |
sandwich | 0:ff9bc5f69c57 | 15 | float timestamp; |
rkk | 8:0574a5db1fc4 | 16 | |
rkk | 8:0574a5db1fc4 | 17 | //for driving |
rkk | 8:0574a5db1fc4 | 18 | float phi1, ome1,amp1; |
rkk | 8:0574a5db1fc4 | 19 | |
rkk | 8:0574a5db1fc4 | 20 | |
sandwich | 0:ff9bc5f69c57 | 21 | public: |
sandwich | 0:ff9bc5f69c57 | 22 | PololuMController(); |
sandwich | 0:ff9bc5f69c57 | 23 | PololuMController(PinName pwmport, PinName A, PinName B); |
sandwich | 0:ff9bc5f69c57 | 24 | ~PololuMController(); |
sandwich | 0:ff9bc5f69c57 | 25 | void setspeed(float speed); //0 to 1 |
sandwich | 0:ff9bc5f69c57 | 26 | void setpolarspeed(float speed); //-1 to 1 |
sandwich | 0:ff9bc5f69c57 | 27 | void reverse(); //only works on non-polar speed |
rkk | 8:0574a5db1fc4 | 28 | void drive_sinusoidal(float currentTime, float amplitude, float frequency); |
sandwich | 7:e005cfaff8d1 | 29 | void drive_rectangular(float currentTime, float amplitude, float frequency); |
sandwich | 0:ff9bc5f69c57 | 30 | }; |