Skip to content

Commit

Permalink
Increasing time between foul -> stop -> game_on transitions
Browse files Browse the repository at this point in the history
  • Loading branch information
zsmn authored and IEEEVSS committed Oct 8, 2021
1 parent ef8a9b7 commit dd82d4c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/constants/constants.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"Referee":{
"refereeAddress": "224.5.23.2",
"refereePort": 10003,
"transitionTime": 3.0,
"transitionTime": 4.0,
"game":{
"gameType": "Group_Phase",
"ballRadius": 0.0215,
Expand Down
12 changes: 11 additions & 1 deletion src/world/entities/referee/referee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ void Referee::initialization() {
// Ball play
addChecker(_ballPlayChecker = new Checker_BallPlay(_vision, getConstants()), 2);
connect(_ballPlayChecker, SIGNAL(emitGoal(VSSRef::Color)), _soccerView, SLOT(addGoal(VSSRef::Color)));
connect(_ballPlayChecker, SIGNAL(emitGoal(VSSRef::Color)), this, SLOT(goalOccurred(VSSRef::Color)));
connect(_ballPlayChecker, SIGNAL(emitSuggestion(QString, VSSRef::Color, VSSRef::Quadrant)), _soccerView, SLOT(addSuggestion(QString, VSSRef::Color, VSSRef::Quadrant)));
_ballPlayChecker->setAtkDefCheckers(_twoAtkChecker, _twoDefChecker);
_ballPlayChecker->setIsPenaltyShootout(false, VSSRef::Color::NONE);
Expand Down Expand Up @@ -164,8 +165,11 @@ void Referee::loop() {
bool teamsPlaced = _teamsPlaced;
_transitionMutex.unlock();

// Transition time
float transitionTime = (_goalOccurred) ? 2.0 * getConstants()->transitionTime() : getConstants()->transitionTime();

// Check if passed transition time
if(_transitionTimer.getSeconds() >= getConstants()->transitionTime() || (teamsPlaced && _transitionTimer.getSeconds() >= (getConstants()->transitionTime() / 2.0))) {
if(_transitionTimer.getSeconds() >= transitionTime/* || (teamsPlaced && _transitionTimer.getSeconds() >= (getConstants()->transitionTime() / 2.0))*/) {
// Set control vars
_isStopped = true;
_resetedTimer = false;
Expand All @@ -186,6 +190,8 @@ void Referee::loop() {
_resetedTimer = true;
}

_goalOccurred = false;

// Stop timer
_transitionTimer.stop();

Expand Down Expand Up @@ -438,6 +444,10 @@ void Referee::teamsPlaced() {
_transitionMutex.unlock();
}

void Referee::goalOccurred(VSSRef::Color) {
_goalOccurred = true;
}

void Referee::sendControlFoul(VSSRef::Foul foul) {
// Take copy of last foul
VSSRef::Foul lastFoul = _lastFoul;
Expand Down
2 changes: 2 additions & 0 deletions src/world/entities/referee/referee.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class Referee : public Entity
void sendControlFoul(VSSRef::Foul foul);
bool _gameHalted;
bool _longStop;
bool _goalOccurred;

// Placement collision control
bool _forceDefault;
Expand All @@ -118,6 +119,7 @@ public slots:
void processChecker(QObject *checker);
void halfPassed();
void teamsPlaced();
void goalOccurred(VSSRef::Color);
void takeManualFoul(VSSRef::Foul foul, VSSRef::Color foulColor, VSSRef::Quadrant foulQuadrant, bool isToPlaceOutside = false);
void takeStuckedTime(float time);
void processCollision(VSSRef::Foul foul, VSSRef::Color foulColor, VSSRef::Quadrant foulQuadrant, bool isToPlaceOutside);
Expand Down

0 comments on commit dd82d4c

Please sign in to comment.