script_server_android.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 time
19 import inspect
20 
21 import rospy
22 
23 from cob_android_msgs.srv import Script, ScriptResponse
24 from simple_script_server import simple_script_server ## pylint: disable=no-name-in-module
26 
27 ## Script server class which inherits from script class.
28 #
29 # Implements actionlib interface for the script server.
30 #
31 class script_server():
32  ## Initializes the actionlib interface of the script server.
33  #
34  def __init__(self):
35  rospy.Service('/script_server_android/script_service', Script, self.service_cb)
36 
37  def service_cb(self, req):
38  res = ScriptResponse()
39  if req.function_name == "trigger":
40  if req.parameter_name == "init":
41  handle01 = sss.init(req.component_name, blocking=False)
42  elif req.parameter_name == "stop":
43  handle01 = sss.stop(req.component_name, mode=req.mode, blocking=False)
44  elif req.parameter_name == "recover":
45  handle01 = sss.recover(req.component_name, blocking=False)
46  elif req.parameter_name == "halt":
47  handle01 = sss.halt(req.component_name, blocking=False)
48  elif req.parameter_name == "compose_trajectory":
49  handle01 = sss.compose_trajectory(req.component_name, req.parameter_name)
50  else:
51  handle01 = sss.trigger(req.component_name, req.parameter_name, blocking=False)
52  elif req.function_name == "move":
53  handle01 = sss.move(req.component_name,req.parameter_name, blocking=False, mode=req.mode)
54  elif req.function_name == "move_base_rel":
55  handle01 = sss.move_base_rel(req.component_name,req. parameter_name, blocking=False)
56  elif req.function_name == "light":
57  handle01 = sss.set_light(req.component_name, req.parameter_name, blocking=False)
58  elif req.function_name == "stop":
59  handle01 = sss.stop(req.component_name, blocking=False)
60  elif req.function_name == "init":
61  handle01 = sss.init(req.component_name, blocking=False)
62  elif req.function_name == "recover":
63  handle01 = sss.recover(req.component_name, blocking=False)
64  elif req.function_name == "halt":
65  handle01 = sss.halt(req.component_name, blocking=False)
66  elif req.function_name == "compose_trajectory":
67  handle01 = sss.compose_trajectory(req.component_name, req.parameter_name)
68  elif req.function_name == "trigger_action":
69  handle01 = sss.trigger_action(req.component_name, req.parameter_name)
70  else:
71  rospy.logerr("function <<%s>> not supported", req.function_name)
72  res.error_code = -1
73  return res
74 
75  res.error_code = handle01.get_error_code()
76  if res.error_code == 0:
77  rospy.logdebug("service result success")
78  else:
79  rospy.logerr("service result error")
80  return res
81 
82 ## Main routine for running the script server
83 #
85  rospy.init_node('script_server')
87  rospy.loginfo("script_server is running")
88  rospy.spin()
def script_server_android_main()
Main routine for running the script server.
Script server class which inherits from script class.
def __init__(self)
Initializes the actionlib interface of the script server.


cob_android_script_server
Author(s): Benjamin Maidel
autogenerated on Tue Jan 19 2021 03:49:33