Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 import time
00019 import inspect
00020
00021 import rospy
00022
00023 from cob_android_msgs.srv import *
00024 from simple_script_server import *
00025
00026 sss = simple_script_server()
00027
00028
00029
00030
00031
00032 class script_server():
00033
00034
00035 def __init__(self):
00036 rospy.Service('/script_server_android/script_service', Script, self.service_cb)
00037
00038 def service_cb(self, req):
00039 res = ScriptResponse()
00040 if req.function_name == "trigger":
00041 if req.parameter_name == "init":
00042 handle01 = sss.init(req.component_name, blocking=False)
00043 elif req.parameter_name == "stop":
00044 handle01 = sss.stop(req.component_name, mode=req.mode, blocking=False)
00045 elif req.parameter_name == "recover":
00046 handle01 = sss.recover(req.component_name, blocking=False)
00047 elif req.parameter_name == "halt":
00048 handle01 = sss.halt(req.component_name, blocking=False)
00049 elif req.parameter_name == "compose_trajectory":
00050 handle01 = sss.compose_trajectory(req.component_name, req.parameter_name)
00051 else:
00052 handle01 = sss.trigger(req.component_name, req.parameter_name, blocking=False)
00053 elif req.function_name == "move":
00054 handle01 = sss.move(req.component_name,req.parameter_name, blocking=False, mode=req.mode)
00055 elif req.function_name == "move_base_rel":
00056 handle01 = sss.move_base_rel(req.component_name,req. parameter_name, blocking=False)
00057 elif req.function_name == "light":
00058 handle01 = sss.set_light(req.component_name, req.parameter_name, blocking=False)
00059 elif req.function_name == "stop":
00060 handle01 = sss.stop(req.component_name, blocking=False)
00061 elif req.function_name == "init":
00062 handle01 = sss.init(req.component_name, blocking=False)
00063 elif req.function_name == "recover":
00064 handle01 = sss.recover(req.component_name, blocking=False)
00065 elif req.function_name == "halt":
00066 handle01 = sss.halt(req.component_name, blocking=False)
00067 elif req.function_name == "compose_trajectory":
00068 handle01 = sss.compose_trajectory(req.component_name, req.parameter_name)
00069 elif req.function_name == "trigger_action":
00070 handle01 = sss.trigger_action(req.component_name, req.parameter_name)
00071 else:
00072 rospy.logerr("function <<%s>> not supported", req.function_name)
00073 res.error_code = -1
00074 return res
00075
00076 res.error_code = handle01.get_error_code()
00077 if res.error_code == 0:
00078 rospy.logdebug("service result success")
00079 else:
00080 rospy.logerr("service result error")
00081 return res
00082
00083
00084
00085 def script_server_android_main():
00086 rospy.init_node('script_server')
00087 script_server()
00088 rospy.loginfo("script_server is running")
00089 rospy.spin()