Skip to content

Commit df31df5

Browse files
authored
Merge pull request #82 from cpaxton/devel
UI fixes
2 parents f6af74b + 932bfb8 commit df31df5

File tree

4 files changed

+36
-34
lines changed

4 files changed

+36
-34
lines changed

costar_instructor/instructor_core/nodes/instructor_view.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ def run_tree(self):
764764
self.sound_pub.publish(String("notify_4"))
765765
self.running__ = True
766766
self.run_timer_.start(5)
767-
self.info_textbox.notify('INSTRUCTOR: Task Tree STARTING')
767+
self.info_textbox.notify('Task Tree starting')
768768
self.run_button.setStyleSheet('''QPushButton#run_button{border: 2px solid #F62459;border-radius: 0px;background-color: #F62459;color:#ffffff}QPushButton#run_button:pressed{border: 2px solid #F62459;border-radius: 0px;background-color: #F62459;color:#ffffff}''')
769769
self.run_button.setText('STOP EXECUTION')
770770

@@ -774,7 +774,7 @@ def run(self):
774774
#rospy.logwarn(result)
775775
# self.regenerate_tree()
776776
if result[:7] == 'SUCCESS':
777-
self.notification_dialog.notify('INSTRUCTOR: Task Tree FINISHED WITH SUCCESS: %s'%result)
777+
self.notification_dialog.notify('Task Tree finished with %s'%result)
778778
self.sound_pub.publish(String("notify_4_succeed"))
779779
self.run_timer_.stop()
780780
self.running__ = False
@@ -783,7 +783,7 @@ def run(self):
783783
self.run_button.setText('EXECUTE PLAN')
784784
self.regenerate_tree()
785785
elif result[:7] == 'FAILURE':
786-
self.notification_dialog.notify('INSTRUCTOR: Task Tree FINISHED WITH FAILURE: %s'%result,'error')
786+
self.notification_dialog.notify('Task Tree finished with %s'%result,'error')
787787
self.run_timer_.stop()
788788
self.running__ = False
789789
# self.root_node.reset()
@@ -793,7 +793,7 @@ def run(self):
793793
rospy.sleep(.5)
794794
self.sound_pub.publish(String("notify_4_fail"))
795795
elif result == 'NODE_ERROR':
796-
self.notification_dialog.notify('INSTRUCTOR: Task Tree ERROR','error')
796+
self.notification_dialog.notify('Task Tree error','error')
797797
self.run_timer_.stop()
798798
self.running__ = False
799799
# self.root_node.reset()
@@ -805,7 +805,7 @@ def run(self):
805805
pass
806806

807807
def stop_tree(self):
808-
self.notification_dialog.notify('INSTRUCTOR: Task Tree STOPPED')
808+
self.notification_dialog.notify('Task Tree stopped')
809809
self.stop_robot_trajectory_cb()
810810
self.run_timer_.stop()
811811
self.running__ = False
@@ -935,8 +935,8 @@ def load_selected_subtree(self):
935935

936936
self.info_textbox.notify('Tree ' + self.selected_subtree.upper() + ' loaded.')
937937
except Exception as e:
938-
self.notification_dialog.notify(load_error_message, 'error')
939-
rospy.logerr(str(e))
938+
# TODO(ahundt): set the correct error message here
939+
self.notification_dialog.notify('Failed to load tree with %s'%str(e), 'error')
940940

941941
# Finish
942942
self.load_sub_btn.hide()

costar_instructor/instructor_core/src/instructor_core/instructor_gui_components.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,11 +375,11 @@ def notify(self, message, severity='warn'):
375375
self.show_hide_slide()
376376

377377
if severity is 'warn':
378-
rospy.logwarn(message)
378+
rospy.logwarn("Instructor: " + message)
379379
elif severity is 'error':
380-
rospy.logerr(message)
380+
rospy.logerr("Instructor: " + message)
381381
else:
382-
rospy.loginfo(message)
382+
rospy.loginfo("Instructor: " + message)
383383

384384
def show_hide_slide(self):
385385
if self.isVisible():

