diff --git a/stm32/include/element.h b/stm32/include/element.h new file mode 100644 index 0000000000000000000000000000000000000000..f180aaef1a625f59832da7b04ac7740f30f3b211 --- /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 0054901aa3fb1eb6ab932208697ceffa42bc7a46..a260b4e545c6028c03b37caab743fb9ef4a28bc2 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 c6f63feec4776794ff1e74ea7235193bc989797e..7fb7edbcc2967fb2ca23ae6ad772450e5568b6e0 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 88aaccf812a068e9fbe727b6478447682a1118b3..4cbb52beab3c90c3afa3d5b61d1dc2c30abb5388 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 2672011c9929d48ce2420d360260cef68d4208bd..07ecde1fb1ae4e379e93218fc243c75ce373c661 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 97262af5c2d1dbb006d5a9f397e01d4a8ed3ca0e..23c0bafc3600823aad569317e7fbf14261b79cca 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 c651687098cd013780ce2d3c4d96fb4d43d88910..dc5f1803f8672b358d234b625fb072d8abcab0ac 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 4cb48748dbaf2bb6afbb779a952362de4da3bc1f..30a136b85554c19e9820c599178ea8ef7d10bc90 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: