![](/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@2:45da48fab346, 2013-03-29 (annotated)
- Committer:
- twighk
- Date:
- Fri Mar 29 20:09:21 2013 +0000
- Revision:
- 2:45da48fab346
- Parent:
- 1:8119211eae14
- Child:
- 4:1be0f6c6ceae
Emergency Stop Button, Derive all actuator classes from the base class, and implement a virtual halt function that releases power from them
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 | 2:45da48fab346 | 6 | #include "Actuators/Actuator.h" |
twighk | 1:8119211eae14 | 7 | |
twighk | 2:45da48fab346 | 8 | class Arm : public Servo, public Actuator |
twighk | 1:8119211eae14 | 9 | { |
twighk | 1:8119211eae14 | 10 | private: |
twighk | 1:8119211eae14 | 11 | bool updirn; |
twighk | 1:8119211eae14 | 12 | |
twighk | 1:8119211eae14 | 13 | public: |
twighk | 1:8119211eae14 | 14 | Arm(PinName yellow, bool upflip = false, float range = 0.0005, float degrees = 45.0) : Servo(yellow) { |
twighk | 1:8119211eae14 | 15 | calibrate(range, degrees); |
twighk | 1:8119211eae14 | 16 | updirn = upflip; |
twighk | 1:8119211eae14 | 17 | } |
twighk | 1:8119211eae14 | 18 | |
twighk | 1:8119211eae14 | 19 | void operator()(float in) { |
twighk | 1:8119211eae14 | 20 | write(in); |
twighk | 1:8119211eae14 | 21 | } |
twighk | 1:8119211eae14 | 22 | |
twighk | 1:8119211eae14 | 23 | void clockwise() { // full lock clockwise |
twighk | 1:8119211eae14 | 24 | write(updirn?1:0); |
twighk | 1:8119211eae14 | 25 | } |
twighk | 1:8119211eae14 | 26 | |
twighk | 1:8119211eae14 | 27 | void anticlockwise() { // full lock anticlockwise |
twighk | 1:8119211eae14 | 28 | write(updirn?0:1); |
twighk | 1:8119211eae14 | 29 | } |
twighk | 1:8119211eae14 | 30 | |
twighk | 2:45da48fab346 | 31 | virtual void halt() { // servo applies no force |
twighk | 2:45da48fab346 | 32 | DigitalOut myled(LED3); |
twighk | 2:45da48fab346 | 33 | myled = 1; |
twighk | 1:8119211eae14 | 34 | _pwm = 0; |
twighk | 1:8119211eae14 | 35 | } |
twighk | 1:8119211eae14 | 36 | }; |
twighk | 1:8119211eae14 | 37 | |
twighk | 1:8119211eae14 | 38 | |
twighk | 1:8119211eae14 | 39 | /* |
twighk | 1:8119211eae14 | 40 | class Servo{ |
twighk | 1:8119211eae14 | 41 | private: |
twighk | 1:8119211eae14 | 42 | PwmOut PWM; |
twighk | 1:8119211eae14 | 43 | |
twighk | 1:8119211eae14 | 44 | public: |
twighk | 1:8119211eae14 | 45 | Servo(PinName pin1) : PWM(pin1){ |
twighk | 1:8119211eae14 | 46 | } |
twighk | 1:8119211eae14 | 47 | |
twighk | 1:8119211eae14 | 48 | void operator()(float in){ |
twighk | 1:8119211eae14 | 49 | PWM = in; |
twighk | 1:8119211eae14 | 50 | } |
twighk | 1:8119211eae14 | 51 | |
twighk | 1:8119211eae14 | 52 | void clockwise() { // full lock clockwise |
twighk | 1:8119211eae14 | 53 | PWM = .135; |
twighk | 1:8119211eae14 | 54 | } |
twighk | 1:8119211eae14 | 55 | |
twighk | 1:8119211eae14 | 56 | void anticlockwise() { // full lock anticlockwise |
twighk | 1:8119211eae14 | 57 | PWM = .025; |
twighk | 1:8119211eae14 | 58 | } |
twighk | 1:8119211eae14 | 59 | |
twighk | 1:8119211eae14 | 60 | void relax() { // servo applies no force |
twighk | 1:8119211eae14 | 61 | PWM = 0; |
twighk | 1:8119211eae14 | 62 | } |
twighk | 1:8119211eae14 | 63 | |
twighk | 1:8119211eae14 | 64 | }; |
twighk | 1:8119211eae14 | 65 | */ |