Skip to content
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

rospy.sleep exception handling #169

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions cob_command_gui/src/knoeppkes.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ def start(func, args):
if(largs[0] == "base"):
if(base_diff_enabled):
largs.append("diff")
#print "Args", tuple(largs)
#print "func ", func
#print("Args", tuple(largs))
#print("func ", func)
thread.start_new_thread(func,tuple(largs)) # exits silently without evaluating result

## use this function in order to evaluate result of action_handle, i.e. show pop-up or similar
Expand Down Expand Up @@ -203,15 +203,15 @@ def halt_all(self,component_names):

def setEMStop(self, em):
if(em):
#print "Emergency Stop Active"
#print("Emergency Stop Active")
gtk.threads_enter()
self.status_image.set_from_file(roslib.packages.get_pkg_dir("cob_command_gui") + "/common/files/icons/error.png")
self.status_label.set_text("EM Stop !")
gtk.threads_leave()
if(self.em_stop == False):
self.em_stop = True
else:
#print "Status OK"
#print("Status OK")
self.status_image.set_from_file(roslib.packages.get_pkg_dir("cob_command_gui") + "/common/files/icons/ok.png")
gtk.threads_enter()
self.status_label.set_text("Status OK")
Expand Down Expand Up @@ -301,7 +301,7 @@ def __init__(self):
gtk.gdk.threads_leave()

def signal_handler(signal, frame):
#print 'You pressed Ctrl+C!'
#print("You pressed Ctrl+C!")
gtk.main_quit()

if __name__ == "__main__":
Expand Down
5 changes: 4 additions & 1 deletion cob_dashboard/scripts/cob_dashboard_aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,7 @@ def publish(self):
r = rospy.Rate(1)
while not rospy.is_shutdown():
da.publish()
r.sleep()
try:
r.sleep()
except rospy.exceptions.ROSInterruptException as e:
pass
2 changes: 1 addition & 1 deletion cob_monitoring/src/cpu_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ def publish_stats(self):
try:
rospy.init_node('cpu_monitor_%s' % hostname)
except rospy.exceptions.ROSInitException:
print >> sys.stderr, 'CPU monitor is unable to initialize node. Master may not be running.'
print('CPU monitor is unable to initialize node. Master may not be running.', file=sys.stderr)
sys.exit(0)

cpu_node = CPUMonitor(hostname, options.diag_hostname)
Expand Down
2 changes: 1 addition & 1 deletion cob_monitoring/src/hd_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ def publish_stats(self):
node_name = ("hd_monitor_"+hostname).replace ("-", "_")
rospy.init_node(node_name)
except rospy.exceptions.ROSInitException:
print 'HD monitor is unable to initialize node. Master may not be running.'
print('HD monitor is unable to initialize node. Master may not be running.', file=sys.stderr)
sys.exit(0)

hd_monitor = hd_monitor(hostname, options.diag_hostname, options.directory)
Expand Down
11 changes: 9 additions & 2 deletions cob_monitoring/src/hz_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ def run(self):
break
rospy.loginfo("hz monitor is waiting for type of topics %s."%str(self.missing_topics))
self.publish_diagnostics()
r.sleep()

try:
r.sleep()
except rospy.exceptions.ROSInterruptException as e:
pass

# call rostopic hz
#rt = rostopic.ROSTopicHz(self.window_size)
Expand All @@ -65,7 +69,10 @@ def run(self):
while not rospy.is_shutdown():
#rt.print_hz() # taken from 'rostopic hz' (/opt/ros/indigo/lib/python2.7/dist-packages/rostopic/__init__.py)
self.publish_diagnostics(rt_HZ_store)
r.sleep()
try:
r.sleep()
except rospy.exceptions.ROSInterruptException as e:
pass

def publish_diagnostics(self, rt_HZ_store = []):
# set desired rates
Expand Down
2 changes: 1 addition & 1 deletion cob_monitoring/src/wifi_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def publish_stats(self):
try:
rospy.init_node('ddwrt_diag')
except rospy.exceptions.ROSInitException:
print 'Wifi monitor is unable to initialize node. Master may not be running.'
print('Wifi monitor is unable to initialize node. Master may not be running.', file=sys.stderr)
sys.exit(2)

wifi_monitor = WifiMonitor()
Expand Down