23 from cob_android_msgs.srv
import Script, ScriptResponse
24 from simple_script_server
import simple_script_server
35 rospy.Service(
'/script_server_android/script_service', Script, self.
service_cb)
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)
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)
71 rospy.logerr(
"function <<%s>> not supported", req.function_name)
75 res.error_code = handle01.get_error_code()
76 if res.error_code == 0:
77 rospy.logdebug(
"service result success")
79 rospy.logerr(
"service result error")
85 rospy.init_node(
'script_server')
87 rospy.loginfo(
"script_server is running")
def script_server_android_main()
Main routine for running the script server.
def service_cb(self, req)
Script server class which inherits from script class.
def __init__(self)
Initializes the actionlib interface of the script server.