Skip to content

Commit e2f0839

Browse files
committed
Merge pull request #82 from personalrobotics/bugfix/servo_simulation
Bugfix/servo simulation
2 parents 2cb9163 + 0281529 commit e2f0839

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/prpy/simulation/servo.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,17 @@ def SetVelocity(self, q_dot):
8181

8282
def Step(self):
8383
while True:
84+
start_time = time.time()
8485
with self.mutex:
8586
# Copy the velocity for thread safety.
8687
q_dot = self.q_dot.copy()
8788
running = self.running
8889

8990
# Stop servoing when the watchdog times out.
90-
now = time.time()
91-
if running and now - self.watchdog > self.watchdog_timeout:
91+
if running and start_time - self.watchdog > self.watchdog_timeout:
9292
self.q_dot = numpy.zeros(self.num_dofs)
9393
self.running = False
94-
logging.warning('Servo motion timed out in %.3f seconds.', now - self.watchdog)
94+
logging.warning('Servo motion timed out in %.3f seconds.', start_time - self.watchdog)
9595

9696
if running:
9797
env = self.manip.GetRobot().GetEnv()
@@ -122,7 +122,6 @@ def Step(self):
122122
else:
123123
self.running = False
124124
logging.warning('Servo motion hit a joint limit.')
125-
126-
if self.event.wait(self.period):
125+
if self.event.wait(max(self.period - (time.time()-start_time), 0.)):
127126
break
128127

0 commit comments

Comments
 (0)