![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
This is some awesome robot code
Dependencies: mbed-rtos mbed QEI
Fork of ICRSEurobot13 by
Actuators/Arms/Arm.h@1:8119211eae14, 2013-03-29 (annotated)
- Committer:
- twighk
- Date:
- Fri Mar 29 16:28:56 2013 +0000
- Revision:
- 1:8119211eae14
- Child:
- 2:45da48fab346
Arms / servos
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
twighk | 1:8119211eae14 | 1 | |
twighk | 1:8119211eae14 | 2 | // Eurobot13 WhiteArm.h |
twighk | 1:8119211eae14 | 3 | |
twighk | 1:8119211eae14 | 4 | #include "mbed.h" |
twighk | 1:8119211eae14 | 5 | #include "Servo.h" |
twighk | 1:8119211eae14 | 6 | |
twighk | 1:8119211eae14 | 7 | class Arm : public Servo |
twighk | 1:8119211eae14 | 8 | { |
twighk | 1:8119211eae14 | 9 | private: |
twighk | 1:8119211eae14 | 10 | bool updirn; |
twighk | 1:8119211eae14 | 11 | |
twighk | 1:8119211eae14 | 12 | public: |
twighk | 1:8119211eae14 | 13 | Arm(PinName yellow, bool upflip = false, float range = 0.0005, float degrees = 45.0) : Servo(yellow) { |
twighk | 1:8119211eae14 | 14 | calibrate(range, degrees); |
twighk | 1:8119211eae14 | 15 | updirn = upflip; |
twighk | 1:8119211eae14 | 16 | } |
twighk | 1:8119211eae14 | 17 | |
twighk | 1:8119211eae14 | 18 | void operator()(float in) { |
twighk | 1:8119211eae14 | 19 | write(in); |
twighk | 1:8119211eae14 | 20 | } |
twighk | 1:8119211eae14 | 21 | |
twighk | 1:8119211eae14 | 22 | void clockwise() { // full lock clockwise |
twighk | 1:8119211eae14 | 23 | write(updirn?1:0); |
twighk | 1:8119211eae14 | 24 | } |
twighk | 1:8119211eae14 | 25 | |
twighk | 1:8119211eae14 | 26 | void anticlockwise() { // full lock anticlockwise |
twighk | 1:8119211eae14 | 27 | write(updirn?0:1); |
twighk | 1:8119211eae14 | 28 | } |
twighk | 1:8119211eae14 | 29 | |
twighk | 1:8119211eae14 | 30 | void relax() { // servo applies no force |
twighk | 1:8119211eae14 | 31 | _pwm = 0; |
twighk | 1:8119211eae14 | 32 | } |
twighk | 1:8119211eae14 | 33 | }; |
twighk | 1:8119211eae14 | 34 | |
twighk | 1:8119211eae14 | 35 | |
twighk | 1:8119211eae14 | 36 | /* |
twighk | 1:8119211eae14 | 37 | class Servo{ |
twighk | 1:8119211eae14 | 38 | private: |
twighk | 1:8119211eae14 | 39 | PwmOut PWM; |
twighk | 1:8119211eae14 | 40 | |
twighk | 1:8119211eae14 | 41 | public: |
twighk | 1:8119211eae14 | 42 | Servo(PinName pin1) : PWM(pin1){ |
twighk | 1:8119211eae14 | 43 | } |
twighk | 1:8119211eae14 | 44 | |
twighk | 1:8119211eae14 | 45 | void operator()(float in){ |
twighk | 1:8119211eae14 | 46 | PWM = in; |
twighk | 1:8119211eae14 | 47 | } |
twighk | 1:8119211eae14 | 48 | |
twighk | 1:8119211eae14 | 49 | void clockwise() { // full lock clockwise |
twighk | 1:8119211eae14 | 50 | PWM = .135; |
twighk | 1:8119211eae14 | 51 | } |
twighk | 1:8119211eae14 | 52 | |
twighk | 1:8119211eae14 | 53 | void anticlockwise() { // full lock anticlockwise |
twighk | 1:8119211eae14 | 54 | PWM = .025; |
twighk | 1:8119211eae14 | 55 | } |
twighk | 1:8119211eae14 | 56 | |
twighk | 1:8119211eae14 | 57 | void relax() { // servo applies no force |
twighk | 1:8119211eae14 | 58 | PWM = 0; |
twighk | 1:8119211eae14 | 59 | } |
twighk | 1:8119211eae14 | 60 | |
twighk | 1:8119211eae14 | 61 | }; |
twighk | 1:8119211eae14 | 62 | */ |