Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Robot2016_2-0 by
Map/Objectifs/Obj_clap.cpp@11:9c70a7f4d7aa, 2016-01-05 (annotated)
- Committer:
- IceTeam
- Date:
- Tue Jan 05 15:48:25 2016 +0100
- Revision:
- 11:9c70a7f4d7aa
Ajout du fichier parent
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| IceTeam | 11:9c70a7f4d7aa | 1 | #include "Obj_clap.h" |
| IceTeam | 11:9c70a7f4d7aa | 2 | |
| IceTeam | 11:9c70a7f4d7aa | 3 | #ifdef PLAN_A |
| IceTeam | 11:9c70a7f4d7aa | 4 | extern Asserv<float> asserv; |
| IceTeam | 11:9c70a7f4d7aa | 5 | #else |
| IceTeam | 11:9c70a7f4d7aa | 6 | extern aserv_planB asserv; |
| IceTeam | 11:9c70a7f4d7aa | 7 | #endif |
| IceTeam | 11:9c70a7f4d7aa | 8 | |
| IceTeam | 11:9c70a7f4d7aa | 9 | Obj_clap::Obj_clap(float x, float y, float theta, float x2, float y2, float theta2, AX12 *ax12_brasG, AX12 *ax12_brasD) |
| IceTeam | 11:9c70a7f4d7aa | 10 | :Objectif(x,y,theta) |
| IceTeam | 11:9c70a7f4d7aa | 11 | { |
| IceTeam | 11:9c70a7f4d7aa | 12 | this->ax12_brasG = ax12_brasG; |
| IceTeam | 11:9c70a7f4d7aa | 13 | this->ax12_brasD = ax12_brasD; |
| IceTeam | 11:9c70a7f4d7aa | 14 | this->x2 = x2; |
| IceTeam | 11:9c70a7f4d7aa | 15 | this->y2 = y2; |
| IceTeam | 11:9c70a7f4d7aa | 16 | this->theta2 = theta2; |
| IceTeam | 11:9c70a7f4d7aa | 17 | } |
| IceTeam | 11:9c70a7f4d7aa | 18 | |
| IceTeam | 11:9c70a7f4d7aa | 19 | void Obj_clap::run() |
| IceTeam | 11:9c70a7f4d7aa | 20 | { |
| IceTeam | 11:9c70a7f4d7aa | 21 | if(theta2 == PI/2) |
| IceTeam | 11:9c70a7f4d7aa | 22 | { |
| IceTeam | 11:9c70a7f4d7aa | 23 | ax12_brasD->setMaxTorque(MAX_TORQUE); |
| IceTeam | 11:9c70a7f4d7aa | 24 | ax12_brasD->setGoal(BRASD_OUVERT); |
| IceTeam | 11:9c70a7f4d7aa | 25 | wait(1); |
| IceTeam | 11:9c70a7f4d7aa | 26 | asserv.setGoal(x2,y2,theta2); |
| IceTeam | 11:9c70a7f4d7aa | 27 | while(!asserv.isArrived())wait(0.1); |
| IceTeam | 11:9c70a7f4d7aa | 28 | ax12_brasD->setGoal(BRASD_FERME); |
| IceTeam | 11:9c70a7f4d7aa | 29 | wait(1); |
| IceTeam | 11:9c70a7f4d7aa | 30 | ax12_brasD->setMaxTorque(0); |
| IceTeam | 11:9c70a7f4d7aa | 31 | } |
| IceTeam | 11:9c70a7f4d7aa | 32 | else |
| IceTeam | 11:9c70a7f4d7aa | 33 | { |
| IceTeam | 11:9c70a7f4d7aa | 34 | ax12_brasG->setMaxTorque(MAX_TORQUE); |
| IceTeam | 11:9c70a7f4d7aa | 35 | ax12_brasG->setGoal(BRASG_OUVERT); |
| IceTeam | 11:9c70a7f4d7aa | 36 | wait(1); |
| IceTeam | 11:9c70a7f4d7aa | 37 | asserv.setGoal(x2,y2,theta2); |
| IceTeam | 11:9c70a7f4d7aa | 38 | while(!asserv.isArrived())wait(0.1); |
| IceTeam | 11:9c70a7f4d7aa | 39 | ax12_brasG->setGoal(BRASG_FERME); |
| IceTeam | 11:9c70a7f4d7aa | 40 | wait(1); |
| IceTeam | 11:9c70a7f4d7aa | 41 | ax12_brasG->setMaxTorque(0); |
| IceTeam | 11:9c70a7f4d7aa | 42 | } |
| IceTeam | 11:9c70a7f4d7aa | 43 | |
| IceTeam | 11:9c70a7f4d7aa | 44 | done = true; |
| IceTeam | 11:9c70a7f4d7aa | 45 | } |
| IceTeam | 11:9c70a7f4d7aa | 46 | |
| IceTeam | 11:9c70a7f4d7aa | 47 | int Obj_clap::isActive() |
| IceTeam | 11:9c70a7f4d7aa | 48 | { |
| IceTeam | 11:9c70a7f4d7aa | 49 | if(!active) |
| IceTeam | 11:9c70a7f4d7aa | 50 | return false; |
| IceTeam | 11:9c70a7f4d7aa | 51 | |
| IceTeam | 11:9c70a7f4d7aa | 52 | if(ax12_brasG->getGoal() == BRASG_OUVERT || ax12_brasD->getGoal() == BRASD_OUVERT) |
| IceTeam | 11:9c70a7f4d7aa | 53 | return false; |
| IceTeam | 11:9c70a7f4d7aa | 54 | |
| IceTeam | 11:9c70a7f4d7aa | 55 | return true; |
| IceTeam | 11:9c70a7f4d7aa | 56 | } |
