Skip to content

Commit

Permalink
walking better detect the real-time breakage
Browse files Browse the repository at this point in the history
  • Loading branch information
madhephaestus committed Dec 22, 2023
1 parent 2164db0 commit cdb9ee6
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions MarcosWalk.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -362,19 +362,19 @@ class BodyController{
bodyLoop=new Thread({
try {
// initialize real-time initial conditions
long start = System.currentTimeMillis();
long index=0;
// run body controller until disconnected
while(availible) {
long start = System.currentTimeMillis();

// update the gait generation
loop();
// update the dynamics controller
runDynamics();
// compute the real-time condition
long elapsed = System.currentTimeMillis()-(start +(numMsOfLoop*index) )
long elapsed = System.currentTimeMillis()-(start )
def numMsOfLoopElapsed = numMsOfLoop-elapsed
// check for real-time overrun
if(numMsOfLoopElapsed<=16) {
if(numMsOfLoopElapsed<0) {
println "Real time in Body Controller broken! Loop took:"+elapsed+" sleep time "+numMsOfLoopElapsed
// this controller must run slower than the UI thread
Thread.sleep(16);
Expand All @@ -383,7 +383,6 @@ class BodyController{
Thread.sleep(numMsOfLoopElapsed);
}
// update the real-time index
index++
}
}catch(Throwable t) {
BowlerStudio.printStackTrace(t)
Expand Down

0 comments on commit cdb9ee6

Please sign in to comment.