Skip to content

Commit 89fb953

Browse files
Update to new version : 4.4.0.0
1 parent e22b945 commit 89fb953

File tree

681 files changed

+25883
-2898
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

681 files changed

+25883
-2898
lines changed

underautomation/fanuc/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import clr
2+
import os
3+
4+
_dll_path = os.path.realpath(os.path.join(os.path.dirname(__file__), 'lib', 'UnderAutomation.Fanuc.dll'))
5+
clr.AddReference(_dll_path)
6+
7+
__author__ = 'UnderAutomation'
Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
1-
import clr
2-
import os
3-
clr.AddReference(os.path.realpath(os.path.join(os.path.dirname(__file__), "..", 'lib', 'UnderAutomation.Fanuc.dll')))
4-
from UnderAutomation.Fanuc.Common import ArmFrontBack as arm_front_back
1+
from enum import IntEnum
52

6-
class ArmFrontBack(int):
7-
Unknown = int(arm_front_back.Unknown)
8-
Front = int(arm_front_back.Front)
9-
Back = int(arm_front_back.Back)
10-
11-
def __repr__(self):
12-
for name, value in vars(ArmFrontBack).items():
13-
if not name.startswith('_') and isinstance(value, int) and value == self:
14-
return name
15-
return str(int(self))
3+
class ArmFrontBack(IntEnum):
4+
'''Arm configuration'''
5+
Unknown = 0 # Unknown
6+
Front = 1 # Front : T
7+
Back = 2 # Back : B
Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
1-
import clr
2-
import os
3-
clr.AddReference(os.path.realpath(os.path.join(os.path.dirname(__file__), "..", 'lib', 'UnderAutomation.Fanuc.dll')))
4-
from UnderAutomation.Fanuc.Common import ArmLeftRight as arm_left_right
1+
from enum import IntEnum
52

6-
class ArmLeftRight(int):
7-
Unknown = int(arm_left_right.Unknown)
8-
Left = int(arm_left_right.Left)
9-
Right = int(arm_left_right.Right)
10-
11-
def __repr__(self):
12-
for name, value in vars(ArmLeftRight).items():
13-
if not name.startswith('_') and isinstance(value, int) and value == self:
14-
return name
15-
return str(int(self))
3+
class ArmLeftRight(IntEnum):
4+
'''Arm left right'''
5+
Unknown = 0 # Unknown
6+
Left = 1 # Left : L
7+
Right = 2 # Right : R
Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
1-
import clr
2-
import os
3-
clr.AddReference(os.path.realpath(os.path.join(os.path.dirname(__file__), "..", 'lib', 'UnderAutomation.Fanuc.dll')))
4-
from UnderAutomation.Fanuc.Common import ArmUpDown as arm_up_down
1+
from enum import IntEnum
52

6-
class ArmUpDown(int):
7-
Unknown = int(arm_up_down.Unknown)
8-
Up = int(arm_up_down.Up)
9-
Down = int(arm_up_down.Down)
10-
11-
def __repr__(self):
12-
for name, value in vars(ArmUpDown).items():
13-
if not name.startswith('_') and isinstance(value, int) and value == self:
14-
return name
15-
return str(int(self))
3+
class ArmUpDown(IntEnum):
4+
'''Arm configuration'''
5+
Unknown = 0 # Unknown
6+
Up = 1 # Up : U
7+
Down = 2 # Down : D
Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,88 @@
11
import typing
22
from underautomation.fanuc.common.configuration import Configuration
33
from underautomation.fanuc.common.xyz_position import XYZPosition
4-
import clr
5-
import os
6-
clr.AddReference(os.path.realpath(os.path.join(os.path.dirname(__file__), "..", 'lib', 'UnderAutomation.Fanuc.dll')))
74
from UnderAutomation.Fanuc.Common import CartesianPosition as cartesian_position
85

