Robot's source code

Dependencies:   mbed

Committer:
Jagang
Date:
Thu Apr 09 17:32:36 2015 +0000
Revision:
63:fd9af0693e50
Parent:
57:ab13f4e7a2b2
Child:
89:d05001d85a02
Test vit odo

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
Jagang 33:eab29f01e499 7 class Odometry
Jagang 33:eab29f01e499 8 {
Jagang 33:eab29f01e499 9 public:
Jagang 33:eab29f01e499 10 Odometry(QEI *qei_left, QEI *qei_right, float radius_left, float radius_right, float v);
Jagang 33:eab29f01e499 11
Jagang 33:eab29f01e499 12 void setPos(float x, float y, float theta);
Jagang 33:eab29f01e499 13 void setVit(float Vx, float Vy, float W);
Near32 47:4909e97570f6 14 void setVitPhi(float phi_r, float phi_l);
Jagang 33:eab29f01e499 15 void setX(float x);
Jagang 33:eab29f01e499 16 void setY(float Y);
Jagang 33:eab29f01e499 17 void setTheta(float theta);
Jagang 33:eab29f01e499 18
Jagang 33:eab29f01e499 19 float getX() {return x;}
Jagang 33:eab29f01e499 20 float getY() {return y;}
Jagang 33:eab29f01e499 21 float getTheta() {return theta;}
Jagang 33:eab29f01e499 22
Jagang 33:eab29f01e499 23 void reset();
Jagang 33:eab29f01e499 24
Jagang 33:eab29f01e499 25 float getVx() {return Vx;}
Jagang 33:eab29f01e499 26 float getVy() {return Vy;}
Jagang 33:eab29f01e499 27 float getW() {return W;}
Near32 47:4909e97570f6 28 float getPhiright()
Near32 47:4909e97570f6 29 {
Near32 48:cb3ebbc27db3 30 phi_r = (m_distPerTick_right/radius_right)*(delta_right/dt);
Near32 47:4909e97570f6 31 return phi_r;
Near32 47:4909e97570f6 32 }
Near32 47:4909e97570f6 33
Near32 47:4909e97570f6 34 float getPhileft()
Near32 47:4909e97570f6 35 {
Near32 47:4909e97570f6 36 phi_l = (m_distPerTick_left/radius_left)*(delta_left/dt);
Near32 47:4909e97570f6 37 return phi_l;
Near32 47:4909e97570f6 38 }
Jagang 57:ab13f4e7a2b2 39
Jagang 57:ab13f4e7a2b2 40 float getVitLeft() {return m_vitLeft;}
Jagang 57:ab13f4e7a2b2 41 float getVitRight() {return m_vitRight;}
Jagang 63:fd9af0693e50 42
Jagang 63:fd9af0693e50 43 void update(float dt);
Jagang 33:eab29f01e499 44
Jagang 33:eab29f01e499 45 private:
Jagang 33:eab29f01e499 46 QEI* m_qei_left;
Jagang 33:eab29f01e499 47 int m_pulses_left;
Jagang 33:eab29f01e499 48 QEI* m_qei_right;
Jagang 33:eab29f01e499 49 int m_pulses_right;
Near32 47:4909e97570f6 50 int delta_right;
Near32 47:4909e97570f6 51 int delta_left;
Near32 47:4909e97570f6 52 float radius_left;
Near32 47:4909e97570f6 53 float radius_right;
Jagang 33:eab29f01e499 54
Jagang 33:eab29f01e499 55 float x, y, theta;
Jagang 57:ab13f4e7a2b2 56 float m_vitLeft, m_vitRight;
Near32 47:4909e97570f6 57 float offsetVx, offsetVy;
Near32 47:4909e97570f6 58 bool initoffset;
Jagang 33:eab29f01e499 59 float Vx,Vy,W;
Near32 47:4909e97570f6 60 float phi_r,phi_l;
Jagang 33:eab29f01e499 61 float dt;
Jagang 33:eab29f01e499 62 Timer timer;
Jagang 33:eab29f01e499 63
Jagang 33:eab29f01e499 64 float m_distPerTick_left, m_distPerTick_right, m_v;
Jagang 33:eab29f01e499 65
Jagang 63:fd9af0693e50 66 //Ticker updater;
Jagang 33:eab29f01e499 67 };
Jagang 33:eab29f01e499 68
Jagang 33:eab29f01e499 69 #endif