-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding back the wd timer, somehow it was removed in some commit
- Loading branch information
1 parent
eb8e267
commit 22b3065
Showing
1 changed file
with
24 additions
and
0 deletions.
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
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 |