diff --git a/simulation/qtcreator-files/paprikaSimulateur/paprikaSimulateur.pro b/simulation/qtcreator-files/paprikaSimulateur/paprikaSimulateur.pro index f724fbb1e5a6ac61baa95436206065b9b6a42f65..83c124a093064f82dc299e3b3b37754ad5be7eaf 100644 --- a/simulation/qtcreator-files/paprikaSimulateur/paprikaSimulateur.pro +++ b/simulation/qtcreator-files/paprikaSimulateur/paprikaSimulateur.pro @@ -105,7 +105,8 @@ HEADERS += \ ../../include/vector.h \ ../../include/strategie/krabijunior2016.h \ ../../include/strategie/krabi2016.h \ - ../../include/actionneurs/fishingNet.h + ../../include/actionneurs/fishingNet.h \ + ../../include/actionneurs/parasol.h SOURCES += \ @@ -185,7 +186,8 @@ SOURCES += \ ../../src/strategie/krabi2016.cpp \ ../../src/strategie/cabine.cpp \ ../../src/strategie/zoneConstruction.cpp \ - ../../src/actionneurs/fishingNet.cpp + ../../src/actionneurs/fishingNet.cpp \ + ../../src/actionneurs/parasol.cpp FORMS += \ ../../include/simul/remotedebug.ui \ diff --git a/stm32/include/actionneurs/parasol.h b/stm32/include/actionneurs/parasol.h new file mode 100644 index 0000000000000000000000000000000000000000..c2deb04eba99c04ce13702b8e68b15c713087d09 --- /dev/null +++ b/stm32/include/actionneurs/parasol.h @@ -0,0 +1,50 @@ +#ifndef PARASOL_H +#define PARASOL_H + +/** + * @brief This singleton class handles the parasol actuator. + * @see getSingleton + */ +class Parasol +{ + /** + * The ID of the servo + */ + static const int SERVO_ID = 0; // To update + + + /** + * Those constantes are angles for the relevant action (names are pretty explicit) + */ + static const int SERVO_CLOSED_POS = 0x00; + static const int SERVO_DEPLOYED_POS = 0x00; + + + public: + + /** + * @brief Parasol is a singleton. This static method will return the only possible instance of Parasol (and create it if deemed necessary) + */ + static Parasol* getSingleton(); + + /** + * @brief Closes the parasol + */ + void close(); + + /** + * @brief Deploys the parasol + */ + void deploy(); + + private: + + /** + * @brief Constructor + * @see getSingleton + */ + Parasol(); + +}; + +#endif diff --git a/stm32/src/actionneurs/parasol.cpp b/stm32/src/actionneurs/parasol.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a9fc2148574f0cd8d4932b3e8921036647e203c3 --- /dev/null +++ b/stm32/src/actionneurs/parasol.cpp @@ -0,0 +1,33 @@ +#include "parasol.h" + +#ifdef ROBOTHW + #include "interfaceServosNumeriques.h" +#endif + +Parasol* Parasol::getSingleton() +{ + static Parasol* instance = 0; + if(instance == 0) + instance = new Parasol(); + + return instance; +} + +Parasol::Parasol() +{ + close(); +} + +void Parasol::close() +{ +#ifdef ROBOTHW + ServosNumeriques::moveTo(SERVO_CLOSED_POS, SERVO_ID); +#endif +} + +void Parasol::deploy() +{ +#ifdef ROBOTHW + ServosNumeriques::moveTo(SERVO_DEPLOYED_POS, SERVO_ID); +#endif +} diff --git a/stm32/src/simul/Graph.cpp b/stm32/src/simul/Graph.cpp index 7909835208cfcabb528ddbab43490f4a48fb876d..f154860af5ec1e560907ed9908a75914ac748331 100644 --- a/stm32/src/simul/Graph.cpp +++ b/stm32/src/simul/Graph.cpp @@ -7,7 +7,7 @@ #include #include "asservissement.h" -Graph::Graph(QWidget* widget) : QWidget(widget), vAngular(1000), vLinear(1000) +Graph::Graph(QWidget* widget) : QWidget(widget), vLinear(1000), vAngular(1000) { dt=0; setAutoFillBackground(true); @@ -26,7 +26,7 @@ void Graph::update(int dt) this->dt = dt; repaint(); } -void Graph::paintEvent(QPaintEvent* evt) +void Graph::paintEvent(QPaintEvent*) { int diameter = 1; @@ -42,12 +42,12 @@ void Graph::paintEvent(QPaintEvent* evt) p.fillRect(0,0,gWidth,gHeight,QColor(255,255,255)); p.setPen(QColor(Qt::black)); - for (int i=0; i+1 < vLinear.size(); i++) + for (size_t i=0; i+1 < vLinear.size(); i++) { p.drawLine(i,-(gHeight/4)*(vLinear[i]/VITESSE_LINEAIRE_MAX)+gHeight/4,i+1,-(gHeight/4)*(vLinear[i+1]/VITESSE_LINEAIRE_MAX)+gHeight/4); //p.drawEllipse(QRectF(i -diameter / 2.0, (gHeight/2)*(vLinear[i]/VITESSE_LINEAIRE_MAX)+gHeight/2 -diameter / 2.0, diameter, diameter)); } - for (int i=0; i+1 < vLinear.size(); i++) + for (size_t i=0; i+1 < vLinear.size(); i++) { p.drawLine(i,-(gHeight/4)*(vAngular[i]/VITESSE_ANGULAIRE_MAX)+3*gHeight/4,i+1,-(gHeight/4)*(vAngular[i+1]/VITESSE_ANGULAIRE_MAX)+3*gHeight/4); //p.drawEllipse(QRectF(i -diameter / 2.0, (gHeight/2)*(vLinear[i]/VITESSE_LINEAIRE_MAX)+gHeight/2 -diameter / 2.0, diameter, diameter)); @@ -56,7 +56,7 @@ void Graph::paintEvent(QPaintEvent* evt) } -void Graph::keyPressEvent(QKeyEvent* evt, bool press) +void Graph::keyPressEvent(QKeyEvent*, bool) { } diff --git a/stm32/src/simul/TableGraphics.cpp b/stm32/src/simul/TableGraphics.cpp index d434d4e5e297c708ea378c9bc80621077d4adf15..3ba3c461989e0bb9a6526eded9c2fbe7c2506a1a 100644 --- a/stm32/src/simul/TableGraphics.cpp +++ b/stm32/src/simul/TableGraphics.cpp @@ -69,7 +69,7 @@ void Shape::drawSelf(QPainter* painter) painter->setPen(p_color); } -void Shape::createSolid(b2Body* body) +void Shape::createSolid(b2Body*) { } diff --git a/stm32/src/simul/main_window.cpp b/stm32/src/simul/main_window.cpp index b64764c2668d4e627715ea918d008f6e45781b72..9492a8752f129bd16c8eeac138596ba023e5af94 100644 --- a/stm32/src/simul/main_window.cpp +++ b/stm32/src/simul/main_window.cpp @@ -74,13 +74,13 @@ void MainWindow::resizeEvent(QResizeEvent* event) table->resize(proportion*s.height(),s.height()); } -void MainWindow::moveEvent(QMoveEvent * event) +void MainWindow::moveEvent(QMoveEvent*) { if (DebugWindow::getInstance()->isAttached()) DebugWindow::getInstance()->moveWithoutEvent(this->mapToGlobal(QPoint()) + QPoint(this->width() + 16, -QApplication::style()->pixelMetric(QStyle::PM_TitleBarHeight))); } -void MainWindow::closeEvent(QCloseEvent *event) +void MainWindow::closeEvent(QCloseEvent*) { DebugWindow::getInstance()->close(); } diff --git a/stm32/src/strategie/strategieV2.cpp b/stm32/src/strategie/strategieV2.cpp index e3d644cfbf05c03d19f9968c36bb19d6c7986016..9266b77fc3b98147d80431ff0a33b0b955b3e602 100644 --- a/stm32/src/strategie/strategieV2.cpp +++ b/stm32/src/strategie/strategieV2.cpp @@ -612,7 +612,7 @@ Command* StrategieV2::setCurrentGoalSmooth(Position goal, Position nextGoal, flo return currentCommand; } -Command* StrategieV2::setCurrentGoal(Position goal, Position center, float vitesse, bool goBack, Angle precisionAngle) +Command* StrategieV2::setCurrentGoal(Position goal, Position center, float vitesse, bool goBack, Angle /*precisionAngle*/) { if (currentCommand != NULL) delete currentCommand; @@ -668,6 +668,7 @@ bool StrategieV2::willCollide() somethingDetected = true; Asservissement::asservissement->setCommandSpeeds(NULL); // stoppe le robot Asservissement::asservissement->resetAsserv(); + return false; } bool StrategieV2::isYellow() @@ -751,6 +752,8 @@ bool StrategieV2::sharpDetects(SharpSensor::SharpName name) for (int i = 0; i < SharpSensor::END_SHARP_NAME; i++) if (sharps[i]->getName() == name && sharpsToCheck[i] == true && !tourneSurSoiMeme) return sharps[i]->getValue().b; + + return false; } void StrategieV2::setTourneSurSoiMeme(bool tourne)