Commit 9e6fd7a0 authored by root's avatar root

Merge branch 'master' of /srv/git/hook_robotique/../repositories/gitRobotique

parents 409018b2 392cf192
......@@ -108,7 +108,7 @@ HEADERS += \
../../include/strategie/benne.h \
../../include/actionneurs/fishingNet.h \
../../include/actionneurs/parasol.h \
../../include/strategie/benne.h \
../../include/actionneurs/benne.h \
../../include/strategie/cubeDebut.h \
../../include/clock.h
......@@ -188,7 +188,7 @@ SOURCES += \
../../src/strategie/krabijunior2016.cpp \
../../src/strategie/krabi2016.cpp \
../../src/strategie/cabine.cpp \
../../src/strategie/benne.cpp \
../../src/actionneurs/benne.cpp \
../../src/strategie/zoneConstruction.cpp \
../../src/strategie/cubeDebut.cpp \
../../src/actionneurs/fishingNet.cpp \
......
#ifndef BENNE_H
#define BENNE_H
class MicroSwitch;
class Benne
{
/**
* The ID of the AX12 used to drive the belts
*/
static const int SERVO_ID = 0; // To update
static const int FORWARD_SPEED = 1023;
static const int BACKWARD_SPEED = 2046;
public:
struct Status
{
enum Enum
{
UNKNOWN,
OPEN,
CLOSED,
OPENING,
CLOSING
};
};
static Benne* getInstance();
~Benne();
void update();
void setBenneEmpty();
void setBenneFull();
bool getIsBenneEmpty() const;
bool getIsBenneFull() const;
void empty();
void open();
void stop();
bool isFrontSwitchActive() const;
bool isBackSwitchActive() const;
Benne::Status::Enum getStatus() const;
private:
Benne();
void setStatus(Status::Enum status);
bool isBenneEmpty;
Status::Enum m_status;
MicroSwitch* m_backSwitch;
MicroSwitch* m_frontSwitch;
};
#endif // BENNE_H
......@@ -10,7 +10,7 @@ class FishingNet
/**
* The ID of the innermost AX12 (i.e. for rotation)
*/
static const int SERVO_INT_ID = 42; // To update
static const int SERVO_INT_ID = 42;
/**
* The ID of the outermost AX12 (i.e. for folding/unfolding)
*/
......
#ifndef BENNE_H
#define BENNE_H
class Benne
{
public:
Benne();
~Benne();
void setBenneEmpty();
void setBenneFull();
bool getIsBenneEmpty();
bool getIsBenneFull();
protected:
bool isBenneEmpty;
};
#endif // BENNE_H
......@@ -73,6 +73,7 @@
</Unit>
<Unit filename="include/KJ2016Tempo.h" />
<Unit filename="include/actionneurs/ascenseur.h" />
<Unit filename="include/actionneurs/benne.h" />
<Unit filename="include/actionneurs/brasKrabi.h" />
<Unit filename="include/actionneurs/brasLateraux.h" />
<Unit filename="include/actionneurs/brasTapis.h" />
......@@ -120,12 +121,10 @@
<Unit filename="include/position.h" />
<Unit filename="include/positionPlusAngle.h" />
<Unit filename="include/strategie/actionGoTo.h" />
<Unit filename="include/strategie/benne.h" />
<Unit filename="include/strategie/cabine.h" />
<Unit filename="include/strategie/clap.h" />
<Unit filename="include/strategie/cubeDebut.h" />
<Unit filename="include/strategie/deposerGobelet.h" />
<Unit filename="include/strategie/deposerPied.h" />
<Unit filename="include/strategie/etape.h" />
<Unit filename="include/strategie/gobelet.h" />
<Unit filename="include/strategie/krabi2015.h" />
......@@ -147,6 +146,7 @@
<Unit filename="src/actionneurs/anciens_fichiers/brak (copie).cpp.victor" />
<Unit filename="src/actionneurs/anciens_fichiers/roues.cpp.victor" />
<Unit filename="src/actionneurs/ascenseur.cpp" />
<Unit filename="src/actionneurs/benne.cpp" />
<Unit filename="src/actionneurs/brak (copie).cpp.victor" />
<Unit filename="src/actionneurs/brasKrabi.cpp" />
<Unit filename="src/actionneurs/brasLateraux.cpp" />
......@@ -199,7 +199,6 @@
<Unit filename="src/strategie/actionGoTo.cpp" />
<Unit filename="src/strategie/anciens_fichiers/feuKrabi (copie).cpp.victor" />
<Unit filename="src/strategie/anciens_fichiers/feukrabilateral.cpp.limitVitesseVictor" />
<Unit filename="src/strategie/benne.cpp" />
<Unit filename="src/strategie/cabine.cpp" />
<Unit filename="src/strategie/clap.cpp" />
<Unit filename="src/strategie/cubeDebut.cpp" />
......
#include "benne.h"
#ifdef ROBOTHW
#include "interfaceServosNumeriques.h"
#else
#include <QDebug>
#endif
#include "hardware/microSwitch.h"
Benne* Benne::getInstance()
{
static Benne* instance = 0;
if(!instance)
instance = new Benne();
return instance;
}
Benne::Benne()
{
#ifdef ROBOTHW
m_backSwitch = new MicroSwitch(GPIOE, GPIO_Pin_3);
m_frontSwitch = new MicroSwitch(GPIOE, GPIO_Pin_2);
#else
m_backSwitch = new MicroSwitch();
m_frontSwitch = new MicroSwitch();
#endif
isBenneEmpty = true;
m_status = Status::UNKNOWN;
#ifdef ROBOTHW
ServosNumeriques::changeContinuousRotationMode(SERVO_ID, true);
#endif
}
Benne::~Benne()
{
delete m_backSwitch;
delete m_frontSwitch;
}
void Benne::setBenneEmpty() {
isBenneEmpty = true;
}
void Benne::setBenneFull() {
isBenneEmpty = false;
}
bool Benne::getIsBenneEmpty() const
{
return isBenneEmpty;
}
bool Benne::getIsBenneFull() const
{
return !isBenneEmpty;
}
Benne::Status::Enum Benne::getStatus() const
{
return m_status;
}
void Benne::setStatus(Status::Enum status)
{
m_status = status;
}
void Benne::empty()
{
if(getStatus() != Status::CLOSED && getStatus() != Status::CLOSING)
{
#ifdef ROBOTHW
ServosNumeriques::moveAtSpeed(FORWARD_SPEED, SERVO_ID);
#else
qDebug() << "Bin is closing";
#endif
setStatus(Status::CLOSING);
}
}
void Benne::open()
{
if(getStatus() != Status::OPEN && getStatus() != Status::OPENING)
{
#ifdef ROBOTHW
ServosNumeriques::moveAtSpeed(BACKWARD_SPEED, SERVO_ID);
#else
qDebug() << "Bin is opening";
#endif
setStatus(Status::OPENING);
}
}
void Benne::update()
{
if(getStatus() == Status::CLOSING && isFrontSwitchActive())
{
stop();
setStatus(Status::CLOSED);
setBenneEmpty();
#ifndef ROBOTHW
qDebug() << "Bin is closed";
#endif
}
else if(getStatus() == Status::OPENING && isBackSwitchActive())
{
stop();
setStatus(Status::OPEN);
#ifndef ROBOTHW
qDebug() << "Bin is open";
#endif
}
}
void Benne::stop()
{
#ifdef ROBOTHW
ServosNumeriques::moveAtSpeed(0, SERVO_ID);
#endif
}
bool Benne::isFrontSwitchActive() const
{
return m_frontSwitch->ferme();
}
bool Benne::isBackSwitchActive() const
{
return m_backSwitch->ferme();
}
#include "clock.h"
#include "asservissement/odometrie.h"
#include "asservissement/asservissement.h"
#include "hardware/tourelle.h"
#include "hardware/leds.h"
#include "actionneurs/benne.h"
#ifdef ROBOTHW
#include "hardware/remote.h"
#include "hardware/leds.h"
#else
#include <QTimer>
#endif
......@@ -29,6 +31,7 @@ void Clock::every5ms()
Odometrie::odometrie->update();
Asservissement::asservissement->update();
Tourelle::getSingleton()->update();
Benne::getInstance()->update();
//StrategieV2::update();
#endif
#endif
......
#include "initkrabi.h"
#include "actionneurs/benne.h"
#ifdef ROBOTHW
InitKrabi::InitKrabi() : Initialisation(PositionPlusAngle(Position(194, 900), 0))
{
}
InitKrabi::InitKrabi() : Initialisation(PositionPlusAngle(Position(194, 900), 0))
{}
#else
#include <QDebug>
InitKrabi::InitKrabi(bool yellow, Robot* robot) : Initialisation(PositionPlusAngle(Position(194, 900), 0), yellow, robot)
{
qDebug() << "InitKrabi " << robot;
}
#include <QDebug>
InitKrabi::InitKrabi(bool yellow, Robot* robot) : Initialisation(PositionPlusAngle(Position(194, 900), 0), yellow, robot)
{
qDebug() << "InitKrabi " << robot;
}
#endif
#ifdef ROBOTHW
void InitKrabi::setYellow()
{
yellow = GPIO_ReadInputDataBit(GPIOE, GPIO_Pin_4) == Bit_RESET;
}
void InitKrabi::setYellow()
{
yellow = GPIO_ReadInputDataBit(GPIOE, GPIO_Pin_4) == Bit_RESET;
}
#endif
/** Initialisation roues codeuses **/
......@@ -177,5 +178,7 @@ void InitKrabi::initActionneurs()
Sensors* sensors = Sensors::getSingleton();
ServosNumeriques::setLedState(1, 12);
Benne::getInstance();
#endif
}
......@@ -7,6 +7,7 @@
#include "strategieV2.h"
#include "sensors.h"
#include "hardware/tourelle.h"
#include "actionneurs/benne.h"
#include <iostream>
#include <QDebug>
......@@ -348,6 +349,7 @@ void Robot::paint(QPainter &p, int dt)
}
else
{
Benne::getInstance()->update();
Odometrie::odometrie->update();
Tourelle::getSingleton()->update();
StrategieV2::update();
......
#include "benne.h"
Benne::Benne()
{
isBenneEmpty = true;
}
void Benne::setBenneEmpty() {
isBenneEmpty = true;
}
void Benne::setBenneFull() {
isBenneEmpty = false;
}
bool Benne::getIsBenneEmpty() {
return isBenneEmpty;
}
bool Benne::getIsBenneFull() {
return !isBenneEmpty;
}
......@@ -10,7 +10,7 @@
Krabi2016::Krabi2016(bool isYellow) : StrategieV3(isYellow)
{
// Création de la benne
benne = new Benne();
benne = Benne::getInstance(); // NB: Tu pourrais utiliser getInstance partout et te passer de l'attribut
//Initialisation des tableaux d'étapes
this->numeroEtapeGarage = ETAPE_GARAGE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment