5 from control_msgs.msg
import GripperCommandAction, GripperCommandResult
11 rospy.init_node(action_name)
12 rospy.loginfo(
'gripper_action server started')
15 robot_ns = self._tool_io_param.get(
'robot_ns')
17 rospy.loginfo(
'wating I/O interface')
19 rospy.loginfo(
'I/O found')
23 self.action_server.start()
24 rospy.loginfo(
'action server started')
34 param = self._tool_io_param.get(name)
35 print(
'_io_operation: {} {}'.format(name, param))
37 for x
in param[
'trigger']:
39 self._io.set_digital_val(addr, *data)
40 for x
in param[
'state']:
42 print(
'wait state: {} {}'.format(addr, data))
43 result = self._io.wait_digital_val(addr, data, time_out=1.0)
44 print(
'result: {}'.format(result))
50 start_addr = min(map(int, param.keys()))
51 end_addr = max(map(int, param.keys()))
53 data = [param.get(str(k), -1)
for k
in range(start_addr, end_addr + 1)]
55 return start_addr, data
58 print(
'------------------execute_action')
60 if goal.command.position > 0:
61 success = self.
_open()
66 result = GripperCommandResult()
67 result.position = goal.command.position
68 result.effort = goal.command.max_effort
69 result.reached_goal =
True 71 self.action_server.set_succeeded(result)
72 print(
'------------------set_succeeded')
74 rospy.loginfo(
'tool operation aboarted')
75 self.action_server.set_aborted()
76 print(
'------------------set_aborted')
78 if __name__ ==
'__main__':
def execute_action(self, goal)
def _translate_io_param(self, param)
def __init__(self, action_name)
def _io_operation(self, name)