Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: RoboClaw StepperMotor mbed
Fork of Robot2016_2-0 by
Odometry/Odometry.h
- Committer:
- sype
- Date:
- 2015-11-24
- Revision:
- 2:abdf8c6823a1
- Parent:
- 0:ad9600df4a70
- Child:
- 3:62e9d715de65
File content as of revision 2:abdf8c6823a1:
#ifndef ODOMETRY_H
#define ODOMETRY_H
#include "mbed.h"
#include "RoboClaw.h"
#define PI 3.1415926535897932384626433832795
#define C 1.1538461538461538461538461538462
/*
* Author : Benjamin Bertelone, reworked by Simon Emarre
*/
extern Serial pc;
class Odometry
{
public:
Odometry(double diameter_right, double diameter_left, double v, RoboClaw &rc);
void setPos(double x, double y, double theta);
void setX(double x);
void setY(double y);
void setTheta(double theta);
void GotoXYT(double x_goal, double y_goal, double theta_goal);
void GotoThet(double theta_);
void GotoB(double distance);
double getX() {return x;}
double getY() {return y;}
double getTheta() {return theta;} // ]-PI;PI]
double getTheta_(double x, double y);
double abs_d(double x){
if(x<0) return -x;
else return x;
}
double getVitLeft() {return m_vitLeft;}
double getVitRight() {return m_vitRight;}
double getDistLeft() {return m_distLeft;}
double getDistRight() {return m_distRight;}
void setDistLeft(double dist) {m_distLeft = dist;}
void setDistRight(double dist) {m_distRight = dist;}
void update_odo(void);
double calcul_distance(double x, double y, double theta_goal);
long getPulsesLeft(void) {return m_pulses_left;}
long getPulsesRight(void) {return m_pulses_right;}
double carre(double a) {return a*a;}
bool isArrivedRot(double theta_);
private:
RoboClaw &roboclaw;
long m_pulses_left;
long m_pulses_right;
double x, y, theta;
double m_vitLeft, m_vitRight;
double m_distLeft, m_distRight;
double m_distPerTick_left, m_distPerTick_right, m_v;
double erreur_ang;
};
#endif
