Robot's source code

Dependencies:   mbed

Committer:
Jagang
Date:
Mon May 11 20:32:11 2015 +0000
Revision:
123:55e5e9acc541
Parent:
89:d05001d85a02
Maj AI; Repositionnement du d?part (1000,177); Ajout de l'action sur les claps

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Jagang 33:eab29f01e499 1 #ifndef ODOMETRY_H
Jagang 33:eab29f01e499 2 #define ODOMETRY_H
Jagang 33:eab29f01e499 3
Jagang 33:eab29f01e499 4 #include "mbed.h"
Jagang 33:eab29f01e499 5 #include "QEI.h"
Jagang 33:eab29f01e499 6
Near32 89:d05001d85a02 7 extern Serial logger;
Near32 89:d05001d85a02 8
Jagang 33:eab29f01e499 9 class Odometry
Jagang 33:eab29f01e499 10 {
Jagang 33:eab29f01e499 11 public:
Jagang 33:eab29f01e499 12 Odometry(QEI *qei_left, QEI *qei_right, float radius_left, float radius_right, float v);
Jagang 33:eab29f01e499 13
Jagang 33:eab29f01e499 14 void setPos(float x, float y, float theta);
Jagang 33:eab29f01e499 15 void setVit(float Vx, float Vy, float W);
Near32 47:4909e97570f6 16 void setVitPhi(float phi_r, float phi_l);
Jagang 33:eab29f01e499 17 void setX(float x);
Jagang 33:eab29f01e499 18 void setY(float Y);
Jagang 33:eab29f01e499 19 void setTheta(float theta);
Jagang 33:eab29f01e499 20
Jagang 33:eab29f01e499 21 float getX() {return x;}
Jagang 33:eab29f01e499 22 float getY() {return y;}
Jagang 33:eab29f01e499 23 float getTheta() {return theta;}
Jagang 33:eab29f01e499 24
Jagang 33:eab29f01e499 25 void reset();
Jagang 33:eab29f01e499 26
Jagang 33:eab29f01e499 27 float getVx() {return Vx;}
Jagang 33:eab29f01e499 28 float getVy() {return Vy;}
Jagang 33:eab29f01e499 29 float getW() {return W;}
Near32 47:4909e97570f6 30 float getPhiright()
Near32 47:4909e97570f6 31 {
Near32 89:d05001d85a02 32 phi_r = (m_distPerTick_right/radius_right)*(delta_right/dt);
Near32 89:d05001d85a02 33 //logger.printf("phi r = %f \r\n", phi_r);
Near32 47:4909e97570f6 34 return phi_r;
Near32 47:4909e97570f6 35 }
Near32 47:4909e97570f6 36
Near32 47:4909e97570f6 37 float getPhileft()
Near32 47:4909e97570f6 38 {
Near32 89:d05001d85a02 39 phi_l = (m_distPerTick_left/radius_left)*(delta_left/dt);
Near32 89:d05001d85a02 40 //logger.printf("phi = %f \r\n", phi_l);
Near32 47:4909e97570f6 41 return phi_l;
Near32 47:4909e97570f6 42 }
Jagang 57:ab13f4e7a2b2 43
Jagang 57:ab13f4e7a2b2 44 float getVitLeft() {return m_vitLeft;}
Jagang 57:ab13f4e7a2b2 45 float getVitRight() {return m_vitRight;}
Jagang 63:fd9af0693e50 46
Jagang 63:fd9af0693e50 47 void update(float dt);
Jagang 33:eab29f01e499 48
Jagang 33:eab29f01e499 49 private:
Jagang 33:eab29f01e499 50 QEI* m_qei_left;
Jagang 33:eab29f01e499 51 int m_pulses_left;
Jagang 33:eab29f01e499 52 QEI* m_qei_right;
Jagang 33:eab29f01e499 53 int m_pulses_right;
Near32 47:4909e97570f6 54 int delta_right;
Near32 47:4909e97570f6 55 int delta_left;
Near32 47:4909e97570f6 56 float radius_left;
Near32 47:4909e97570f6 57 float radius_right;
Jagang 33:eab29f01e499 58
Near32 89:d05001d85a02 59 volatile float x, y, theta;
Near32 89:d05001d85a02 60 volatile float m_vitLeft, m_vitRight;
Near32 89:d05001d85a02 61 volatile float offsetVx, offsetVy;
Near32 47:4909e97570f6 62 bool initoffset;
Near32 89:d05001d85a02 63 volatile float Vx,Vy,W;
Near32 89:d05001d85a02 64 volatile float phi_r,phi_l;
Near32 89:d05001d85a02 65 volatile float dt;
Jagang 33:eab29f01e499 66 Timer timer;
Jagang 33:eab29f01e499 67
Jagang 33:eab29f01e499 68 float m_distPerTick_left, m_distPerTick_right, m_v;
Jagang 33:eab29f01e499 69
Jagang 63:fd9af0693e50 70 //Ticker updater;
Jagang 33:eab29f01e499 71 };
Jagang 33:eab29f01e499 72
Jagang 33:eab29f01e499 73 #endif