96
class CartesianPosition(XYZPosition):
7+
'''Fanuc cartesian position and rotations'''
108
def __init__(self, x: float, y: float, z: float, w: float, p: float, r: float, configuration: Configuration, _internal = 0):
9+
'''Constructor with position, rotations and configuration'''
1110
if(_internal == 0):
1211
self._instance = cartesian_position(x, y, z, w, p, r, configuration)
1312
else:
1413
self._instance = _internal
15-
def __repr__(self):
16-
return self._instance.ToString() if self._instance is not None else ""
14+
15+
def equals(self, obj: typing.Any) -> bool:
16+
return self._instance.Equals(obj)
17+
18+
def get_hash_code(self) -> int:
19+
return self._instance.GetHashCode()
20+
1721
def to_homogeneous_matrix(self) -> typing.List[float]:
22+
'''Convert position to a homogeneous rotation and translation 4x4 matrix'''
1823
return self._instance.ToHomogeneousMatrix()
24+
1925
@staticmethod
2026
def from_homogeneous_matrix(R: typing.List[float]) -> 'CartesianPosition':
2127
return CartesianPosition(None, None, None, None, None, None, None, cartesian_position.FromHomogeneousMatrix(R))
28+
2229
@staticmethod
2330
def normalize_angle(angle: float) -> float:
31+
'''Normalize an angle to the range ]-180, 180]'''
2432
return cartesian_position.NormalizeAngle(angle)
33+
2534
@staticmethod
2635
def normalize_angles(pose: 'CartesianPosition') -> None:
36+
'''Normalize the W, P, R angles to the range ]-180, 180]'''
2737
cartesian_position.NormalizeAngles(pose._instance if pose else None)
38+
2839
@staticmethod
2940
def is_near(a: 'CartesianPosition', b: 'CartesianPosition', mmTolerance: float, degreesTolerance: float) -> bool:
41+
'''Check if two Cartesian positions are near each other within specified tolerances'''
3042
return cartesian_position.IsNear(a._instance if a else None, b._instance if b else None, mmTolerance, degreesTolerance)
43+
3144
@property
3245
def w(self) -> float:
46+
'''W rotation in degrees (Rx)'''
3347
return self._instance.W
48+
3449
@w.setter
3550
def w(self, value: float):
3651
self._instance.W = value
52+
3753
@property
3854
def p(self) -> float:
55+
'''P rotation in degrees (Ry)'''
3956
return self._instance.P
57+
4058
@p.setter
4159
def p(self, value: float):
4260
self._instance.P = value
61+
4362
@property
4463
def r(self) -> float:
64+
'''R rotation in degrees (Rz)'''
4565
return self._instance.R
66+
4667
@r.setter
4768
def r(self, value: float):
4869
self._instance.R = value
70+
4971
@property
5072
def configuration(self) -> Configuration:
73+
'''Position configuration'''
5174
return Configuration(None, None, None, None, None, None, None, self._instance.Configuration)
75+
76+
def __str__(self):
77+
return self._instance.ToString() if self._instance is not None else ""
78+
79+
def __repr__(self):
80+
return self.__str__()
81+
82+
def __eq__(self, other) -> bool:
83+
if not isinstance(other, CartesianPosition):
84+
NotImplemented
85+
return self._instance.Equals(other._instance)
86+
87+
def __hash__(self) -> int:
88+
return self._instance.GetHashCode() if self._instance is not None else 0
Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,41 @@
11
import typing
22
from underautomation.fanuc.common.cartesian_position import CartesianPosition
3-
import clr
4-
import os
5-
clr.AddReference(os.path.realpath(os.path.join(os.path.dirname(__file__), "..", 'lib', 'UnderAutomation.Fanuc.dll')))
63
from UnderAutomation.Fanuc.Common import CartesianPositionWithTool as cartesian_position_with_tool
74

