00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 from hironx_ros_bridge.hironx_client import HIRONX
00038
00039 from nextage_ros_bridge.iros13_hands import Iros13Hands
00040 from nextage_ros_bridge.hands_05 import Hands05
00041
00042
00043 class NextageClient(HIRONX, object):
00044
00045
00046
00047 '''
00048 This class holds methods that are specific to Kawada Industries' dual-arm
00049 robot called Nextage Open.
00050 '''
00051
00052
00053 ''' Overriding a variable in the superclass to set the arms at higher
00054 positions.'''
00055 OffPose = [[0], [0, 0],
00056 [25, -140, -150, 45, 0, 0],
00057 [-25, -140, -150, -45, 0, 0],
00058 [0, 0, 0, 0],
00059 [0, 0, 0, 0]]
00060
00061
00062
00063
00064 _DI_PORTS_L = [25, 21, 22, 23, 24]
00065 _DI_PORTS_R = [20, 16, 17, 18, 19]
00066
00067 HAND_VER_0_4_2 = '0.4.2'
00068 HAND_VER_0_5_1 = '0.5.1'
00069
00070 def __init__(self):
00071 '''
00072 Do not get confused that there is also a method called
00073 'init' (without trailing underscores) that is succeeded from the
00074 super class as the tradition there.
00075 '''
00076 super(NextageClient, self).__init__()
00077 self.set_hand_version(self.HAND_VER_0_5_1)
00078
00079 def init(self, robotname="HiroNX(Robot)0", url=""):
00080 '''
00081 Calls init from its superclass, which tries to connect RTCManager,
00082 looks for ModelLoader, and starts necessary RTC components. Also runs
00083 config, logger.
00084 Also internally calls setSelfGroups().
00085
00086 @type robotname: str
00087 @type url: str
00088 '''
00089 HIRONX.init(self, robotname=robotname, url=url)
00090
00091 def get_hand_version(self):
00092 '''
00093 @rtype: str
00094 '''
00095 if not self._hand_version:
00096 return 'Hand module not set yet.'
00097 else:
00098 return self._hand_version
00099
00100 def set_hand_version(self, version=HAND_VER_0_5_1):
00101 self._hand_version = version
00102 if self.HAND_VER_0_4_2 == self._hand_version:
00103 self._hands = Iros13Hands(self)
00104 elif self.HAND_VER_0_5_1 == self._hand_version:
00105 self._hands = Hands05(self)
00106
00107 def handlight_r(self, is_on=True):
00108 '''
00109 @deprecated: Won't be functional after package version 0.5.1.
00110 Use self._hands.%FUNCTION_NAME% instead.
00111 '''
00112 return self._hands.handlight_r(is_on)
00113
00114 def handlight_l(self, is_on=True):
00115 '''
00116 @deprecated: Won't be functional after package version 0.5.1.
00117 Use self._hands.%FUNCTION_NAME% instead.
00118 '''
00119 return self._hands.handlight_r(is_on)
00120
00121 def handlight_both(self, is_on=True):
00122 '''
00123 @deprecated: Won't be functional after package version 0.5.1.
00124 Use self._hands.%FUNCTION_NAME% instead.
00125 '''
00126 return self._hands.handlight_both(is_on)
00127
00128 def handtool_l_eject(self):
00129 '''
00130 @deprecated: Won't be functional after package version 0.5.1.
00131 Use self._hands.%FUNCTION_NAME% instead.
00132 '''
00133 return self._hands.toolchanger_l_command.execute(
00134 self._hands.toolchanger_l_command.HAND_TOOLCHANGE_OFF)
00135
00136 def handtool_r_eject(self):
00137 '''
00138 @deprecated: Won't be functional after package version 0.5.1.
00139 Use self._hands.%FUNCTION_NAME% instead.
00140 '''
00141 return self._hands.toolchanger_r_command.execute(
00142 self._hands.toolchanger_r_command.HAND_TOOLCHANGE_OFF)
00143
00144 def handtool_l_attach(self):
00145 '''
00146 @deprecated: Won't be functional after package version 0.5.1.
00147 Use self._hands.%FUNCTION_NAME% instead.
00148 '''
00149 return self._hands.toolchanger_l_command.execute(
00150 self._hands.toolchanger_l_command.HAND_TOOLCHANGE_ON)
00151
00152 def handtool_r_attach(self):
00153 '''
00154 @deprecated: Won't be functional after package version 0.5.1.
00155 Use self._hands.%FUNCTION_NAME% instead.
00156 '''
00157 return self._hands.toolchanger_r_command.execute(
00158 self._hands.toolchanger_r_command.HAND_TOOLCHANGE_ON)
00159
00160 def gripper_l_close(self):
00161 '''
00162 @deprecated: Won't be functional after package version 0.5.1.
00163 Use self._hands.%FUNCTION_NAME% instead.
00164 '''
00165 return self._hands.gripper_l_command.execute(
00166 self._hands.gripper_l_command.GRIPPER_CLOSE)
00167
00168 def gripper_r_close(self):
00169 '''
00170 @deprecated: Won't be functional after package version 0.5.1.
00171 Use self._hands.%FUNCTION_NAME% instead.
00172 '''
00173 return self._hands.gripper_r_command.execute(
00174 self._hands.gripper_r_command.GRIPPER_CLOSE)
00175
00176 def gripper_l_open(self):
00177 '''
00178 @deprecated: Won't be functional after package version 0.5.1.
00179 Use self._hands.%FUNCTION_NAME% instead.
00180 '''
00181 return self._hands.gripper_l_command.execute(
00182 self._hands.gripper_r_command.GRIPPER_OPEN)
00183
00184 def gripper_r_open(self):
00185 '''
00186 @deprecated: Won't be functional after package version 0.5.1.
00187 Use self._hands.%FUNCTION_NAME% instead.
00188 '''
00189 return self._hands.gripper_r_command.execute(
00190 self._hands.gripper_r_command.GRIPPER_OPEN)
00191
00192 def airhand_l_drawin(self):
00193 '''
00194 @deprecated: Won't be functional after package version 0.5.1.
00195 Use self._hands.%FUNCTION_NAME% instead.
00196 '''
00197 return self._hands.airhand_l_command.execute(
00198 self._hands.airhand_l_command.AIRHAND_DRAWIN)
00199
00200 def airhand_r_drawin(self):
00201 '''
00202 @deprecated: Won't be functional after package version 0.5.1.
00203 Use self._hands.%FUNCTION_NAME% instead.
00204 '''
00205 return self._hands.airhand_r_command.execute(
00206 self._hands.airhand_r_command.AIRHAND_DRAWIN)
00207
00208 def airhand_l_keep(self):
00209 '''
00210 @deprecated: Won't be functional after package version 0.5.1.
00211 Use self._hands.%FUNCTION_NAME% instead.
00212 '''
00213 return self._hands.airhand_l_command.execute(
00214 self._hands.airhand_l_command.AIRHAND_KEEP)
00215
00216 def airhand_r_keep(self):
00217 '''
00218 @deprecated: Won't be functional after package version 0.5.1.
00219 Use self._hands.%FUNCTION_NAME% instead.
00220 '''
00221 return self._hands.airhand_r_command.execute(
00222 self._hands.airhand_r_command.AIRHAND_KEEP)
00223
00224 def airhand_l_release(self):
00225 '''
00226 @deprecated: Won't be functional after package version 0.5.1.
00227 Use self._hands.%FUNCTION_NAME% instead.
00228 '''
00229 return self._hands.airhand_l_command.execute(
00230 self._hands.airhand_l_command.AIRHAND_RELEASE)
00231
00232 def airhand_r_release(self):
00233 '''
00234 @deprecated: Won't be functional after package version 0.5.1.
00235 Use self._hands.%FUNCTION_NAME% instead.
00236 '''
00237 return self._hands.airhand_r_command.execute(
00238 self._hands.airhand_r_command.AIRHAND_RELEASE)
00239
00240 def initialize_hand_dio(self):
00241 '''
00242 @deprecated: Won't be functional after package version 0.5.1.
00243 Use self._hands.%FUNCTION_NAME% instead.
00244
00245 Reset all DIO channels to "off" state except for toolchanger lockers
00246 (if they are turned off the attached tools will fall).
00247 '''
00248 self._hands.init_dio()
00249
00250 def getRTCList(self):
00251 '''
00252 Overwriting HrpsysConfigurator.getRTCList
00253 Returning predefined list of RT components.
00254 @rtype [[str]]
00255 @rerutrn List of available components. Each element consists of a list
00256 of abbreviated and full names of the component.
00257 '''
00258 return [
00259 ['seq', "SequencePlayer"],
00260 ['sh', "StateHolder"],
00261 ['fk', "ForwardKinematics"],
00262 ['el', "SoftErrorLimiter"],
00263
00264
00265 ['log', "DataLogger"]
00266 ]
00267
00268 def goInitial(self, tm=7, wait=True, init_pose_type=0):
00269 '''
00270 @see: HIRONX.goInitial
00271 '''
00272 if not init_pose_type:
00273
00274 init_pose_type = HIRONX.INITPOS_TYPE_EVEN
00275 return HIRONX.goInitial(self, tm, wait, init_pose_type)
00276
00277 def readDinGroup(self, ports, dumpFlag=True):
00278 '''
00279 Print the currently set values of digital input registry. Print output order is tailored
00280 for the hands' functional group; DIO spec that is disloseable as of 7/17/2014 is:
00281
00282 Left hand:
00283 DI26: Tool changer attached or not.
00284 DI22, 23: Fingers.
00285 DI24, 25: Compliance.
00286
00287 Right hand:
00288 DI21: Tool changer attached or not.
00289 DI17, 18: Fingers.
00290 DI19, 20: Compliance.
00291
00292 Example output, for the right hand:
00293
00294 No hand attached:
00295
00296 In [1]: robot.printDin([20, 16, 17, 18, 19])
00297 DI21 is 0
00298 DI17 is 0
00299 DI18 is 0
00300 DI19 is 0
00301 DI20 is 0
00302 Out[1]: [(20, 0), (16, 0), (17, 0), (18, 0), (19, 0)]
00303
00304 Hand attached, fingers closed:
00305
00306 In [1]: robot.printDin([20, 16, 17, 18, 19])
00307 DI21 is 1
00308 DI17 is 1
00309 DI18 is 0
00310 DI19 is 0
00311 DI20 is 0
00312 Out[1]: [(20, 0), (16, 0), (17, 0), (18, 0), (19, 0)]
00313
00314 @author: Koichi Nagashima
00315 @since: 0.2.16
00316 @type ports: int or [int].
00317 @param dumpFlag: Print each pin if True.
00318 @param ports: A port number or a list of port numbers in D-in registry.
00319 @rtype: [(int, int)]
00320 @return: List of tuples of port and din value. If the arg ports was an int value,
00321 this could be a list with single tuple in it.
00322 '''
00323 if isinstance(ports, int):
00324 ports = [ports];
00325 pass;
00326
00327
00328 din = self.readDigitalInput();
00329 resAry=[];
00330 for port in ports:
00331 res = din[port]
00332 if (dumpFlag): print("DI%02d is %d"%(port+1,res));
00333 resAry.append((port, res));
00334 pass;
00335 return resAry;
00336
00337 def readDinGroupL(self, dumpFlag=True):
00338 return self.readDinGroup(self._DI_PORTS_L, dumpFlag)
00339
00340 def readDinGroupR(self, dumpFlag=True):
00341 return self.readDinGroup(self._DI_PORTS_R, dumpFlag)
00342