Robot's source code

Dependencies:   mbed

Committer:
Near32
Date:
Fri Mar 27 19:49:22 2015 +0000
Revision:
48:cb3ebbc27db3
Parent:
47:4909e97570f6
Child:
57:ab13f4e7a2b2
pwm offset set.; ; coeff pid :; p set ; i variant ; d null; ; coeff controller; krho set; kalpha kbeta variant for angular positionning only...; ; controller :; linear VX only : OKAY : 0.4 centimeter accuracy; angular : accurate if converging...;

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 33:eab29f01e499 39
Jagang 33:eab29f01e499 40 private:
Jagang 33:eab29f01e499 41 QEI* m_qei_left;
Jagang 33:eab29f01e499 42 int m_pulses_left;
Jagang 33:eab29f01e499 43 QEI* m_qei_right;
Jagang 33:eab29f01e499 44 int m_pulses_right;
Near32 47:4909e97570f6 45 int delta_right;
Near32 47:4909e97570f6 46 int delta_left;
Near32 47:4909e97570f6 47 float radius_left;
Near32 47:4909e97570f6 48 float radius_right;
Jagang 33:eab29f01e499 49
Jagang 33:eab29f01e499 50 float x, y, theta;
Near32 47:4909e97570f6 51 float offsetVx, offsetVy;
Near32 47:4909e97570f6 52 bool initoffset;
Jagang 33:eab29f01e499 53 float Vx,Vy,W;
Near32 47:4909e97570f6 54 float phi_r,phi_l;
Jagang 33:eab29f01e499 55 float dt;
Jagang 33:eab29f01e499 56 Timer timer;
Jagang 33:eab29f01e499 57
Jagang 33:eab29f01e499 58 float m_distPerTick_left, m_distPerTick_right, m_v;
Jagang 33:eab29f01e499 59
Jagang 33:eab29f01e499 60 Ticker updater;
Jagang 33:eab29f01e499 61
Jagang 33:eab29f01e499 62 void update();
Jagang 33:eab29f01e499 63 };
Jagang 33:eab29f01e499 64
Jagang 33:eab29f01e499 65 #endif