default_behavior.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #
3 # Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 
17 
18 import rospy
19 from simple_script_server import *
21 from std_msgs.msg import ColorRGBA
22 from std_srvs.srv import Trigger, TriggerResponse
23 from cob_light.srv import *
24 from cob_light.msg import *
25 
26 
27 def setLightCyan_cb(req):
28  sss.set_light("light_base","cyan")
29  sss.set_light("light_torso","cyan")
30  return TriggerResponse(True, "")
31 
32 def setLightRed_cb(req):
33  sss.set_light("light_base","red")
34  sss.set_light("light_torso","red")
35  return TriggerResponse(True, "")
36 
38  sss.set_light("light_base","green")
39  sss.set_light("light_torso","green")
40  return TriggerResponse(True, "")
41 
43  #rospy.wait_for_service('/light_torso/set_light')
44  sss.set_light("light_base","cyan")
45 
46  try:
47  set_light_torso = rospy.ServiceProxy("/light_torso/set_light",SetLightMode)
48  light_mode = LightMode()
49  cyan_color = ColorRGBA()
50  cyan_color.r = 0.0
51  cyan_color.g = 1.0
52  cyan_color.b = 0.5
53  cyan_color.a = 0.4
54  light_mode.colors.append(cyan_color)
55  light_mode.mode = 8
56  light_mode.frequency = 30
57  resp = set_light_torso(light_mode)
58  print(resp)
59  except rospy.ServiceException as e:
60  print("Service call failed: %s"%e)
61  return TriggerResponse(False, "Calling light service failed.")
62  return TriggerResponse(True, "")
63 
65  #rospy.wait_for_service('/light_torso/set_light')
66  sss.set_light("light_base","cyan")
67 
68  try:
69  set_light_torso = rospy.ServiceProxy("/light_torso/set_light",SetLightMode)
70  light_mode = LightMode()
71  cyan_color = ColorRGBA()
72  cyan_color.r = 0.0
73  cyan_color.g = 1.0
74  cyan_color.b = 0.5
75  cyan_color.a = 0.4
76  light_mode.colors.append(cyan_color)
77  light_mode.mode = 3
78  light_mode.frequency = 0.25
79  resp = set_light_torso(light_mode)
80  print(resp)
81  except rospy.ServiceException as e:
82  print("Service call failed: %s"%e)
83  return TriggerResponse(False, "Calling light service failed.")
84  return TriggerResponse(True, "")
85 
86 
88  sss.set_mimic("mimic",["afraid",0,1])
89  return TriggerResponse(True, "")
90 
92  sss.set_mimic("mimic",["angry",0,1])
93  return TriggerResponse(True, "")
94 
96  sss.set_mimic("mimic",["asking",0,1])
97  return TriggerResponse(True, "")
98 
100  sss.set_mimic("mimic",["blinking_left",0,1])
101  return TriggerResponse(True, "")
102 
104  sss.set_mimic("mimic",["blinking",0,1])
105  return TriggerResponse(True, "")
106 
108  sss.set_mimic("mimic",["blinking_right",0,1])
109  return TriggerResponse(True, "")
110 
112  sss.set_mimic("mimic",["bored",0,1])
113  return TriggerResponse(True, "")
114 
116  sss.set_mimic("mimic",["busy",0,1])
117  return TriggerResponse(True, "")
118 
120  sss.set_mimic("mimic",["confused",0,1])
121  return TriggerResponse(True, "")
122 
124  sss.set_mimic("mimic",["default",0,1])
125  return TriggerResponse(True, "")
126 
128  sss.set_mimic("mimic",["falling_asleep",0,1])
129  return TriggerResponse(True, "")
130 
132  sss.set_mimic("mimic",["happy",0,1])
133  return TriggerResponse(True, "")
134 
136  sss.set_mimic("mimic",["laughing",0,1])
137  return TriggerResponse(True, "")
138 
139 def setMimicNo_cb(req):
140  sss.set_mimic("mimic",["no",0,1])
141  return TriggerResponse(True, "")
142 
143 def setMimicSad_cb(req):
144  sss.set_mimic("mimic",["sad",0,1])
145  return TriggerResponse(True, "")
146 
148  sss.set_mimic("mimic",["searching",0,1])
149  return TriggerResponse(True, "")
150 
152  sss.set_mimic("mimic",["sleeping",0,1])
153  return TriggerResponse(True, "")
154 
156  sss.set_mimic("mimic",["surprised",0,1])
157  return TriggerResponse(True, "")
158 
160  sss.set_mimic("mimic",["tired",0,1])
161  return TriggerResponse(True, "")
162 
164  sss.set_mimic("mimic",["waking_up",0,1])
165  return TriggerResponse(True, "")
166 
167 def setMimicYes_cb(req):
168  sss.set_mimic("mimic",["yes",0,1])
169  return TriggerResponse(True, "")
170 
171 def soundHello_cb(req):
172  sss.say("sound", ["Hello, my name is Care O bot, a mobile service robot from Mojin Robotics."])
173  return TriggerResponse(True, "")


cob_default_robot_behavior
Author(s): Felix Messmer , Nadia Hammoudeh Garcia
autogenerated on Sat Dec 5 2020 03:54:43