Skip to content

Commit

Permalink
Adding back the wd timer, somehow it was removed in some commit
Browse files Browse the repository at this point in the history
  • Loading branch information
adnanmunawar committed Feb 7, 2018
1 parent eb8e267 commit 22b3065
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions scripts/watch_dog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env python
import rospy


class WatchDog(object):
def __init__(self, time_out=0.1):
self.expire_duration = rospy.Duration.from_sec(time_out)
self.next_cmd_expected_time = rospy.Time.now()
self.initialized = False

def acknowledge_wd(self):
self.initialized = True
self.next_cmd_expected_time = rospy.Time.now() + self.expire_duration

def is_wd_expired(self):
if rospy.Time.now() > self.next_cmd_expected_time and self.initialized:
return True
else:
return False

def console_print(self, class_name):
if self.initialized:
print 'Watch Dog Expired, Resetting {} command'.format(class_name)
self.initialized = False

0 comments on commit 22b3065

Please sign in to comment.