85
class CartesianPositionWithTool(CartesianPosition):
6+
'''A cartesian position with a tool ID'''
97
def __init__(self, x: float, y: float, z: float, w: float, p: float, r: float, tool: int, _internal = 0):
8+
'''Constructor with position, rotations and tool ID'''
109
if(_internal == 0):
1110
self._instance = cartesian_position_with_tool(x, y, z, w, p, r, tool)
1211
else:
1312
self._instance = _internal
14-
def __repr__(self):
15-
return self._instance.ToString() if self._instance is not None else ""
13+
14+
def equals(self, obj: typing.Any) -> bool:
15+
return self._instance.Equals(obj)
16+
17+
def get_hash_code(self) -> int:
18+
return self._instance.GetHashCode()
19+
1620
@property
1721
def tool(self) -> int:
22+
'''Tool ID'''
1823
return self._instance.Tool
24+
1925
@tool.setter
2026
def tool(self, value: int):
2127
self._instance.Tool = value
28+
29+
def __str__(self):
30+
return self._instance.ToString() if self._instance is not None else ""
31+
32+
def __repr__(self):
33+
return self.__str__()
34+
35+
def __eq__(self, other) -> bool:
36+
if not isinstance(other, CartesianPositionWithTool):
37+
NotImplemented
38+
return self._instance.Equals(other._instance)
39+
40+
def __hash__(self) -> int:
41+
return self._instance.GetHashCode() if self._instance is not None else 0
Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,37 @@
11
import typing
22
from underautomation.fanuc.common.cartesian_position_with_tool import CartesianPositionWithTool
3-
import clr
4-
import os
5-
clr.AddReference(os.path.realpath(os.path.join(os.path.dirname(__file__), "..", 'lib', 'UnderAutomation.Fanuc.dll')))
63
from UnderAutomation.Fanuc.Common import CartesianPositionWithUserFrame as cartesian_position_with_user_frame
74

85
class CartesianPositionWithUserFrame(CartesianPositionWithTool):
6+
'''A cartesian tool position with a user frame ID'''
97
def __init__(self, x: float, y: float, z: float, w: float, p: float, r: float, tool: int, frame: int, _internal = 0):
8+
'''Constructor with position, rotations, tool and frame IDs'''
109
if(_internal == 0):
1110
self._instance = cartesian_position_with_user_frame(x, y, z, w, p, r, tool, frame)
1211
else:
1312
self._instance = _internal
14-
def __repr__(self):
15-
return self._instance.ToString() if self._instance is not None else ""
13+
14+
def equals(self, obj: typing.Any) -> bool:
15+
return self._instance.Equals(obj)
16+
17+
def get_hash_code(self) -> int:
18+
return self._instance.GetHashCode()
19+
1620
@property
1721
def frame(self) -> int:
22+
'''Frame ID in the controller'''
1823
return self._instance.Frame
24+
25+
def __str__(self):
26+
return self._instance.ToString() if self._instance is not None else ""
27+
28+
def __repr__(self):
29+
return self.__str__()
30+
31+
def __eq__(self, other) -> bool:
32+
if not isinstance(other, CartesianPositionWithUserFrame):
33+
NotImplemented
34+
return self._instance.Equals(other._instance)
35+
36+
def __hash__(self) -> int:
37+
return self._instance.GetHashCode() if self._instance is not None else 0

underautomation/fanuc/common/configuration.py

Lines changed: 51 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,67 +3,109 @@
33
from underautomation.fanuc.common.arm_up_down import ArmUpDown
44
from underautomation.fanuc.common.arm_left_right import ArmLeftRight
55
from underautomation.fanuc.common.arm_front_back import ArmFrontBack
6-
import clr
7-
import os
8-
clr.AddReference(os.path.realpath(os.path.join(os.path.dirname(__file__), "..", 'lib', 'UnderAutomation.Fanuc.dll')))
96
from UnderAutomation.Fanuc.Common import Configuration as configuration
107
from UnderAutomation.Fanuc.Common import WristFlip as wrist_flip
118
from UnderAutomation.Fanuc.Common import ArmUpDown as arm_up_down
129
from UnderAutomation.Fanuc.Common import ArmLeftRight as arm_left_right
1310
from UnderAutomation.Fanuc.Common import ArmFrontBack as arm_front_back
1411