costar_instructor/instructor_core/src/instructor_core/robot_interface.py

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -66,49 +66,50 @@ def teach(self):
6666
try:
6767
rospy.wait_for_service('/costar/SetTeachMode',2)
6868
except rospy.ROSException as e:
69-
print 'Could not find teach service'
69+
rospy.logerr('Could not find teach service')
7070
return
7171
try:
7272
teach_mode_service = rospy.ServiceProxy('/costar/SetTeachMode',SetTeachMode)
7373
result = teach_mode_service(True)
74-
# self.sound_pub.publish(String("low_up"))
75-
rospy.logwarn(result.ack)
7674
self.teach_btn.set_color(colors['gray_light'])
7775
except rospy.ServiceException, e:
78-
print e
76+
rospy.logerr(str(e))
7977
elif self.driver_status == 'TEACH':
80-
try:
81-
rospy.wait_for_service('/costar/SetTeachMode',2)
82-
except rospy.ROSException as e:
83-
print 'Could not find teach service'
84-
return
85-
try:
86-
teach_mode_service = rospy.ServiceProxy('/costar/SetTeachMode',SetTeachMode)
87-
result = teach_mode_service(False)
88-
rospy.logwarn(result.ack)
89-
# self.sound_pub.publish(String("low_down"))
90-
self.teach_btn.set_color(colors['gray'])
91-
except rospy.ServiceException, e:
92-
print e
78+
self.disable_teach_mode()
9379
else:
94-
rospy.logwarn('FAILED, driver is in ['+self.driver_status+'] mode.')
80+
rospy.logerr('FAILED, driver is in ['+self.driver_status+'] mode.')
9581
self.toast('Driver is in ['+self.driver_status+'] mode!')
9682

83+
def disable_teach_mode(self):
84+
try:
85+
rospy.wait_for_service('/costar/SetTeachMode',2)
86+
except rospy.ROSException as e:
87+
rospy.logerr('Could not find teach service')
88+
return
89+
try:
90+
teach_mode_service = rospy.ServiceProxy('/costar/SetTeachMode',SetTeachMode)
91+
result = teach_mode_service(False)
92+
rospy.logwarn(result.ack)
93+
self.teach_btn.set_color(colors['gray'])
94+
except rospy.ServiceException, e:
95+
rospy.logerr(str(e))
96+
9797
def servo(self):
98+
if self.driver_status == 'TEACH':
99+
self.disable_teach_mode()
98100
if self.driver_status == 'IDLE' or self.driver_status == 'TEACH':
99101
try:
100102
rospy.wait_for_service('/costar/SetServoMode',2)
101103
except rospy.ROSException as e:
102-
print 'Could not find SetServoMode service'
104+
rospy.logerr('Could not find SetServoMode service')
103105
return
104106
try:
105107
servo_mode_service = rospy.ServiceProxy('/costar/SetServoMode',SetServoMode)
106108
result = servo_mode_service('SERVO')
107109
rospy.logwarn(result.ack)
108110
self.servo_btn.set_color(colors['gray_light'])
109111
except rospy.ServiceException, e:
110-
print e
111-
112+
rospy.logerr(str(e))
112113
elif self.driver_status == 'SERVO':
113114
try:
114115
rospy.wait_for_service('/costar/SetServoMode',2)

costar_instructor/instructor_plugins/src/instructor_plugins/service_node.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class ServiceNode(Node):
2828

2929
def __init__(self, name, label, color,service_description, display_name = None):
3030
super(ServiceNode,self).__init__(name,label,color)
31+
self.ready_color = color
3132
self.status_msg = ''
3233
self.running = False
3334
self.finished_with_success = None
@@ -46,7 +47,7 @@ def reset_self(self):
4647
self.running = False
4748
self.finished_with_success = None
4849
self.needs_reset = False
49-
self.set_color(self.color_)
50+
self.set_color(self.ready_color)
5051

5152
def execute(self):
5253
if self.display_name is not None:
@@ -89,6 +90,6 @@ def execute(self):
8990
self.needs_reset = True
9091
return self.set_status('FAILURE -- %s'%self.status_msg)
9192

92-
def make_service_call(self,request,*args):
93-
raise NotImplementedError('make_service_call must be implemented in child class')
93+
#def make_service_call(self,request,*args):
94+
# raise NotImplementedError('make_service_call must be implemented in child class')
9495

0 commit comments

Comments
 (0)