Robot secondaire
Dependencies: RoboClaw mbed StepperMotor
Fork of RoboClaw by
Odometry/Odometry.h@3:62e9d715de65, 2015-11-24 (annotated)
- Committer:
- sype
- Date:
- Tue Nov 24 21:42:10 2015 +0000
- Revision:
- 3:62e9d715de65
- Parent:
- 2:abdf8c6823a1
- Child:
- 6:f54df7542988
GotoThet quasi fini, essayez d'y jeter un coup d'oeil pour me donner vos impressions
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sype | 0:ad9600df4a70 | 1 | #ifndef ODOMETRY_H |
sype | 0:ad9600df4a70 | 2 | #define ODOMETRY_H |
sype | 0:ad9600df4a70 | 3 | |
sype | 0:ad9600df4a70 | 4 | #include "mbed.h" |
sype | 0:ad9600df4a70 | 5 | #include "RoboClaw.h" |
sype | 0:ad9600df4a70 | 6 | |
sype | 0:ad9600df4a70 | 7 | #define PI 3.1415926535897932384626433832795 |
sype | 2:abdf8c6823a1 | 8 | #define C 1.1538461538461538461538461538462 |
sype | 0:ad9600df4a70 | 9 | |
sype | 0:ad9600df4a70 | 10 | /* |
sype | 0:ad9600df4a70 | 11 | * Author : Benjamin Bertelone, reworked by Simon Emarre |
sype | 0:ad9600df4a70 | 12 | */ |
sype | 0:ad9600df4a70 | 13 | |
sype | 2:abdf8c6823a1 | 14 | extern Serial pc; |
sype | 2:abdf8c6823a1 | 15 | |
sype | 0:ad9600df4a70 | 16 | class Odometry |
sype | 0:ad9600df4a70 | 17 | { |
sype | 0:ad9600df4a70 | 18 | public: |
sype | 2:abdf8c6823a1 | 19 | Odometry(double diameter_right, double diameter_left, double v, RoboClaw &rc); |
sype | 0:ad9600df4a70 | 20 | |
sype | 0:ad9600df4a70 | 21 | void setPos(double x, double y, double theta); |
sype | 0:ad9600df4a70 | 22 | void setX(double x); |
sype | 0:ad9600df4a70 | 23 | void setY(double y); |
sype | 0:ad9600df4a70 | 24 | void setTheta(double theta); |
sype | 0:ad9600df4a70 | 25 | |
sype | 2:abdf8c6823a1 | 26 | void GotoXYT(double x_goal, double y_goal, double theta_goal); |
sype | 2:abdf8c6823a1 | 27 | void GotoThet(double theta_); |
sype | 3:62e9d715de65 | 28 | void GotoDist(double distance); |
sype | 0:ad9600df4a70 | 29 | |
sype | 0:ad9600df4a70 | 30 | double getX() {return x;} |
sype | 0:ad9600df4a70 | 31 | double getY() {return y;} |
sype | 0:ad9600df4a70 | 32 | double getTheta() {return theta;} // ]-PI;PI] |
sype | 2:abdf8c6823a1 | 33 | double getTheta_(double x, double y); |
sype | 2:abdf8c6823a1 | 34 | |
sype | 2:abdf8c6823a1 | 35 | double abs_d(double x){ |
sype | 2:abdf8c6823a1 | 36 | if(x<0) return -x; |
sype | 2:abdf8c6823a1 | 37 | else return x; |
sype | 2:abdf8c6823a1 | 38 | } |
sype | 0:ad9600df4a70 | 39 | |
sype | 0:ad9600df4a70 | 40 | double getVitLeft() {return m_vitLeft;} |
sype | 0:ad9600df4a70 | 41 | double getVitRight() {return m_vitRight;} |
sype | 0:ad9600df4a70 | 42 | |
sype | 0:ad9600df4a70 | 43 | double getDistLeft() {return m_distLeft;} |
sype | 0:ad9600df4a70 | 44 | double getDistRight() {return m_distRight;} |
sype | 0:ad9600df4a70 | 45 | |
sype | 0:ad9600df4a70 | 46 | void setDistLeft(double dist) {m_distLeft = dist;} |
sype | 0:ad9600df4a70 | 47 | void setDistRight(double dist) {m_distRight = dist;} |
sype | 0:ad9600df4a70 | 48 | |
sype | 0:ad9600df4a70 | 49 | void update_odo(void); |
sype | 0:ad9600df4a70 | 50 | double calcul_distance(double x, double y, double theta_goal); |
sype | 0:ad9600df4a70 | 51 | |
sype | 3:62e9d715de65 | 52 | int32_t getPulsesLeft(void) {return m_pulses_left;} |
sype | 3:62e9d715de65 | 53 | int32_t getPulsesRight(void) {return m_pulses_right;} |
sype | 2:abdf8c6823a1 | 54 | double carre(double a) {return a*a;} |
sype | 2:abdf8c6823a1 | 55 | |
sype | 2:abdf8c6823a1 | 56 | bool isArrivedRot(double theta_); |
sype | 0:ad9600df4a70 | 57 | |
sype | 0:ad9600df4a70 | 58 | private: |
sype | 2:abdf8c6823a1 | 59 | RoboClaw &roboclaw; |
sype | 3:62e9d715de65 | 60 | int32_t m_pulses_left; |
sype | 3:62e9d715de65 | 61 | int32_t m_pulses_right; |
sype | 0:ad9600df4a70 | 62 | |
sype | 0:ad9600df4a70 | 63 | double x, y, theta; |
sype | 0:ad9600df4a70 | 64 | double m_vitLeft, m_vitRight; |
sype | 0:ad9600df4a70 | 65 | double m_distLeft, m_distRight; |
sype | 0:ad9600df4a70 | 66 | |
sype | 0:ad9600df4a70 | 67 | double m_distPerTick_left, m_distPerTick_right, m_v; |
sype | 2:abdf8c6823a1 | 68 | |
sype | 2:abdf8c6823a1 | 69 | double erreur_ang; |
sype | 0:ad9600df4a70 | 70 | }; |
sype | 0:ad9600df4a70 | 71 | |
sype | 0:ad9600df4a70 | 72 | #endif |