zhaw_st16b_pes2_10
/
progr_Pes2_st16b_10_Giona-Arm
arm class implemented
Fork of progr_Pes2_st16b_10_Giona by
Revision 14:bdf4055ed31d, committed 2017-04-25
- Comitter:
- EpicG10
- Date:
- Tue Apr 25 15:27:21 2017 +0000
- Parent:
- 13:f3fea9f5c990
- Commit message:
- a
Changed in this revision
diff -r f3fea9f5c990 -r bdf4055ed31d Headers/Declarations.h --- a/Headers/Declarations.h Sun Apr 16 19:04:29 2017 +0000 +++ b/Headers/Declarations.h Tue Apr 25 15:27:21 2017 +0000 @@ -26,7 +26,7 @@ #define RED -1 // //Greifer: -#define PC_7 SERVO0 +//#define PC_7 SERVO0 //Arm #define COLLECT_POS 65.0f
diff -r f3fea9f5c990 -r bdf4055ed31d Headers/Robot.h --- a/Headers/Robot.h Sun Apr 16 19:04:29 2017 +0000 +++ b/Headers/Robot.h Tue Apr 25 15:27:21 2017 +0000 @@ -57,10 +57,10 @@ Arm(); void init(); - void down(); - void collect(); - void back(); - void setAngle(float angle); + void collecttodown(); + void downtocollect(); + void collecttoback(); + void backtocollect(); private: float angle;
diff -r f3fea9f5c990 -r bdf4055ed31d Sources/Arm.cpp --- a/Sources/Arm.cpp Sun Apr 16 19:04:29 2017 +0000 +++ b/Sources/Arm.cpp Tue Apr 25 15:27:21 2017 +0000 @@ -13,37 +13,34 @@ ServoArm.position(COLLECT_POS); } -void Arm::down(){ - for(int i=0; i<(COLLECT_POS-TAKE_POS); i+=1) { - ServoArm.position(COLLECT_POS-(float)i); - wait(0.02f); +void Arm::collecttodown(){ + static float pos=COLLECT_POS; + if(pos>TAKE_POS) { + pos-=0.5f; + ServoArm.position(pos); } } -void Arm::collect(){ - for(int i=0; i<(COLLECT_POS-TAKE_POS); i+=1) { - ServoArm.position(TAKE_POS+(float)i); - wait(0.02f); +void Arm::downtocollect(){ + static float pos=TAKE_POS; + if(pos<COLLECT_POS) { + pos+=0.5f; + ServoArm.position(pos); } } -void Arm::back(){ - for(int i=0; i<(RELEASE_POS-COLLECT_POS); i+=1) { - ServoArm.position(COLLECT_POS+(float)i); - wait(0.02f); +void Arm::collecttoback(){ + static float pos=COLLECT_POS; + if(pos<RELEASE_POS) { + pos+=0.5f; + ServoArm.position(pos); } } -void Arm::setAngle(float angle){ - this->angle=angle; - if (angle>90.0f) angle=90.0f; - if (angle<-90.0f) angle=-90.0f; - float pos=ServoArm.read(); - - for(int i=0; i<int(abs(pos-angle));i++){ - - if(pos>angle) ServoArm.position(pos-i); - else ServoArm.position(pos+i); - wait(0.02f); +void Arm::backtocollect(){ + static float pos=RELEASE_POS; + if(pos>COLLECT_POS) { + pos-=0.5f; + ServoArm.position(pos); } }