00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 import rospy
00019 from simple_script_server import *
00020 sss = simple_script_server()
00021 from std_msgs.msg import ColorRGBA
00022 from std_srvs.srv import Trigger, TriggerResponse
00023 from cob_light.srv import *
00024 from cob_light.msg import *
00025
00026
00027 def setLightCyan_cb(req):
00028 sss.set_light("light_base","cyan")
00029 sss.set_light("light_torso","cyan")
00030 return TriggerResponse(True, "")
00031
00032 def setLightRed_cb(req):
00033 sss.set_light("light_base","red")
00034 sss.set_light("light_torso","red")
00035 return TriggerResponse(True, "")
00036
00037 def setLightGreen_cb(req):
00038 sss.set_light("light_base","green")
00039 sss.set_light("light_torso","green")
00040 return TriggerResponse(True, "")
00041
00042 def setLightCyanSweep_cb(req):
00043
00044 sss.set_light("light_base","cyan")
00045
00046 try:
00047 set_light_torso = rospy.ServiceProxy("/light_torso/set_light",SetLightMode)
00048 light_mode = LightMode()
00049 cyan_color = ColorRGBA()
00050 cyan_color.r = 0.0
00051 cyan_color.g = 1.0
00052 cyan_color.b = 0.5
00053 cyan_color.a = 0.4
00054 light_mode.colors.append(cyan_color)
00055 light_mode.mode = 8
00056 light_mode.frequency = 30
00057 resp = set_light_torso(light_mode)
00058 print resp
00059 except rospy.ServiceException, e:
00060 print "Service call failed: %s"%e
00061 return TriggerResponse(False, "Calling light service failed.")
00062 return TriggerResponse(True, "")
00063
00064 def setLightCyanBreath_cb(req):
00065
00066 sss.set_light("light_base","cyan")
00067
00068 try:
00069 set_light_torso = rospy.ServiceProxy("/light_torso/set_light",SetLightMode)
00070 light_mode = LightMode()
00071 cyan_color = ColorRGBA()
00072 cyan_color.r = 0.0
00073 cyan_color.g = 1.0
00074 cyan_color.b = 0.5
00075 cyan_color.a = 0.4
00076 light_mode.colors.append(cyan_color)
00077 light_mode.mode = 3
00078 light_mode.frequency = 0.25
00079 resp = set_light_torso(light_mode)
00080 print resp
00081 except rospy.ServiceException, e:
00082 print "Service call failed: %s"%e
00083 return TriggerResponse(False, "Calling light service failed.")
00084 return TriggerResponse(True, "")
00085
00086
00087 def setMimicAfraid_cb(req):
00088 sss.set_mimic("mimic",["afraid",0,1])
00089 return TriggerResponse(True, "")
00090
00091 def setMimicAngry_cb(req):
00092 sss.set_mimic("mimic",["angry",0,1])
00093 return TriggerResponse(True, "")
00094
00095 def setMimicAsking_cb(req):
00096 sss.set_mimic("mimic",["asking",0,1])
00097 return TriggerResponse(True, "")
00098
00099 def setMimicBlinkingLeft_cb(req):
00100 sss.set_mimic("mimic",["blinking_left",0,1])
00101 return TriggerResponse(True, "")
00102
00103 def setMimicBlinking_cb(req):
00104 sss.set_mimic("mimic",["blinking",0,1])
00105 return TriggerResponse(True, "")
00106
00107 def setMimicBlinkingRight_cb(req):
00108 sss.set_mimic("mimic",["blinking_right",0,1])
00109 return TriggerResponse(True, "")
00110
00111 def setMimicBored_cb(req):
00112 sss.set_mimic("mimic",["bored",0,1])
00113 return TriggerResponse(True, "")
00114
00115 def setMimicBusy_cb(req):
00116 sss.set_mimic("mimic",["busy",0,1])
00117 return TriggerResponse(True, "")
00118
00119 def setMimicConfused_cb(req):
00120 sss.set_mimic("mimic",["confused",0,1])
00121 return TriggerResponse(True, "")
00122
00123 def setMimicDefault_cb(req):
00124 sss.set_mimic("mimic",["default",0,1])
00125 return TriggerResponse(True, "")
00126
00127 def setMimicFallingAsleep_cb(req):
00128 sss.set_mimic("mimic",["falling_asleep",0,1])
00129 return TriggerResponse(True, "")
00130
00131 def setMimicHappy_cb(req):
00132 sss.set_mimic("mimic",["happy",0,1])
00133 return TriggerResponse(True, "")
00134
00135 def setMimicLaughing_cb(req):
00136 sss.set_mimic("mimic",["laughing",0,1])
00137 return TriggerResponse(True, "")
00138
00139 def setMimicNo_cb(req):
00140 sss.set_mimic("mimic",["no",0,1])
00141 return TriggerResponse(True, "")
00142
00143 def setMimicSad_cb(req):
00144 sss.set_mimic("mimic",["sad",0,1])
00145 return TriggerResponse(True, "")
00146
00147 def setMimicSearching_cb(req):
00148 sss.set_mimic("mimic",["searching",0,1])
00149 return TriggerResponse(True, "")
00150
00151 def setMimicSleeping_cb(req):
00152 sss.set_mimic("mimic",["sleeping",0,1])
00153 return TriggerResponse(True, "")
00154
00155 def setMimicSurprised_cb(req):
00156 sss.set_mimic("mimic",["surprised",0,1])
00157 return TriggerResponse(True, "")
00158
00159 def setMimicTired_cb(req):
00160 sss.set_mimic("mimic",["tired",0,1])
00161 return TriggerResponse(True, "")
00162
00163 def setMimicWakingUp_cb(req):
00164 sss.set_mimic("mimic",["waking_up",0,1])
00165 return TriggerResponse(True, "")
00166
00167 def setMimicYes_cb(req):
00168 sss.set_mimic("mimic",["yes",0,1])
00169 return TriggerResponse(True, "")
00170
00171 def soundHello_cb(req):
00172 sss.say("sound", ["Hello, my name is Care O bot, a mobile service robot from Mojin Robotics."])
00173 return TriggerResponse(True, "")