iros13_hands.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 # Software License Agreement (BSD License)
4 #
5 # Copyright (c) 2013, Tokyo Opensource Robotics Kyokai Association
6 # All rights reserved.
7 #
8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions
10 # are met:
11 #
12 # * Redistributions of source code must retain the above copyright
13 # notice, this list of conditions and the following disclaimer.
14 # * Redistributions in binary form must reproduce the above
15 # copyright notice, this list of conditions and the following
16 # disclaimer in the documentation and/or other materials provided
17 # with the distribution.
18 # * Neither the name of Tokyo Opensource Robotics Kyokai Association. nor the
19 # names of its contributors may be used to endorse or promote products
20 # derived from this software without specific prior written permission.
21 #
22 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 # POSSIBILITY OF SUCH DAMAGE.
34 #
35 # Author: Isaac Isao Saito
36 
37 from nextage_ros_bridge.base_hands import BaseHands
38 from nextage_ros_bridge.command.airhand_command import AbsractHandCommand
39 from nextage_ros_bridge.command.airhand_command import AirhandCommand
40 from nextage_ros_bridge.command.gripper_command import GripperCommand
41 from nextage_ros_bridge.command.handlight_command import HandlightCommand
42 from nextage_ros_bridge.command.toolchanger_command import ToolchangerCommand
43 
44 
46  '''
47  This class holds methods to operate the hands of NEXTAGE OPEN in a specific
48  configuration where a clipping hand on left and suction hand on right
49  connected to toolchanger module. This was presented at IROS 2013.
50  '''
51  # TODO: Unittest is needed!!
52 
53  def __init__(self, parent):
54  '''
55  @see: AbsractIros13Hands.__init__
56  '''
57 
58  # Instantiating public command classes.
59  #
60  # There can be at least 2 ways for the Robot client classes
61  # (eg. See nextage_client.NextageClient) to call hand commands.
62  #
63  # (1) Call directly the 'execute' methods of each command.
64  # (2) Call via interface methods in the hand class.
65  #
66  # In Iros13Hands class, (1) is used. (1) is faster to implement. And
67  # I think it's ok for robot client classes to know what commands exist,
68  # without the hand class has the interfaces for comamands. But you can
69  # always apply (2) approach, which is cleaner.
70  super(Iros13Hands, self).__init__(parent)
71  _pins_airhand = [self.DIO_27, self.DIO_28, self.DIO_22, self.DIO_23]
72  _pins_gripper = [self.DIO_25, self.DIO_26, self.DIO_20, self.DIO_21]
73  self.airhand_l_command = AirhandCommand(self, self.HAND_L, _pins_airhand)
74  self.airhand_r_command = AirhandCommand(self, self.HAND_R, _pins_airhand)
75  self.gripper_l_command = GripperCommand(self, self.HAND_L, _pins_gripper)
76  self.gripper_r_command = GripperCommand(self, self.HAND_R, _pins_gripper)
77 
78  _pins_handlight = [self.DIO_18, self.DIO_17]
79  _pins_toolchanger = [self.DIO_24, self.DIO_25, self.DIO_26,
80  self.DIO_19, self.DIO_20, self.DIO_21]
81  # The following lines are moved from BaseToolchangerHands
82  self.handlight_l_command = HandlightCommand(self, self.HAND_L, _pins_handlight)
83  self.handlight_r_command = HandlightCommand(self, self.HAND_R, _pins_handlight)
84  self.toolchanger_l_command = ToolchangerCommand(self, self.HAND_L, _pins_toolchanger)
85  self.toolchanger_r_command = ToolchangerCommand(self, self.HAND_R, _pins_toolchanger)
86 
87  def airhand_l_drawin(self):
88  return self.airhand_l_command.execute(self.airhand_l_command.AIRHAND_DRAWIN)
89 
90  def airhand_r_drawin(self):
91  return self.airhand_r_command.execute(self.airhand_r_command.AIRHAND_DRAWIN)
92 
93  def airhand_l_keep(self):
94  return self.airhand_l_command.execute(self.airhand_l_command.AIRHAND_KEEP)
95 
96  def airhand_r_keep(self):
97  return self.airhand_r_command.execute(self.airhand_r_command.AIRHAND_KEEP)
98 
99  def airhand_l_release(self):
100  return self.airhand_l_command.execute(self.airhand_l_command.AIRHAND_RELEASE)
101 
102  def airhand_r_release(self):
103  return self.airhand_r_command.execute(self.airhand_r_command.AIRHAND_RELEASE)
104 
105  def gripper_l_close(self):
106  return self.gripper_l_command.execute(self.gripper_l_command.GRIPPER_CLOSE)
107 
108  def gripper_r_close(self):
109  return self.gripper_r_command.execute(self.gripper_r_command.GRIPPER_CLOSE)
110 
111  def gripper_l_open(self):
112  return self.gripper_l_command.execute(self.gripper_r_command.GRIPPER_OPEN)
113 
114  def gripper_r_open(self):
115  return self.gripper_r_command.execute(self.gripper_r_command.GRIPPER_OPEN)
116 
117  def handtool_l_eject(self):
118  return self.toolchanger_l_command.execute(
119  self.toolchanger_l_command.HAND_TOOLCHANGE_OFF)
120 
121  def handtool_r_eject(self):
122  return self.toolchanger_r_command.execute(
123  self.toolchanger_r_command.HAND_TOOLCHANGE_OFF)
124 
125  def handtool_l_attach(self):
126  return self.toolchanger_l_command.execute(
127  self.toolchanger_l_command.HAND_TOOLCHANGE_ON)
128 
129  def handtool_r_attach(self):
130  return self.toolchanger_r_command.execute(
131  self.toolchanger_r_command.HAND_TOOLCHANGE_ON)
132 
133  def handlight_r(self, is_on=True):
134  return self.handlight_r_command.turn_handlight(self.HAND_R, is_on)
135 
136  def handlight_l(self, is_on=True):
137  return self.handlight_l_command.turn_handlight(self.HAND_L, is_on)
138 
139  def handlight_both(self, is_on=True):
140  result = self.handlight_l_command.turn_handlight(self.HAND_L, is_on)
141  result = result and self.handlight_r_command.turn_handlight(self.HAND_R, is_on)
142  return result


nextage_ros_bridge
Author(s): Isaac Isao Saito , Akio Ochiai
autogenerated on Wed Jun 17 2020 04:14:47