Robot secondaire

Dependencies:   RoboClaw mbed StepperMotor

Fork of RoboClaw by Simon Emarre

Committer:
IceTeam
Date:
Tue Nov 24 22:26:09 2015 +0000
Revision:
6:f54df7542988
Parent:
3:62e9d715de65
Child:
7:961c1acdf753
(Romain) Test de la documentation sur Odometry.cpp

Who changed what in which revision?

UserRevisionLine numberNew 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:
IceTeam 6:f54df7542988 19 /** Constructeur standart
IceTeam 6:f54df7542988 20 * @param diameter_right Definit le diametre de la roue droite
IceTeam 6:f54df7542988 21 * @param diameter_left Definit le diametre de la roue gauche
IceTeam 6:f54df7542988 22 * @param v Definit l'entraxe du robot
IceTeam 6:f54df7542988 23 * @param rc Definit une reference vers l'objet permettant l'asserv des moteurs
IceTeam 6:f54df7542988 24 @note Cet objet doit etre initialise en amont
IceTeam 6:f54df7542988 25 */
sype 2:abdf8c6823a1 26 Odometry(double diameter_right, double diameter_left, double v, RoboClaw &rc);
sype 0:ad9600df4a70 27
IceTeam 6:f54df7542988 28 /** Les fonctions suivantes permettent de réinitialiser les valeurs de position de l'odometrie. */
sype 0:ad9600df4a70 29 void setPos(double x, double y, double theta);
sype 0:ad9600df4a70 30 void setX(double x);
sype 0:ad9600df4a70 31 void setY(double y);
sype 0:ad9600df4a70 32 void setTheta(double theta);
sype 0:ad9600df4a70 33
sype 2:abdf8c6823a1 34 void GotoXYT(double x_goal, double y_goal, double theta_goal);
sype 2:abdf8c6823a1 35 void GotoThet(double theta_);
sype 3:62e9d715de65 36 void GotoDist(double distance);
sype 0:ad9600df4a70 37
sype 0:ad9600df4a70 38 double getX() {return x;}
sype 0:ad9600df4a70 39 double getY() {return y;}
sype 0:ad9600df4a70 40 double getTheta() {return theta;} // ]-PI;PI]
sype 2:abdf8c6823a1 41 double getTheta_(double x, double y);
sype 2:abdf8c6823a1 42
sype 2:abdf8c6823a1 43 double abs_d(double x){
sype 2:abdf8c6823a1 44 if(x<0) return -x;
sype 2:abdf8c6823a1 45 else return x;
sype 2:abdf8c6823a1 46 }
sype 0:ad9600df4a70 47
sype 0:ad9600df4a70 48 double getVitLeft() {return m_vitLeft;}
sype 0:ad9600df4a70 49 double getVitRight() {return m_vitRight;}
sype 0:ad9600df4a70 50
sype 0:ad9600df4a70 51 double getDistLeft() {return m_distLeft;}
sype 0:ad9600df4a70 52 double getDistRight() {return m_distRight;}
sype 0:ad9600df4a70 53
sype 0:ad9600df4a70 54 void setDistLeft(double dist) {m_distLeft = dist;}
sype 0:ad9600df4a70 55 void setDistRight(double dist) {m_distRight = dist;}
sype 0:ad9600df4a70 56
sype 0:ad9600df4a70 57 void update_odo(void);
sype 0:ad9600df4a70 58 double calcul_distance(double x, double y, double theta_goal);
sype 0:ad9600df4a70 59
sype 3:62e9d715de65 60 int32_t getPulsesLeft(void) {return m_pulses_left;}
sype 3:62e9d715de65 61 int32_t getPulsesRight(void) {return m_pulses_right;}
sype 2:abdf8c6823a1 62 double carre(double a) {return a*a;}
sype 2:abdf8c6823a1 63
sype 2:abdf8c6823a1 64 bool isArrivedRot(double theta_);
sype 0:ad9600df4a70 65
sype 0:ad9600df4a70 66 private:
sype 2:abdf8c6823a1 67 RoboClaw &roboclaw;
sype 3:62e9d715de65 68 int32_t m_pulses_left;
sype 3:62e9d715de65 69 int32_t m_pulses_right;
sype 0:ad9600df4a70 70
sype 0:ad9600df4a70 71 double x, y, theta;
sype 0:ad9600df4a70 72 double m_vitLeft, m_vitRight;
sype 0:ad9600df4a70 73 double m_distLeft, m_distRight;
sype 0:ad9600df4a70 74
sype 0:ad9600df4a70 75 double m_distPerTick_left, m_distPerTick_right, m_v;
sype 2:abdf8c6823a1 76
sype 2:abdf8c6823a1 77 double erreur_ang;
sype 0:ad9600df4a70 78 };
sype 0:ad9600df4a70 79
sype 0:ad9600df4a70 80 #endif