From 6fe702aef044bc557afbee3c4b915eedc13f2b19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Payen=20de=20La=20Garanderie?= <gregoire.payendelagaranderie@telecom-bretagne.eu> Date: Thu, 12 May 2011 15:29:28 +0200 Subject: [PATCH] =?UTF-8?q?Cr=C3=A9ation=20de=20l=E2=80=99objet=20pince=20?= =?UTF-8?q?pour=20la=20simul.=20Et=20:=20je=20m=E2=80=99appelle=20Emmanuel?= =?UTF-8?q?=20Caill=C3=A9=20et=20...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit je met des #include "servo.h" toutes les deux lignes, histoire de casser le code de la simulation. C’est mieux de compiler avant de commiter ... --- stm32/include/element.h | 35 ++++++++++++++++++++++++++++++++++ stm32/include/pince.h | 26 +++++++++++++------------ stm32/include/simul/element.h | 32 +------------------------------ stm32/src/pince.cpp | 36 ++++++++++++++++++----------------- stm32/src/simul/element.cpp | 2 +- stm32/src/simul/robot.cpp | 5 +++-- stm32/src/simul/table.cpp | 2 ++ stm32/src/strategie.cpp | 4 ++-- 8 files changed, 77 insertions(+), 65 deletions(-) create mode 100644 stm32/include/element.h diff --git a/stm32/include/element.h b/stm32/include/element.h new file mode 100644 index 00000000..f180aaef --- /dev/null +++ b/stm32/include/element.h @@ -0,0 +1,35 @@ +#ifndef PION_H_INCLUDED +#define PION_H_INCLUDED + +#include "Position.h" +#include <QPainter> +#include "Box2D.h" + +class Element +{ +public: + Position p; + enum Type + { + Pawn = 0, + Queen = 1, + King = 2 + }; + + Type type; + unsigned int multiplier; + +#ifndef ROBOTHW + // /!\ Internal data for the simulation, don't use inside the Strategy class + + b2Body* body; + + Element(b2World & world, Position p, Type t); + + void paint(QPainter & pa); + + void updatePos(); +#endif +}; + +#endif //PION_H_INCLUDED diff --git a/stm32/include/pince.h b/stm32/include/pince.h index 0054901a..a260b4e5 100644 --- a/stm32/include/pince.h +++ b/stm32/include/pince.h @@ -2,22 +2,24 @@ #define PINCE_H_INCLUDED #include"Angle.h" +#ifdef ROBOTHW #include"servo.h" +#endif //ROBOTHW #ifdef ROBOTHW //vrai robot -class Pince -{ - private: - - Servo serv1; - Servo serv2; - - public: - Pince(Servo serv1, Servo serv2); - void pivote(Angle angle); - ~Pince(); - +class Pince +{ + private: + + Servo serv1; + Servo serv2; + + public: + Pince(Servo serv1, Servo serv2); + void pivote(Angle angle); + ~Pince(); + }; diff --git a/stm32/include/simul/element.h b/stm32/include/simul/element.h index c6f63fee..7fb7edbc 100644 --- a/stm32/include/simul/element.h +++ b/stm32/include/simul/element.h @@ -1,31 +1 @@ -#ifndef PION_H_INCLUDED -#define PION_H_INCLUDED - -#include "Position.h" -#include <QPainter> -#include "Box2D.h" - -class Element -{ -public: - Position p; - enum Type - { - Pawn = 0, - Queen = 1, - King = 2 - }; - - Type type; - unsigned int multiplier; - - b2Body* body; - - Element(b2World & world, Position p, Type t); - - void paint(QPainter & pa); - - void updatePos(); -}; - -#endif //PION_H_INCLUDED +//Empty file, just to make the QT moc happy. diff --git a/stm32/src/pince.cpp b/stm32/src/pince.cpp index 88aaccf8..4cbb52be 100644 --- a/stm32/src/pince.cpp +++ b/stm32/src/pince.cpp @@ -1,28 +1,30 @@ #include "pince.h" +#ifdef ROBOTHW #include"servo.h" +#endif #ifdef ROBOTHW // vrai robot - + Pince::Pince(Servo serv1, Servo serv2) : serv1(1),serv2(2) -{ - - -} - -void Pince::pivote(Angle angle) -{ - serv1.goToAngle(angle); - serv2.goToAngle(-angle); - -} - -Pince::~Pince() -{ - -} +{ + + +} + +void Pince::pivote(Angle angle) +{ + serv1.goToAngle(angle); + serv2.goToAngle(-angle); + +} + +Pince::~Pince() +{ + +} diff --git a/stm32/src/simul/element.cpp b/stm32/src/simul/element.cpp index 2672011c..07ecde1f 100644 --- a/stm32/src/simul/element.cpp +++ b/stm32/src/simul/element.cpp @@ -1,4 +1,4 @@ -#include "simul/element.h" +#include "element.h" Element::Element(b2World & world, Position p, Type t) { diff --git a/stm32/src/simul/robot.cpp b/stm32/src/simul/robot.cpp index 97262af5..23c0bafc 100644 --- a/stm32/src/simul/robot.cpp +++ b/stm32/src/simul/robot.cpp @@ -1,5 +1,6 @@ #include "simul/robot.h" -#include "simul/element.h" +#include "element.h" +#include "pince.h" #include <cmath> @@ -48,7 +49,7 @@ Robot::Robot(b2World & world) : world(world), olds(10000) odometrie = new Odometrie(this); asservissement = new Asservissement(odometrie); - strategie = new Strategie(true, odometrie); + strategie = new Strategie(true, odometrie, new Pince(this)); asservissement->strategie = strategie; pos = odometrie->getPos(); diff --git a/stm32/src/simul/table.cpp b/stm32/src/simul/table.cpp index c6516870..dc5f1803 100644 --- a/stm32/src/simul/table.cpp +++ b/stm32/src/simul/table.cpp @@ -1,5 +1,7 @@ #include "simul/table.h" #include "simul/robot.h" +#include "element.h" + #include <iostream> #include <QPainter> diff --git a/stm32/src/strategie.cpp b/stm32/src/strategie.cpp index 4cb48748..30a136b8 100755 --- a/stm32/src/strategie.cpp +++ b/stm32/src/strategie.cpp @@ -6,10 +6,10 @@ #include "stm32f10x_tim.h" #include "stm32f10x_rcc.h" #include "stm32f10x_gpio.h" +#include "servo.h" #endif #include "command.h" #include "pince.h" -#include "servo.h" #include <math.h> #define INSTRUCTION_COLLISION 128 @@ -75,7 +75,7 @@ void Strategie::doNthInstruction(uint16_t n){ switch(n) { case 1: - pince->pivote(0.5); + //pince->pivote(0.5); //(new TrapezoidalCommand)->goTo(Position(600, 200)); break; case 2: -- GitLab