![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
vf
Dependencies: Servo ServoArm mbed
Fork of PES_Official by
Sources/Arm.cpp@7:6fed0dcae9c1, 2017-05-02 (annotated)
- Committer:
- EpicG10
- Date:
- Tue May 02 08:00:19 2017 +0000
- Revision:
- 7:6fed0dcae9c1
- Parent:
- 6:ba26dd3251b3
- Child:
- 10:f76476943a6c
u
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
beacon | 6:ba26dd3251b3 | 1 | #include "Robot.h" |
beacon | 6:ba26dd3251b3 | 2 | #include "Declarations.h" |
beacon | 6:ba26dd3251b3 | 3 | |
beacon | 4:67d7177c213f | 4 | |
beacon | 6:ba26dd3251b3 | 5 | Arm::Arm(){ |
beacon | 6:ba26dd3251b3 | 6 | } |
beacon | 6:ba26dd3251b3 | 7 | |
beacon | 6:ba26dd3251b3 | 8 | Arm::Arm(Servo* servoArm){ |
beacon | 6:ba26dd3251b3 | 9 | init(servoArm); |
beacon | 4:67d7177c213f | 10 | } |
beacon | 4:67d7177c213f | 11 | |
beacon | 6:ba26dd3251b3 | 12 | void Arm::init(Servo* servoArm){ |
beacon | 6:ba26dd3251b3 | 13 | this->servoArm = servoArm; |
beacon | 4:67d7177c213f | 14 | |
EpicG10 | 7:6fed0dcae9c1 | 15 | this->servoArm->calibrate(0.008f, 90.0f); |
beacon | 6:ba26dd3251b3 | 16 | this->servoArm->position(COLLECT_POS); |
beacon | 4:67d7177c213f | 17 | } |
beacon | 4:67d7177c213f | 18 | |
beacon | 6:ba26dd3251b3 | 19 | void Arm::collecttodown(int* done){ |
beacon | 6:ba26dd3251b3 | 20 | static float pos=COLLECT_POS; |
beacon | 6:ba26dd3251b3 | 21 | if(pos>TAKE_POS) { |
EpicG10 | 7:6fed0dcae9c1 | 22 | pos-=1; |
beacon | 6:ba26dd3251b3 | 23 | this->servoArm->position(pos); |
beacon | 6:ba26dd3251b3 | 24 | } |
beacon | 6:ba26dd3251b3 | 25 | else{ |
beacon | 6:ba26dd3251b3 | 26 | *done = 1; |
beacon | 6:ba26dd3251b3 | 27 | } |
beacon | 4:67d7177c213f | 28 | } |
beacon | 4:67d7177c213f | 29 | |
beacon | 6:ba26dd3251b3 | 30 | void Arm::downtocollect(int* done){ |
beacon | 6:ba26dd3251b3 | 31 | static float pos=TAKE_POS; |
beacon | 6:ba26dd3251b3 | 32 | if(pos<COLLECT_POS) { |
EpicG10 | 7:6fed0dcae9c1 | 33 | pos+=1; |
beacon | 6:ba26dd3251b3 | 34 | this->servoArm->position(pos); |
beacon | 6:ba26dd3251b3 | 35 | } |
beacon | 6:ba26dd3251b3 | 36 | else{ |
beacon | 6:ba26dd3251b3 | 37 | *done = 1; |
beacon | 6:ba26dd3251b3 | 38 | } |
beacon | 4:67d7177c213f | 39 | } |
beacon | 4:67d7177c213f | 40 | |
beacon | 6:ba26dd3251b3 | 41 | void Arm::collecttoback(int* done){ |
beacon | 6:ba26dd3251b3 | 42 | static float pos=COLLECT_POS; |
beacon | 6:ba26dd3251b3 | 43 | if(pos<RELEASE_POS) { |
EpicG10 | 7:6fed0dcae9c1 | 44 | pos+=1; |
beacon | 6:ba26dd3251b3 | 45 | this->servoArm->position(pos); |
beacon | 6:ba26dd3251b3 | 46 | } |
beacon | 6:ba26dd3251b3 | 47 | else{ |
beacon | 6:ba26dd3251b3 | 48 | *done = 1; |
beacon | 6:ba26dd3251b3 | 49 | } |
beacon | 4:67d7177c213f | 50 | } |
beacon | 4:67d7177c213f | 51 | |
beacon | 6:ba26dd3251b3 | 52 | void Arm::backtocollect(int* done){ |
beacon | 6:ba26dd3251b3 | 53 | static float pos=RELEASE_POS; |
beacon | 6:ba26dd3251b3 | 54 | if(pos>COLLECT_POS) { |
EpicG10 | 7:6fed0dcae9c1 | 55 | pos-=1; |
beacon | 6:ba26dd3251b3 | 56 | this->servoArm->position(pos); |
beacon | 6:ba26dd3251b3 | 57 | } |
beacon | 6:ba26dd3251b3 | 58 | else{ |
beacon | 6:ba26dd3251b3 | 59 | *done = 1; |
beacon | 6:ba26dd3251b3 | 60 | } |
beacon | 6:ba26dd3251b3 | 61 | } |