1512
class Configuration:
13+
'''Fanuc arm configuration'''
1614
def __init__(self, wristFlip: WristFlip, armUpDown: ArmUpDown, armLeftRight: ArmLeftRight, armFrontBack: ArmFrontBack, turnAxis1: int, turnAxis2: int, turnAxis3: int, _internal = 0):
15+
'''Constructor with all configuration parameters'''
1716
if(_internal == 0):
1817
self._instance = configuration(wristFlip, armUpDown, armLeftRight, armFrontBack, turnAxis1, turnAxis2, turnAxis3)
1918
else:
2019
self._instance = _internal
21-
def __repr__(self):
22-
return self._instance.ToString() if self._instance is not None else ""
20+
2321
def from_string(self, value: str) -> None:
22+
'''Parse a Fanuc configuration string representation, like : "N U T, 0, 0, 0" or "R, 0, 0, 0"'''
2423
self._instance.FromString(value)
24+
25+
def equals(self, obj: typing.Any) -> bool:
26+
return self._instance.Equals(obj)
27+
28+
def get_hash_code(self) -> int:
29+
return self._instance.GetHashCode()
30+
2531
@property
2632
def is_unknown(self) -> bool:
33+
'''Indicates if the configuration is unknown'''
2734
return self._instance.IsUnknown
35+
2836
@property
2937
def wrist_flip(self) -> WristFlip:
30-
return WristFlip(self._instance.WristFlip)
38+
'''Wrist configuration'''
39+
return WristFlip(int(self._instance.WristFlip))
40+
3141
@wrist_flip.setter
3242
def wrist_flip(self, value: WristFlip):
3343
self._instance.WristFlip = wrist_flip(int(value))
44+
3445
@property
3546
def arm_up_down(self) -> ArmUpDown:
36-
return ArmUpDown(self._instance.ArmUpDown)
47+
'''Arm up/down configuration'''
48+
return ArmUpDown(int(self._instance.ArmUpDown))
49+
3750
@arm_up_down.setter
3851
def arm_up_down(self, value: ArmUpDown):
3952
self._instance.ArmUpDown = arm_up_down(int(value))
53+
4054
@property
4155
def arm_left_right(self) -> ArmLeftRight:
42-
return ArmLeftRight(self._instance.ArmLeftRight)
56+
'''Arm left/right configuration'''
57+
return ArmLeftRight(int(self._instance.ArmLeftRight))
58+
4359
@arm_left_right.setter
4460
def arm_left_right(self, value: ArmLeftRight):
4561
self._instance.ArmLeftRight = arm_left_right(int(value))
62+
4663
@property
4764
def arm_front_back(self) -> ArmFrontBack:
48-
return ArmFrontBack(self._instance.ArmFrontBack)
65+
'''Arm back/front configuration'''
66+
return ArmFrontBack(int(self._instance.ArmFrontBack))
67+
4968
@arm_front_back.setter
5069
def arm_front_back(self, value: ArmFrontBack):
5170
self._instance.ArmFrontBack = arm_front_back(int(value))
71+
5272
@property
5373
def turn_axis4(self) -> int:
74+
'''Turn number of axis J4 (1:180° to 539°, 0:-179° to 179°, -1:-539° to -180°)'''
5475
return self._instance.TurnAxis4
76+
5577
@turn_axis4.setter
5678
def turn_axis4(self, value: int):
5779
self._instance.TurnAxis4 = value
80+
5881
@property
5982
def turn_axis5(self) -> int:
83+
'''Turn number of axis J5 (1:180° to 539°, 0:-179° to 179°, -1:-539° to -180°)'''
6084
return self._instance.TurnAxis5
85+
6186
@turn_axis5.setter
6287
def turn_axis5(self, value: int):
6388
self._instance.TurnAxis5 = value
89+
6490
@property
6591
def turn_axis6(self) -> int:
92+
'''Turn number of axis J6 (1:180° to 539°, 0:-179° to 179°, -1:-539° to -180°)'''
6693
return self._instance.TurnAxis6
94+
6795
@turn_axis6.setter
6896
def turn_axis6(self, value: int):
6997
self._instance.TurnAxis6 = value
98+
99+
def __str__(self):
100+
return self._instance.ToString() if self._instance is not None else ""
101+
102+
def __repr__(self):
103+
return self.__str__()
104+
105+
def __eq__(self, other) -> bool:
106+
if not isinstance(other, Configuration):
107+
NotImplemented
108+
return self._instance.Equals(other._instance)
109+
110+
def __hash__(self) -> int:
111+
return self._instance.GetHashCode() if self._instance is not None else 0

0 commit comments

Comments
 (0)