deplacement v6

Fork of Deplacement by Projet robot

Committer:
fab16
Date:
Mon Feb 27 10:31:05 2017 +0000
Revision:
8:751dfd02c59e
Parent:
7:cc426369e073
Child:
9:832a3d20c4ee
deplacement v3

Who changed what in which revision?

UserRevisionLine numberNew contents of line
aure 0:d6b2da5ef6cb 1 #include "Deplacement.h"
aure 1:662d3c47637f 2 #include "mbed.h"
fab16 5:327f0df4ba8e 3
fab16 5:327f0df4ba8e 4 m3pi m3piD;
aure 0:d6b2da5ef6cb 5
aure 1:662d3c47637f 6 Deplacement::Deplacement() //constructeur
aure 1:662d3c47637f 7 {
aure 4:bd8b50f91f81 8
fab16 5:327f0df4ba8e 9 this->mseconds=30;// temps pour la rotation une fois valeur trouvé ne pas changer
fab16 5:327f0df4ba8e 10 posx=0;
fab16 5:327f0df4ba8e 11 posy=0;
fab16 8:751dfd02c59e 12 this->vitesse=0.1; //pointeur this
fab16 6:ad9dd32c18c7 13 }
fab16 6:ad9dd32c18c7 14
fab16 6:ad9dd32c18c7 15 void Deplacement::init(float val){
fab16 6:ad9dd32c18c7 16 m3piD.right_motor(val);
fab16 6:ad9dd32c18c7 17 m3piD.left_motor(val);
aure 1:662d3c47637f 18 }
aure 1:662d3c47637f 19
aure 1:662d3c47637f 20 Deplacement::~Deplacement()
aure 0:d6b2da5ef6cb 21 {
fab16 5:327f0df4ba8e 22
aure 1:662d3c47637f 23 }
aure 1:662d3c47637f 24 /////////////////////////////////////////////////////
aure 1:662d3c47637f 25
aure 1:662d3c47637f 26 void Deplacement::setVitesse(float v)
aure 1:662d3c47637f 27 {
fab16 5:327f0df4ba8e 28 this->vitesse=v;
aure 1:662d3c47637f 29 }
aure 1:662d3c47637f 30
aure 1:662d3c47637f 31 /////////////////////////////////////////////////////
aure 1:662d3c47637f 32
aure 1:662d3c47637f 33 void Deplacement::tourner_droite()
aure 1:662d3c47637f 34 {
aure 2:7e0d789e1be8 35 int copie=0;
aure 4:bd8b50f91f81 36
fab16 8:751dfd02c59e 37 m3piD.right(this->vitesse);
fab16 8:751dfd02c59e 38 wait(0.9);
aure 4:bd8b50f91f81 39
fab16 8:751dfd02c59e 40 m3piD.stop();
aure 4:bd8b50f91f81 41
aure 2:7e0d789e1be8 42 posx=copie;
aure 2:7e0d789e1be8 43 posx=posy;
aure 2:7e0d789e1be8 44 posy=-copie;
aure 2:7e0d789e1be8 45
aure 1:662d3c47637f 46 }
aure 1:662d3c47637f 47
aure 1:662d3c47637f 48 void Deplacement::tourner_gauche()
aure 1:662d3c47637f 49 {
fab16 8:751dfd02c59e 50 int copie=0;
aure 4:bd8b50f91f81 51
fab16 8:751dfd02c59e 52 m3piD.left(this->vitesse);
fab16 8:751dfd02c59e 53 wait(0.9);
fab16 8:751dfd02c59e 54 m3piD.stop();
aure 4:bd8b50f91f81 55
aure 4:bd8b50f91f81 56
aure 2:7e0d789e1be8 57 posx=copie;
aure 2:7e0d789e1be8 58 posx=-posy;
aure 2:7e0d789e1be8 59 posy=copie;
fab16 6:ad9dd32c18c7 60
aure 1:662d3c47637f 61 }
aure 1:662d3c47637f 62
aure 1:662d3c47637f 63 void Deplacement::avancer()
aure 1:662d3c47637f 64 {
fab16 5:327f0df4ba8e 65 m3piD.forward(this->vitesse);
fab16 8:751dfd02c59e 66 wait(2);
aure 2:7e0d789e1be8 67 posy++;
fab16 8:751dfd02c59e 68 m3piD.stop();
aure 1:662d3c47637f 69 }
aure 1:662d3c47637f 70
aure 1:662d3c47637f 71 void Deplacement::reculer()
aure 1:662d3c47637f 72 {
fab16 5:327f0df4ba8e 73 m3piD.backward(this->vitesse);
fab16 8:751dfd02c59e 74 wait(2);
aure 2:7e0d789e1be8 75 posy--;
fab16 8:751dfd02c59e 76 m3piD.stop();
fab16 8:751dfd02c59e 77 }
fab16 8:751dfd02c59e 78
fab16 8:751dfd02c59e 79 void Deplacement::gauche(){
fab16 8:751dfd02c59e 80 m3piD.left(this->vitesse);
fab16 8:751dfd02c59e 81 wait(0.9);
fab16 8:751dfd02c59e 82 avancer();
fab16 8:751dfd02c59e 83 }
fab16 8:751dfd02c59e 84
fab16 8:751dfd02c59e 85 void Deplacement::droite(){
fab16 8:751dfd02c59e 86 m3piD.right(this->vitesse);
fab16 8:751dfd02c59e 87 wait(0.9);
fab16 8:751dfd02c59e 88 avancer();
aure 1:662d3c47637f 89 }
aure 1:662d3c47637f 90
aure 3:965871a8c5ff 91 void Deplacement::stop()
aure 3:965871a8c5ff 92 {
fab16 5:327f0df4ba8e 93 m3piD.stop();
aure 3:965871a8c5ff 94 }
aure 3:965871a8c5ff 95
aure 2:7e0d789e1be8 96 void Deplacement::RAZ()
aure 2:7e0d789e1be8 97 {
aure 2:7e0d789e1be8 98 posx=0;
fab16 5:327f0df4ba8e 99 posy=0;
fab16 5:327f0df4ba8e 100 this->vitesse=0;
aure 2:7e0d789e1be8 101
fab16 5:327f0df4ba8e 102 }
aure 1:662d3c47637f 103
aure 3:965871a8c5ff 104 float Deplacement::getVitesse()
fab16 5:327f0df4ba8e 105 {
fab16 5:327f0df4ba8e 106 return(this->vitesse);
fab16 5:327f0df4ba8e 107 }
fab16 5:327f0df4ba8e 108
aure 3:965871a8c5ff 109 int Deplacement::getPosX()
fab16 5:327f0df4ba8e 110 {
fab16 5:327f0df4ba8e 111 return(this->posx);
fab16 5:327f0df4ba8e 112 }
fab16 5:327f0df4ba8e 113
aure 3:965871a8c5ff 114 int Deplacement::getPosY()
fab16 5:327f0df4ba8e 115 {
fab16 5:327f0df4ba8e 116 return(this->posy);
fab16 5:327f0df4ba8e 117 }
aure 1:662d3c47637f 118
fab16 6:ad9dd32c18c7 119 void Deplacement::tourner_droite_t()
fab16 6:ad9dd32c18c7 120 {
fab16 6:ad9dd32c18c7 121
fab16 6:ad9dd32c18c7 122 m3piD.left_motor(this->vitesse);
fab16 6:ad9dd32c18c7 123 m3piD.right_motor(-(this->vitesse));
fab16 6:ad9dd32c18c7 124 }
fab16 6:ad9dd32c18c7 125
aure 1:662d3c47637f 126
aure 1:662d3c47637f 127
aure 1:662d3c47637f 128
aure 1:662d3c47637f 129