toolchanger_command.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 abs_hand_command import AbsractHandCommand
38 
39 
40 class ToolchangerCommand(AbsractHandCommand):
41  '''
42  Following Command design pattern, this class represents commands for
43  a toolchanger of NEXTAGE OPEN.
44  '''
45  # TODO: Unittest is needed!!
46 
47  # For grippers
48  HAND_TOOLCHANGE_ON = 'toolchange_on'
49  HAND_TOOLCHANGE_OFF = 'toolchange_off'
50 
51  def __init__(self, hands, hand, dio_pins):
52  super(ToolchangerCommand, self).__init__(hands, hand, dio_pins)
53 
54  def _assign_dio_names(self, dio_pins):
55  '''
56  @see abs_hand_command.AbsractHandCommand._assign_dio_names
57  '''
58  self._DIO_VALVE5PORT_L = dio_pins[0]
59  self._DIO_AIR_DRAWIN_L = dio_pins[1]
60  self._DIO_AIR_RELEASE_L = dio_pins[2]
61  self._DIO_VALVE5PORT_R = dio_pins[3]
62  self._DIO_AIR_DRAWIN_R = dio_pins[4]
63  self._DIO_AIR_RELEASE_R = dio_pins[5]
64 
65  def execute(self, operation):
66  '''
67  @see abs_hand_command.AbsractHandCommand.execute
68  '''
69  dout = []
70  # Chuck hand uses 2 bits, either of which needs to remain on to keep
71  # grasping position firmly. This becomes an issue when a hand is
72  # detatched after some grasping actions where the air keeps blowing
73  # out. Thus when detatched, air bits for chuck hand need to be turned
74  # off and these 2 bits are included in the masking bit.
75  mask = []
76  if self.HAND_TOOLCHANGE_ON == operation:
77  if self._hands.HAND_L == self._hand:
78  # 10/29/2013 DIO changed. Now '1' is ON for both 5PORT Valves.
79  mask = [self._DIO_VALVE5PORT_L]
80  elif self._hands.HAND_R == self._hand:
81  mask = [self._DIO_VALVE5PORT_R]
82  elif self.HAND_TOOLCHANGE_OFF == operation:
83  if self._hands.HAND_L == self._hand:
84  # 10/29/2013 DIO changed. Now '0' is OFF for both 5PORT Valves.
85  # 1/31/2014 DIO changed. Now '1' is OFF for both 5PORT Valves.
86  mask.append(self._DIO_VALVE5PORT_L)
87  mask.append(self._DIO_AIR_DRAWIN_L)
88  dout = [self._DIO_VALVE5PORT_L]
89  elif self._hands.HAND_R == self._hand:
90  mask.append(self._DIO_VALVE5PORT_R)
91  mask.append(self._DIO_AIR_DRAWIN_R)
92  dout = [self._DIO_VALVE5PORT_R]
93  return self._hands._dio_writer(dout, mask)
94 
95  def release_ejector(self, hand=None, on=True):
96  '''
97  @deprecated: TODO: need to figure out how this can be used. Until
98  then, set derprecated.
99  '''
100  dout = []
101  mask = []
102  if on:
103  if self.HAND_R == hand:
104  # TODO: Make sure if turning both ejectors at once is the right
105  # usage.
106  dout = mask = [self._DIO_EJECTOR_R_1, self._DIO_EJECTOR_R_2]
107  elif self.HAND_L == hand:
108  dout = mask = [self._DIO_EJECTOR_L_1, self._DIO_EJECTOR_L_2]
109  elif not hand:
110  dout = mask = [self._DIO_EJECTOR_R_1, self._DIO_EJECTOR_R_2,
111  self._DIO_EJECTOR_L_1, self._DIO_EJECTOR_L_2]
112  else:
113  if self.HAND_R == hand:
114  mask = [self._DIO_EJECTOR_R_1, self._DIO_EJECTOR_R_2]
115  elif self.HAND_L == hand:
116  mask = [self._DIO_EJECTOR_L_1, self._DIO_EJECTOR_L_2]
117  elif not hand:
118  mask = [self._DIO_EJECTOR_R_1, self._DIO_EJECTOR_R_2,
119  self._DIO_EJECTOR_L_1, self._DIO_EJECTOR_L_2]
120  return self._hands._dio_writer(dout, mask)


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