1 from __future__
import print_function
11 CONFIGURATION_DATA = 6
30 PART_D_CALIBRATION = 237
33 EMERGENCY_STOPPED = 240
34 CALVAL_INITIALIZATION = 241
39 MOTOR_INITIALISATION = 246
41 DEAD_COMMUTATION = 248
61 ROBOT_EMERGENCY_STOP = 5
62 EXTERNAL_EMERGENCY_STOP = 6
77 (plen, ptype) = struct.unpack_from(
"!IB", buf)
79 return RobotModeData_V18.unpack(buf)
81 return RobotModeData_V30.unpack(buf)
83 print(
"RobotModeData has wrong length: " + str(plen))
88 __slots__ = [
'timestamp',
'robot_connected',
'real_robot_enabled',
89 'power_on_robot',
'emergency_stopped',
90 'security_stopped',
'program_running',
'program_paused',
91 'robot_mode',
'speed_fraction']
96 rmd.timestamp, rmd.robot_connected, rmd.real_robot_enabled,
97 rmd.power_on_robot, rmd.emergency_stopped, rmd.security_stopped,
98 rmd.program_running, rmd.program_paused, rmd.robot_mode,
99 rmd.speed_fraction) = struct.unpack_from(
"!IBQ???????Bd", buf)
104 __slots__ = [
'timestamp',
'robot_connected',
'real_robot_enabled',
105 'power_on_robot',
'emergency_stopped',
106 'security_stopped',
'program_running',
'program_paused',
107 'robot_mode',
'control_mode',
'target_speed_fraction',
113 rmd.timestamp, rmd.robot_connected, rmd.real_robot_enabled,
114 rmd.power_on_robot, rmd.emergency_stopped, rmd.security_stopped,
115 rmd.program_running, rmd.program_paused, rmd.robot_mode, rmd.control_mode,
116 rmd.target_speed_fraction, rmd.speed_scaling) = struct.unpack_from(
"!IBQ???????BBdd", buf)
121 __slots__ = [
'q_actual',
'q_target',
'qd_actual',
122 'I_actual',
'V_actual',
'T_motor',
'T_micro',
'joint_mode']
129 (jd.q_actual, jd.q_target, jd.qd_actual, jd.I_actual, jd.V_actual,
130 jd.T_motor, jd.T_micro,
131 jd.joint_mode) = struct.unpack_from(
"!dddffffB", buf, offset)
133 all_joints.append(jd)
138 __slots__ = [
'analog_input_range2',
'analog_input_range3',
139 'analog_input2',
'analog_input3',
140 'tool_voltage_48V',
'tool_output_voltage',
'tool_current',
141 'tool_temperature',
'tool_mode']
146 td.analog_input_range2, td.analog_input_range3,
147 td.analog_input2, td.analog_input3,
148 td.tool_voltage_48V, td.tool_output_voltage, td.tool_current,
149 td.tool_temperature, td.tool_mode) = struct.unpack_from(
"!IBbbddfBffB", buf)
157 (plen, ptype) = struct.unpack_from(
"!IB", buf)
158 if (plen == 64)
or (plen == 76):
159 return MasterboardData_V18.unpack(buf)
160 elif (plen == 72)
or (plen == 92):
161 return MasterboardData_V30.unpack(buf)
163 print(
"MasterboardData has wrong length: " + str(plen))
164 print(
"Euromap67Interface is ignored")
169 __slots__ = [
'digital_input_bits',
'digital_output_bits',
170 'analog_input_range0',
'analog_input_range1',
171 'analog_input0',
'analog_input1',
172 'analog_output_domain0',
'analog_output_domain1',
173 'analog_output0',
'analog_output1',
174 'masterboard_temperature',
175 'robot_voltage_48V',
'robot_current',
176 'master_io_current',
'master_safety_state',
177 'master_onoff_state']
182 md.digital_input_bits, md.digital_output_bits,
183 md.analog_input_range0, md.analog_input_range1,
184 md.analog_input0, md.analog_input1,
185 md.analog_output_domain0, md.analog_output_domain1,
186 md.analog_output0, md.analog_output1,
187 md.masterboard_temperature,
188 md.robot_voltage_48V, md.robot_current,
189 md.master_io_current, md.master_safety_state,
190 md.master_onoff_state) = struct.unpack_from(
"!IBhhbbddbbddffffBB", buf)
195 __slots__ = [
'digital_input_bits',
'digital_output_bits',
196 'analog_input_range0',
'analog_input_range1',
197 'analog_input0',
'analog_input1',
198 'analog_output_domain0',
'analog_output_domain1',
199 'analog_output0',
'analog_output1',
200 'masterboard_temperature',
201 'robot_voltage_48V',
'robot_current',
202 'master_io_current',
'safety_mode',
208 md.digital_input_bits, md.digital_output_bits,
209 md.analog_input_range0, md.analog_input_range1,
210 md.analog_input0, md.analog_input1,
211 md.analog_output_domain0, md.analog_output_domain1,
212 md.analog_output0, md.analog_output1,
213 md.masterboard_temperature,
214 md.robot_voltage_48V, md.robot_current,
215 md.master_io_current, md.safety_mode,
216 md.in_reduced_mode) = struct.unpack_from(
"!IBiibbddbbddffffBB", buf)
221 __slots__ = [
'x',
'y',
'z',
'rx',
'ry',
'rz']
226 ci.x, ci.y, ci.z, ci.rx, ci.ry, ci.rz) = struct.unpack_from(
"!IB6d", buf)
238 __slots__ = [
'min_limit',
'max_limit',
'max_speed',
'max_acceleration']
243 __slots__ = [
'joint_limit_data',
244 'v_joint_default',
'a_joint_default',
245 'v_tool_default',
'a_tool_default',
'eq_radius',
246 'dh_a',
'dh_d',
'dh_alpha',
'dh_theta',
247 'masterboard_version',
'controller_box_type',
248 'robot_type',
'robot_subtype']
252 cd.joint_limit_data = []
255 (jld.min_limit, jld.max_limit) = struct.unpack_from(
"!dd", buf, 5+16*i)
256 (jld.max_speed, jld.max_acceleration) = struct.unpack_from(
"!dd", buf, 5+16*6+16*i)
257 cd.joint_limit_data.append(jld)
258 (cd.v_joint_default, cd.a_joint_default, cd.v_tool_default, cd.a_tool_default,
259 cd.eq_radius) = struct.unpack_from(
"!ddddd", buf, 5+32*6)
260 (cd.masterboard_version, cd.controller_box_type, cd.robot_type,
261 cd.robot_subtype) = struct.unpack_from(
"!iiii", buf, 5+32*6+5*8+6*32)
267 __slots__ = [
'x',
'y',
'z',
'rx',
'ry',
'rz',
'robot_dexterity']
271 (_, _, fmd.x, fmd.y, fmd.z, fmd.rx, fmd.ry, fmd.rz,
272 fmd.robot_dexterity) = struct.unpack_from(
"!IBddddddd", buf)
280 (plen, ptype) = struct.unpack_from(
"!IB", buf)
282 return AdditionalInfoOld.unpack(buf)
284 return AdditionalInfoNew.unpack(buf)
286 print(
"AdditionalInfo has wrong length: " + str(plen))
290 __slots__ = [
'ctrl_bits',
'teach_button']
294 (_,_,ai.ctrl_bits, ai.teach_button) = struct.unpack_from(
"!IBIB", buf)
298 __slots__ = [
'teach_button_enabled',
'teach_button_pressed']
302 (_,_,ai.teach_button_enabled, ai.teach_button_pressed) = struct.unpack_from(
"!IBBB", buf)
307 __slots__ = [
'robot_mode_data',
'joint_data',
'tool_data',
308 'masterboard_data',
'cartesian_info',
309 'kinematics_info',
'configuration_data',
310 'force_mode_data',
'additional_info',
318 length, mtype = struct.unpack_from(
"!IB", buf)
319 if length != len(buf):
320 raise Exception(
"Could not unpack packet: length field is incorrect")
323 print(
"Likely a syntax error:")
325 raise Exception(
"Fatal error when unpacking RobotState packet")
329 while offset < len(buf):
330 length, ptype = struct.unpack_from(
"!IB", buf, offset)
331 assert offset + length <= len(buf)
332 package_buf = buffer(buf, offset, length)
335 if ptype == PackageType.ROBOT_MODE_DATA:
336 rs.robot_mode_data = RobotModeData.unpack(package_buf)
337 elif ptype == PackageType.JOINT_DATA:
338 rs.joint_data = JointData.unpack(package_buf)
339 elif ptype == PackageType.TOOL_DATA:
340 rs.tool_data = ToolData.unpack(package_buf)
341 elif ptype == PackageType.MASTERBOARD_DATA:
342 rs.masterboard_data = MasterboardData.unpack(package_buf)
343 elif ptype == PackageType.CARTESIAN_INFO:
344 rs.cartesian_info = CartesianInfo.unpack(package_buf)
345 elif ptype == PackageType.KINEMATICS_INFO:
346 rs.kinematics_info = KinematicsInfo.unpack(package_buf)
347 elif ptype == PackageType.CONFIGURATION_DATA:
348 rs.configuration_data = ConfigurationData.unpack(package_buf)
349 elif ptype == PackageType.FORCE_MODE_DATA:
350 rs.force_mode_data = ForceModeData.unpack(package_buf)
351 elif ptype == PackageType.ADDITIONAL_INFO:
352 rs.additional_info = AdditionalInfo.unpack(package_buf)
353 elif ptype == PackageType.CALIBRATION_DATA:
356 rs.unknown_ptypes.append(ptype)
360 for s
in o.__slots__:
361 child = getattr(o, s,
None)
363 print(
"%s%s: None" % (indent, s))
364 elif hasattr(child,
'__slots__'):
365 print(
"%s%s:" % (indent, s))
366 pstate(child, indent +
' ')
367 elif hasattr(child,
'__iter__'):
368 print(
"%s%s:" % (indent, s))
369 for i, c
in enumerate(child):
370 print(
"%s [%i]:" % (indent, i))
373 print(
"%s%s: %s" % (indent, s, child))