![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
vf
Dependencies: Servo ServoArm mbed
Fork of PES_Official by
Sources/Arm.cpp@17:4e1be70bdedb, 2017-05-18 (annotated)
- Committer:
- beacon
- Date:
- Thu May 18 14:27:09 2017 +0000
- Revision:
- 17:4e1be70bdedb
- Parent:
- 12:c0bcb95885dd
Si compila.
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 | 10:f76476943a6c | 8 | Arm::Arm(ServoArm* arm){ |
beacon | 10:f76476943a6c | 9 | init(arm); |
beacon | 4:67d7177c213f | 10 | } |
beacon | 4:67d7177c213f | 11 | |
beacon | 10:f76476943a6c | 12 | void Arm::init(ServoArm* arm){ |
beacon | 10:f76476943a6c | 13 | this->arm = arm; |
beacon | 4:67d7177c213f | 14 | |
beacon | 10:f76476943a6c | 15 | this->arm->calibrate(0.0015f, 180.0f); |
beacon | 17:4e1be70bdedb | 16 | this->arm->position(RELEASE_POS); |
beacon | 4:67d7177c213f | 17 | } |
beacon | 4:67d7177c213f | 18 | |
beacon | 11:292bdbd85a9c | 19 | int Arm::collectToDown(){ |
beacon | 6:ba26dd3251b3 | 20 | static float pos=COLLECT_POS; |
beacon | 6:ba26dd3251b3 | 21 | if(pos>TAKE_POS) { |
beacon | 11:292bdbd85a9c | 22 | pos-=3; |
beacon | 10:f76476943a6c | 23 | this->arm->position(pos); |
beacon | 11:292bdbd85a9c | 24 | return 0; |
beacon | 6:ba26dd3251b3 | 25 | } |
beacon | 6:ba26dd3251b3 | 26 | else{ |
beacon | 12:c0bcb95885dd | 27 | pos = COLLECT_POS; |
beacon | 11:292bdbd85a9c | 28 | return 1; |
beacon | 6:ba26dd3251b3 | 29 | } |
beacon | 4:67d7177c213f | 30 | } |
beacon | 4:67d7177c213f | 31 | |
beacon | 11:292bdbd85a9c | 32 | int Arm::downToCollect(){ |
beacon | 6:ba26dd3251b3 | 33 | static float pos=TAKE_POS; |
beacon | 6:ba26dd3251b3 | 34 | if(pos<COLLECT_POS) { |
beacon | 11:292bdbd85a9c | 35 | pos+=3; |
beacon | 10:f76476943a6c | 36 | this->arm->position(pos); |
beacon | 11:292bdbd85a9c | 37 | return 0; |
beacon | 11:292bdbd85a9c | 38 | } |
beacon | 6:ba26dd3251b3 | 39 | else{ |
beacon | 12:c0bcb95885dd | 40 | pos = TAKE_POS; |
beacon | 11:292bdbd85a9c | 41 | return 1; |
beacon | 6:ba26dd3251b3 | 42 | } |
beacon | 4:67d7177c213f | 43 | } |
beacon | 4:67d7177c213f | 44 | |
beacon | 11:292bdbd85a9c | 45 | int Arm::collectToBack(){ |
beacon | 6:ba26dd3251b3 | 46 | static float pos=COLLECT_POS; |
beacon | 6:ba26dd3251b3 | 47 | if(pos<RELEASE_POS) { |
beacon | 11:292bdbd85a9c | 48 | pos+=3; |
beacon | 10:f76476943a6c | 49 | this->arm->position(pos); |
beacon | 11:292bdbd85a9c | 50 | return 0; |
beacon | 6:ba26dd3251b3 | 51 | } |
beacon | 6:ba26dd3251b3 | 52 | else{ |
beacon | 12:c0bcb95885dd | 53 | pos = COLLECT_POS; |
beacon | 11:292bdbd85a9c | 54 | return 1; |
beacon | 6:ba26dd3251b3 | 55 | } |
beacon | 4:67d7177c213f | 56 | } |
beacon | 4:67d7177c213f | 57 | |
beacon | 11:292bdbd85a9c | 58 | int Arm::backToCollect(){ |
beacon | 6:ba26dd3251b3 | 59 | static float pos=RELEASE_POS; |
beacon | 6:ba26dd3251b3 | 60 | if(pos>COLLECT_POS) { |
beacon | 11:292bdbd85a9c | 61 | pos-=3; |
beacon | 10:f76476943a6c | 62 | this->arm->position(pos); |
beacon | 11:292bdbd85a9c | 63 | return 0; |
beacon | 6:ba26dd3251b3 | 64 | } |
beacon | 6:ba26dd3251b3 | 65 | else{ |
beacon | 12:c0bcb95885dd | 66 | pos = RELEASE_POS; |
beacon | 11:292bdbd85a9c | 67 | return 1; |
beacon | 6:ba26dd3251b3 | 68 | } |
beacon | 6:ba26dd3251b3 | 69 | } |