deplacement v6

Fork of Deplacement by Projet robot

Committer:
aure
Date:
Thu Feb 02 12:08:29 2017 +0000
Revision:
4:bd8b50f91f81
Parent:
3:965871a8c5ff
Child:
5:327f0df4ba8e
l

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