c

Dependencies:   Servo ServoArm mbed

Fork of PES_PIXY_Official by zhaw_st16b_pes2_10

Committer:
beacon
Date:
Mon May 22 11:24:46 2017 +0000
Revision:
0:15a8480061e8
Child:
1:fd3cef0f116d
o

Who changed what in which revision?

UserRevisionLine numberNew contents of line
beacon 0:15a8480061e8 1 #include "Robot.h"
beacon 0:15a8480061e8 2 #include "Declarations.h"
beacon 0:15a8480061e8 3
beacon 0:15a8480061e8 4
beacon 0:15a8480061e8 5 Arm::Arm(){
beacon 0:15a8480061e8 6 }
beacon 0:15a8480061e8 7
beacon 0:15a8480061e8 8 Arm::Arm(ServoArm* arm){
beacon 0:15a8480061e8 9 init(arm);
beacon 0:15a8480061e8 10 }
beacon 0:15a8480061e8 11
beacon 0:15a8480061e8 12 void Arm::init(ServoArm* arm){
beacon 0:15a8480061e8 13 this->arm = arm;
beacon 0:15a8480061e8 14
beacon 0:15a8480061e8 15 this->arm->calibrate(0.0015f, 180.0f);
beacon 0:15a8480061e8 16 this->arm->position(RELEASE_POS);
beacon 0:15a8480061e8 17 }
beacon 0:15a8480061e8 18
beacon 0:15a8480061e8 19 int Arm::collectToDown(){
beacon 0:15a8480061e8 20 static float pos=COLLECT_POS;
beacon 0:15a8480061e8 21 if(pos>TAKE_POS) {
beacon 0:15a8480061e8 22 pos-=3;
beacon 0:15a8480061e8 23 this->arm->position(pos);
beacon 0:15a8480061e8 24 return 0;
beacon 0:15a8480061e8 25 }
beacon 0:15a8480061e8 26 else{
beacon 0:15a8480061e8 27 pos = COLLECT_POS;
beacon 0:15a8480061e8 28 return 1;
beacon 0:15a8480061e8 29 }
beacon 0:15a8480061e8 30 }
beacon 0:15a8480061e8 31
beacon 0:15a8480061e8 32 int Arm::downToCollect(){
beacon 0:15a8480061e8 33 static float pos=TAKE_POS;
beacon 0:15a8480061e8 34 if(pos<COLLECT_POS) {
beacon 0:15a8480061e8 35 pos+=3;
beacon 0:15a8480061e8 36 this->arm->position(pos);
beacon 0:15a8480061e8 37 return 0;
beacon 0:15a8480061e8 38 }
beacon 0:15a8480061e8 39 else{
beacon 0:15a8480061e8 40 pos = TAKE_POS;
beacon 0:15a8480061e8 41 return 1;
beacon 0:15a8480061e8 42 }
beacon 0:15a8480061e8 43 }
beacon 0:15a8480061e8 44
beacon 0:15a8480061e8 45 int Arm::collectToBack(){
beacon 0:15a8480061e8 46 static float pos=COLLECT_POS;
beacon 0:15a8480061e8 47 if(pos<RELEASE_POS) {
beacon 0:15a8480061e8 48 pos+=3;
beacon 0:15a8480061e8 49 this->arm->position(pos);
beacon 0:15a8480061e8 50 return 0;
beacon 0:15a8480061e8 51 }
beacon 0:15a8480061e8 52 else{
beacon 0:15a8480061e8 53 pos = COLLECT_POS;
beacon 0:15a8480061e8 54 return 1;
beacon 0:15a8480061e8 55 }
beacon 0:15a8480061e8 56 }
beacon 0:15a8480061e8 57
beacon 0:15a8480061e8 58 int Arm::backToCollect(){
beacon 0:15a8480061e8 59 static float pos=RELEASE_POS;
beacon 0:15a8480061e8 60 if(pos>COLLECT_POS) {
beacon 0:15a8480061e8 61 pos-=3;
beacon 0:15a8480061e8 62 this->arm->position(pos);
beacon 0:15a8480061e8 63 return 0;
beacon 0:15a8480061e8 64 }
beacon 0:15a8480061e8 65 else{
beacon 0:15a8480061e8 66 pos = RELEASE_POS;
beacon 0:15a8480061e8 67 return 1;
beacon 0:15a8480061e8 68 }
beacon 0:15a8480061e8 69 }
beacon 0:15a8480061e8 70
beacon 0:15a8480061e8 71 int Arm::backToDown(){
beacon 0:15a8480061e8 72 static float pos = RELEASE_POS;
beacon 0:15a8480061e8 73 if( pos > TAKE_POS ){
beacon 0:15a8480061e8 74 pos -= 0.0015f;
beacon 0:15a8480061e8 75 this->arm->position(pos);
beacon 0:15a8480061e8 76 return 0;
beacon 0:15a8480061e8 77 }
beacon 0:15a8480061e8 78 else{
beacon 0:15a8480061e8 79 pos = RELEASE_POS;
beacon 0:15a8480061e8 80 return 1;
beacon 0:15a8480061e8 81 }
beacon 0:15a8480061e8 82 }
beacon 0:15a8480061e8 83
beacon 0:15a8480061e8 84 int Arm::downToBack(){
beacon 0:15a8480061e8 85 static float pos = TAKE_POS;
beacon 0:15a8480061e8 86 if( pos < RELEASE_POS ){
beacon 0:15a8480061e8 87 pos += 0.0015f;
beacon 0:15a8480061e8 88 this->arm->position(pos);
beacon 0:15a8480061e8 89 return 0;
beacon 0:15a8480061e8 90 }
beacon 0:15a8480061e8 91 else{
beacon 0:15a8480061e8 92 pos = TAKE_POS;
beacon 0:15a8480061e8 93 return 1;
beacon 0:15a8480061e8 94 }
beacon 0:15a8480061e8 95 }