-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding pause_function to Speed Dreams robots #13
Open
privatereese
wants to merge
7
commits into
argos-research:ACC
Choose a base branch
from
privatereese:pause_function
base: ACC
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a922ed7
added pause function example to human robot
privatereese 2fb38f8
added optimizations and calculations
privatereese d5e6945
extracted pause function to lib
privatereese d1dd5a8
added time calculations in the functions
privatereese 1b82949
changed calculation of global values
privatereese ca9e459
added comments and namespace WIP
privatereese 458d3bc
added a TimeMeasurement class to have objects per robot for time meas…
privatereese File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
INCLUDE(../../../cmake/macros.cmake) | ||
|
||
|
||
ADD_INTERFACE_INCLUDEDIR() | ||
ADD_SDLIB_INCLUDEDIR(tgf) | ||
|
||
SET(GAMEPAUSE_HEADERS gamepause.h) | ||
|
||
SET(GAMEPAUSE_SOURCES gamepause.cpp) | ||
|
||
SD_ADD_LIBRARY(gamepause SHARED ${GAMEPAUSE_SOURCES} ${GAMEPAUSE_HEADERS}) | ||
|
||
ADD_SDLIB_LIBRARY(gamepause tgf) | ||
|
||
IF(WIN32) | ||
SD_INSTALL_FILES(BIN TARGETS gamepause) | ||
ELSE(WIN32) | ||
SD_INSTALL_FILES(LIB lib TARGETS gamepause) | ||
ENDIF(WIN32) | ||
|
||
SD_INSTALL_FILES(INCLUDE gamepause FILES ${GAMEPAUSE_HEADERS}) | ||
|
||
|
||
INCLUDE_DIRECTORIES(../../modules/userinterface/legacymenu) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
/*************************************************************************** | ||
|
||
created : Sat Mar 18 23:16:38 CET 2000 | ||
copyright : (C) 2000 by Eric Espie | ||
email : [email protected] | ||
version : $Id: human.cpp 5522 2013-06-17 21:03:25Z torcs-ng $ | ||
|
||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "legacymenu.h" | ||
#include "gamepause.h" | ||
#include <algorithm> | ||
#include <chrono> | ||
|
||
namespace gamepause{ | ||
|
||
|
||
TimeMeasurement::TimeMeasurement() | ||
{ | ||
stopcounter,avgcounter,mincounter,maxcounter,duration,totalduration = 0; | ||
|
||
} | ||
|
||
TimeMeasurement::~TimeMeasurement() | ||
{ | ||
|
||
} | ||
|
||
|
||
|
||
|
||
|
||
void | ||
TimeMeasurement::TimedRaceResume() | ||
{ | ||
|
||
//resetting the duration | ||
duration = 0; | ||
|
||
RaceResume(); | ||
|
||
//Taking the stopvalue time | ||
stopvalue = std::chrono::system_clock::now(); | ||
|
||
|
||
//calculating duration between the given startvalue and the taken stopvalue time | ||
duration = std::chrono::duration_cast<std::chrono::milliseconds>(stopvalue - startvalue).count(); | ||
|
||
|
||
//adding of the actual calculated duration to the total amount of the game being paused | ||
totalduration += duration; | ||
|
||
|
||
//updating the stopcounter, which indicates how often the game was stopvalueped. | ||
stopcounter++; | ||
|
||
|
||
}//Resuming the race for the robots | ||
|
||
void | ||
TimeMeasurement::TimedRacePause() | ||
{ | ||
//Taking the startvalue time | ||
startvalue = std::chrono::system_clock::now(); | ||
|
||
RacePause(); | ||
|
||
}//Pausing the race for the robots | ||
|
||
void | ||
TimeMeasurement::maxcalc() | ||
{ | ||
|
||
//calculating, returning and writing the maximum value to the globally available variable | ||
maxcounter = std::max(maxcounter,duration); | ||
|
||
|
||
}//calculating maximum duration time taken for one step | ||
|
||
|
||
void | ||
TimeMeasurement::mincalc() | ||
{ | ||
|
||
//if it is the first simulation step set minval as totest | ||
//otherwise minval will always be zero | ||
if (stopcounter == 1) mincounter = duration; | ||
|
||
//calculating and writing the minimum value to the globally available variable | ||
mincounter = std::min(mincounter,duration); | ||
|
||
|
||
}//calculating minimum duration time taken for one step | ||
|
||
void | ||
TimeMeasurement::avgcalc() | ||
{ | ||
//calculating, returning and writing the average value to the globally available variable | ||
avgcounter = totalduration / stopcounter; | ||
|
||
}//calculating average duration time taken all previous steps and durations | ||
|
||
|
||
|
||
void | ||
RaceResume() | ||
{ | ||
|
||
//see whether the game is started with a gui and sound and resume the sound | ||
if (LegacyMenu::self().soundEngine()) | ||
LegacyMenu::self().soundEngine()->mute(false); | ||
|
||
|
||
//Resuming the RaceEngine | ||
LmRaceEngine().start(); | ||
} | ||
|
||
void | ||
RacePause() | ||
{ | ||
//see whether the game is started with a gui and sound and resume the sound | ||
if (LegacyMenu::self().soundEngine()) | ||
LegacyMenu::self().soundEngine()->mute(true); | ||
|
||
//stopvalueping the RaceEngine | ||
LmRaceEngine().stop(); | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be readded