deplacement v6

Fork of Deplacement by Projet robot

Committer:
fab16
Date:
Thu Feb 09 14:35:28 2017 +0000
Revision:
5:327f0df4ba8e
Parent:
4:bd8b50f91f81
Child:
6:ad9dd32c18c7
v2

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 5:327f0df4ba8e 12 this->vitesse=0; //pointeur this
aure 1:662d3c47637f 13 }
aure 1:662d3c47637f 14
aure 1:662d3c47637f 15 Deplacement::~Deplacement()
aure 0:d6b2da5ef6cb 16 {
fab16 5:327f0df4ba8e 17
aure 1:662d3c47637f 18 }
aure 1:662d3c47637f 19 /////////////////////////////////////////////////////
aure 1:662d3c47637f 20
aure 1:662d3c47637f 21 void Deplacement::setVitesse(float v)
aure 1:662d3c47637f 22 {
fab16 5:327f0df4ba8e 23 this->vitesse=v;
aure 1:662d3c47637f 24 }
aure 1:662d3c47637f 25
aure 1:662d3c47637f 26 /////////////////////////////////////////////////////
aure 1:662d3c47637f 27
aure 1:662d3c47637f 28 void Deplacement::tourner_droite()
aure 1:662d3c47637f 29 {
aure 2:7e0d789e1be8 30 int copie=0;
aure 4:bd8b50f91f81 31
aure 4:bd8b50f91f81 32 t.reset();
aure 4:bd8b50f91f81 33 t.start();
aure 4:bd8b50f91f81 34
fab16 5:327f0df4ba8e 35 while((t.read_ms())!=this->mseconds)
fab16 5:327f0df4ba8e 36 m3piD.right(this->vitesse);
aure 2:7e0d789e1be8 37
aure 4:bd8b50f91f81 38 t.stop();
aure 4:bd8b50f91f81 39
aure 2:7e0d789e1be8 40 posx=copie;
aure 2:7e0d789e1be8 41 posx=posy;
aure 2:7e0d789e1be8 42 posy=-copie;
aure 2:7e0d789e1be8 43
aure 1:662d3c47637f 44 }
aure 1:662d3c47637f 45
aure 1:662d3c47637f 46 void Deplacement::tourner_gauche()
aure 1:662d3c47637f 47 {
aure 2:7e0d789e1be8 48 int copie=0;
aure 4:bd8b50f91f81 49
aure 4:bd8b50f91f81 50 t.reset();
aure 4:bd8b50f91f81 51 t.start();
aure 4:bd8b50f91f81 52
fab16 5:327f0df4ba8e 53 while((t.read_ms())!=this->mseconds)
fab16 5:327f0df4ba8e 54 m3piD.left(this->vitesse);
aure 2:7e0d789e1be8 55
aure 4:bd8b50f91f81 56 t.stop();
aure 4:bd8b50f91f81 57
aure 4:bd8b50f91f81 58
aure 2:7e0d789e1be8 59 posx=copie;
aure 2:7e0d789e1be8 60 posx=-posy;
aure 2:7e0d789e1be8 61 posy=copie;
aure 1:662d3c47637f 62 }
aure 1:662d3c47637f 63
aure 1:662d3c47637f 64 void Deplacement::avancer()
aure 1:662d3c47637f 65 {
fab16 5:327f0df4ba8e 66 m3piD.forward(this->vitesse);
aure 2:7e0d789e1be8 67 posy++;
aure 1:662d3c47637f 68 }
aure 1:662d3c47637f 69
aure 1:662d3c47637f 70 void Deplacement::reculer()
aure 1:662d3c47637f 71 {
fab16 5:327f0df4ba8e 72 m3piD.backward(this->vitesse);
aure 2:7e0d789e1be8 73 posy--;
aure 1:662d3c47637f 74 }
aure 1:662d3c47637f 75
aure 3:965871a8c5ff 76 void Deplacement::stop()
aure 3:965871a8c5ff 77 {
fab16 5:327f0df4ba8e 78 m3piD.stop();
aure 3:965871a8c5ff 79 }
aure 3:965871a8c5ff 80
aure 2:7e0d789e1be8 81 void Deplacement::RAZ()
aure 2:7e0d789e1be8 82 {
aure 2:7e0d789e1be8 83 posx=0;
fab16 5:327f0df4ba8e 84 posy=0;
fab16 5:327f0df4ba8e 85 this->vitesse=0;
aure 2:7e0d789e1be8 86
fab16 5:327f0df4ba8e 87 }
aure 1:662d3c47637f 88
aure 3:965871a8c5ff 89 float Deplacement::getVitesse()
fab16 5:327f0df4ba8e 90 {
fab16 5:327f0df4ba8e 91 return(this->vitesse);
fab16 5:327f0df4ba8e 92 }
fab16 5:327f0df4ba8e 93
aure 3:965871a8c5ff 94 int Deplacement::getPosX()
fab16 5:327f0df4ba8e 95 {
fab16 5:327f0df4ba8e 96 return(this->posx);
fab16 5:327f0df4ba8e 97 }
fab16 5:327f0df4ba8e 98
aure 3:965871a8c5ff 99 int Deplacement::getPosY()
fab16 5:327f0df4ba8e 100 {
fab16 5:327f0df4ba8e 101 return(this->posy);
fab16 5:327f0df4ba8e 102 }
aure 1:662d3c47637f 103
aure 1:662d3c47637f 104
aure 1:662d3c47637f 105
aure 1:662d3c47637f 106
aure 1:662d3c47637f 107