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