23 from cob_script_server.msg
import ScriptAction, ScriptActionResult
24 from cob_script_server.srv
import ComposeTrajectory, ComposeTrajectoryResponse
25 from simple_script_server
import *
38 self.script_action_server.start()
43 print(
"compose trajectory", req.component_name, req.parameter_name)
44 traj_msg, error_code = sss.compose_trajectory(req.component_name, req.parameter_name)
47 res = ComposeTrajectoryResponse()
48 res.trajectory = traj_msg
57 server_result = ScriptActionResult().result
58 if server_goal.function_name ==
None or server_goal.function_name.strip() ==
"":
59 rospy.logerr(
"function name cannot be blank")
62 if server_goal.function_name
in dir(sss):
63 func = getattr(sss, server_goal.function_name)
64 argspec = inspect.getargspec(func)
66 for arg
in argspec.args:
67 if arg
in dir(server_goal):
68 serverArg = getattr(server_goal, arg)
69 if type(serverArg) == str:
71 serverArg = eval(serverArg)
76 handle01 = func(*(), **args)
78 rospy.logerr(
"function <<%s>> not supported", server_goal.function_name)
79 self.script_action_server.set_aborted(server_result)
82 if 'get_error_code' in dir(handle01):
83 server_result.error_code = handle01.get_error_code()
85 rospy.logwarn(
"unexpected action result type <<%s>> for function %s", type(handle01), server_goal.function_name)
86 if server_result.error_code == 0:
87 rospy.logdebug(
"action result success")
88 self.script_action_server.set_succeeded(server_result)
90 rospy.logerr(
"action result error, error_code: " + str(server_result.error_code))
91 self.script_action_server.set_aborted(server_result)
95 if __name__ ==
'__main__':
96 rospy.init_node(
'script_server')
98 rospy.loginfo(
"script_server is running")
def execute_cb(self, server_goal)
Executes actionlib callbacks.
def handle_compose_trajectory(self, req)
def __init__(self)
Initializes the actionlib interface of the script server.
Script server class which inherits from script class.
Simple script server class.
compose_trajectory_service