Newer
Older
#include "clap.h"
#include "strategieV2.h"
#include "mediumLevelAction.h"
#include "command.h"
#include "position.h"
#include "braslateral.h"
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
Clap::Clap(){}
Clap::Clap(Position positionDepart, Position positionArrivee):MediumLevelAction(positionDepart)
{
this->positionArrivee = positionArrivee;
this->goBack = false;
}
Clap::~Clap(){}
int Clap::update()
{
if (status == 0)
{
#ifndef ROBOTHW
qDebug() << "clap";
#endif
status++;
}
else if (status == 1)
{
StrategieV2::setCurrentGoal(goalPosition, goBack);
status++;
}
else if (status == 2)
{
if (Command::isNear(goalPosition))
{
StrategieV2::lookAt(positionArrivee);
status++;
}
}
else if (status == 3)
{
if (Command::isLookingAt(positionArrivee))
{
//ouvrir le bras
#ifndef ROBOTHW
qDebug() << "On ouvre le bras";
#endif
if ((goalPosition.getX()-positionArrivee.getX())>0)
BrasLateral::getRight()->expand();
BrasLateral::getLeft()->expand();
status++;
}
}
else if ((status <= 53) && (status > -1 )) //On attend que le bras du robot s'ouvre : 50ms par incrémentation du status
{
status++;
}
else if (status == 54)
{
StrategieV2::setCurrentGoal(positionArrivee, goBack);
status++;
}
else if (status == 55)
{
if (Command::isNear(positionArrivee))
{
//fermer bras
#ifndef ROBOTHW
qDebug() << "On ferme le bras";
#endif
if ((goalPosition.getX()-positionArrivee.getX())>0)
BrasLateral::getLeft()->collapse();
BrasLateral::getRight()->collapse();