Robot secondaire

Dependencies:   RoboClaw mbed StepperMotor

Fork of RoboClaw by Simon Emarre

Committer:
sype
Date:
Thu May 05 08:46:08 2016 +0000
Revision:
77:f19cc7f81f2a
Parent:
47:be4eebf40568
commit homologation

Who changed what in which revision?

UserRevisionLine numberNew contents of line
IceTeam 47:be4eebf40568 1 #ifndef POINTPARCOURS_H
IceTeam 47:be4eebf40568 2 #define POINTPARCOURS_H
IceTeam 47:be4eebf40568 3 #include "math.h"
IceTeam 47:be4eebf40568 4
IceTeam 47:be4eebf40568 5 #include "controle.h"
IceTeam 47:be4eebf40568 6 #include "point.h"
IceTeam 47:be4eebf40568 7
IceTeam 47:be4eebf40568 8 typedef struct PP4 PointsParc4;
IceTeam 47:be4eebf40568 9
IceTeam 47:be4eebf40568 10 class pointParcours : public point {
IceTeam 47:be4eebf40568 11 public:
IceTeam 47:be4eebf40568 12 pointParcours (float nx, float ny, pointParcours * npere, point arr) : point (nx, ny) {
IceTeam 47:be4eebf40568 13 if (npere != NULL)
IceTeam 47:be4eebf40568 14 G2 = sqrt(npere->getG2() + calculDistance2 (nx, ny, npere->getX(), npere->getY ()));
IceTeam 47:be4eebf40568 15 else
IceTeam 47:be4eebf40568 16 G2 = 0;
IceTeam 47:be4eebf40568 17 pere = npere;
IceTeam 47:be4eebf40568 18 H2 = sqrt (calculDistance2 (nx, ny, arr.getX (), arr.getY ()));
IceTeam 47:be4eebf40568 19 }
IceTeam 47:be4eebf40568 20
IceTeam 47:be4eebf40568 21 pointParcours (point p, pointParcours * npere, point arr) : point (p) {
IceTeam 47:be4eebf40568 22 if (pere != NULL)
IceTeam 47:be4eebf40568 23 G2 = npere->getG2 () + calculDistance2 (p.getX(), p.getY(), npere->getX (), npere->getY ());
IceTeam 47:be4eebf40568 24 else
IceTeam 47:be4eebf40568 25 G2 = 0;
IceTeam 47:be4eebf40568 26 pere = npere;
IceTeam 47:be4eebf40568 27
IceTeam 47:be4eebf40568 28 H2 = sqrt(calculDistance2 (p.getX (), p.getY (), arr.getX (), arr.getY ()));
IceTeam 47:be4eebf40568 29 }
IceTeam 47:be4eebf40568 30
IceTeam 47:be4eebf40568 31 pointParcours * getPere () { return pere; }
IceTeam 47:be4eebf40568 32
IceTeam 47:be4eebf40568 33 long double getG2 () { return G2; }
IceTeam 47:be4eebf40568 34 long double getH2 () { return H2; }
IceTeam 47:be4eebf40568 35 long double getP2 () { return G2 + H2; }
IceTeam 47:be4eebf40568 36
IceTeam 47:be4eebf40568 37 bool operator==(pointParcours& a) {
IceTeam 47:be4eebf40568 38 // Autre version : return (x == a.getX () && y == a.getY () && a.getP2 () == G2 + H2);
IceTeam 47:be4eebf40568 39 return (x == a.getX () && y == a.getY ());
IceTeam 47:be4eebf40568 40 }
IceTeam 47:be4eebf40568 41
IceTeam 47:be4eebf40568 42 bool operator==(point& a) {
IceTeam 47:be4eebf40568 43 return (x == a.getX () && y == a.getY ());
IceTeam 47:be4eebf40568 44 }
IceTeam 47:be4eebf40568 45
IceTeam 47:be4eebf40568 46 protected:
IceTeam 47:be4eebf40568 47 pointParcours * pere;
IceTeam 47:be4eebf40568 48 long double G2, H2;
IceTeam 47:be4eebf40568 49 };
IceTeam 47:be4eebf40568 50
IceTeam 47:be4eebf40568 51 struct PP4 {
IceTeam 47:be4eebf40568 52 pointParcours p0;
IceTeam 47:be4eebf40568 53 pointParcours p1;
IceTeam 47:be4eebf40568 54 pointParcours p2;
IceTeam 47:be4eebf40568 55 pointParcours p3;
IceTeam 47:be4eebf40568 56 };
IceTeam 47:be4eebf40568 57
IceTeam 47:be4eebf40568 58 #endif