Skip to content

Commit b7b482a

Browse files
authored
Merge pull request #82 from compas-dev/bump-to-compas-0.10.0
Bump dependency to compas 0.10.0
2 parents 5fd9124 + 46d4212 commit b7b482a

File tree

9 files changed

+35
-22
lines changed

9 files changed

+35
-22
lines changed

CHANGELOG.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ Unreleased
1616

1717
**Changed**
1818

19+
* Updated to COMPAS 0.10
20+
1921
**Removed**
2022

2123
**Fixed**

docs/examples/01_fundamentals/01_frame_and_transformation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ coordinate system.
3333
# point in F (local coordinates)
3434
P = Point(35., 35., 35.)
3535
# point in global (world) coordinates
36-
P_ = F.represent_point_in_global_coordinates(P)
36+
P_ = F.to_world_coords(P)
3737
3838
3939
Industrial robots do not have a common way of describing the pose orientation.

docs/examples/01_fundamentals/02_coordinate_frames.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ before sending it as a target pose to the robot.
112112
frame_WCF = Frame(point, xaxis, yaxis)
113113
print("frame in WCF", frame_WCF)
114114
115-
frame_RCF = robot.represent_frame_in_RCF(frame_WCF)
115+
frame_RCF = robot.to_local_coords(frame_WCF)
116116
print("frame in RCF", frame_RCF)
117117
118-
frame_WCF = robot.represent_frame_in_WCF(frame_RCF)
118+
frame_WCF = robot.to_world_coords(frame_RCF)
119119
print("frame in WCF", frame_WCF)
120120
121121
Links

docs/examples/03_backends_ros/files/02_forward_kinematics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
configuration = Configuration.from_revolute_values([-2.238, -1.153, -2.174, 0.185, 0.667, 0.])
66

77
frame_RCF = robot.forward_kinematics(configuration)
8-
frame_WCF = robot.represent_frame_in_WCF(frame_RCF)
8+
frame_WCF = robot.to_world_coords(frame_RCF)
99

1010
print("Frame in the robot's coordinate system")
1111
print(frame_RCF)

docs/examples/03_backends_ros/files/02_forward_kinematics_ros.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
configuration = Configuration.from_revolute_values([-2.238, -1.153, -2.174, 0.185, 0.667, 0.])
88

99
frame_RCF = robot.forward_kinematics(configuration)
10-
frame_WCF = robot.represent_frame_in_WCF(frame_RCF)
10+
frame_WCF = robot.to_world_coords(frame_RCF)
1111

1212
print("Frame in the robot's coordinate system")
1313
print(frame_RCF)

docs/examples/03_backends_ros/files/robot.ghx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,7 +1298,7 @@ if robot and configuration:
12981298
frames = draw_pipes(pipes, cap=1)
12991299

13001300
ee_frame_RCF = robot.forward_kinematics(configuration, backend='model')
1301-
ee_frame = robot.represent_frame_in_WCF(ee_frame_RCF)
1301+
ee_frame = robot.to_world_coords(ee_frame_RCF)
13021302
ee_plane = draw_frame(ee_frame)
13031303

13041304
print("End-effector frame:")
@@ -5236,7 +5236,7 @@ if robot:
52365236

52375237
if sc.sticky[response_key]:
52385238
frame_RCF = sc.sticky[response_key]
5239-
frame_WCF = robot.represent_frame_in_WCF(frame_RCF, group)
5239+
frame_WCF = robot.to_world_coords(frame_RCF, group)
52405240

52415241
print frame_WCF</item>
52425242
<item name="Description" type_name="gh_string" type_code="10">GhPython provides a Python script component</item>
@@ -14730,4 +14730,4 @@ print joint_positions</item>
1473014730
</items>
1473114731
</chunk>
1473214732
</chunks>
14733-
</Archive>
14733+
</Archive>

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
requirements = [
1313
# Until COMPAS reaches 1.0, we pin major.minor and allow patch version updates
14-
'compas>=0.8.1,<0.9',
14+
'compas>=0.10,<0.11',
1515
'roslibpy>=0.7',
1616
'pyserial',
1717
]

src/compas_fab/robots/constraints.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,14 @@ def __init__(self, link_name, quaternion, tolerances=None, weight=1.):
226226
def transform(self, transformation):
227227
R = Rotation.from_quaternion(self.quaternion)
228228
R = transformation * R
229-
self.quaternion = R.rotation.quaternion
229+
230+
# Due to a bug on COMPAS 0.10.0
231+
# (Fixed on https://github.com/compas-dev/compas/pull/378 but not released atm)
232+
# we work around the retrival of the rotation component of R and instead decompose and get it
233+
_, _, r, _, _ = R.decomposed()
234+
self.quaternion = r.quaternion
235+
# After that bug fix is released, the previous two lines should be changed to:
236+
# self.quaternion = R.rotation.quaternion
230237

231238
def __repr__(self):
232239
return "OrientationConstraint('{0}', {1}, {2}, {3})".format(self.link_name, self.quaternion, self.tolerances, self.weight)

src/compas_fab/robots/robot.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ def _get_current_base_frame(self, full_configuration, group):
287287
base_frame_WCF = Frame.worldXY()
288288
else:
289289
base_frame_WCF = self.model.forward_kinematics(joint_state, link_name=base_link.name)
290-
base_frame_RCF = self.represent_frame_in_RCF(base_frame_WCF, group)
290+
base_frame_RCF = self.to_local_coords(base_frame_WCF, group)
291291

292292
base_frame_RCF.point *= self.scale_factor
293293
T = Transformation.from_frame(base_frame)
@@ -561,7 +561,7 @@ def transformation_RCF_WCF(self, group=None):
561561
562562
"""
563563
base_frame = self.get_base_frame(group)
564-
return Transformation.from_frame_to_frame(Frame.worldXY(), base_frame)
564+
return Transformation.change_basis(base_frame, Frame.worldXY())
565565

566566
def _get_current_transformation_WCF_RCF(self, full_configuration, group):
567567
"""Returns the group's current WCF to RCF transformation, if the robot is in full_configuration.
@@ -602,7 +602,7 @@ def transformation_WCF_RCF(self, group=None):
602602
603603
"""
604604
base_frame = self.get_base_frame(group)
605-
return Transformation.from_frame_to_frame(base_frame, Frame.worldXY())
605+
return Transformation.change_basis(Frame.worldXY(), base_frame)
606606

607607
def set_RCF(self, robot_coordinate_frame, group=None):
608608
"""Moves the origin frame of the robot to the robot_coordinate_frame.
@@ -615,7 +615,7 @@ def get_RCF(self, group=None):
615615
"""
616616
return self.get_base_frame(group)
617617

618-
def represent_frame_in_RCF(self, frame_WCF, group=None):
618+
def to_local_coords(self, frame_WCF, group=None):
619619
"""Represents a frame from the world coordinate system (WCF) in the robot's coordinate system (RCF).
620620
621621
Parameters
@@ -631,12 +631,14 @@ def represent_frame_in_RCF(self, frame_WCF, group=None):
631631
Examples
632632
--------
633633
>>> frame_WCF = Frame([-0.363, 0.003, -0.147], [0.388, -0.351, -0.852], [0.276, 0.926, -0.256])
634-
>>> frame_RCF = robot.represent_frame_in_RCF(frame_WCF)
634+
>>> frame_RCF = robot.to_local_coords(frame_WCF)
635+
>>> frame_RCF
636+
Frame(Point(-0.363, 0.003, -0.147), Vector(0.388, -0.351, -0.852), Vector(0.276, 0.926, -0.256))
635637
"""
636638
frame_RCF = frame_WCF.transformed(self.transformation_WCF_RCF(group))
637639
return frame_RCF
638640

639-
def represent_frame_in_WCF(self, frame_RCF, group=None):
641+
def to_world_coords(self, frame_RCF, group=None):
640642
"""Represents a frame from the robot's coordinate system (RCF) in the world coordinate system (WCF).
641643
642644
Parameters
@@ -652,7 +654,9 @@ def represent_frame_in_WCF(self, frame_RCF, group=None):
652654
Examples
653655
--------
654656
>>> frame_RCF = Frame([-0.363, 0.003, -0.147], [0.388, -0.351, -0.852], [0.276, 0.926, -0.256])
655-
>>> frame_WCF = robot.represent_frame_in_WCF(frame_RCF)
657+
>>> frame_WCF = robot.to_world_coords(frame_RCF)
658+
>>> frame_WCF
659+
Frame(Point(-0.363, 0.003, -0.147), Vector(0.388, -0.351, -0.852), Vector(0.276, 0.926, -0.256))
656660
"""
657661
frame_WCF = frame_RCF.transformed(self.transformation_RCF_WCF(group))
658662
return frame_WCF
@@ -899,7 +903,7 @@ def inverse_kinematics(self, frame_WCF, start_configuration=None,
899903
start_configuration)
900904

901905
# represent in RCF
902-
frame_RCF = self.represent_frame_in_RCF(frame_WCF, group)
906+
frame_RCF = self.to_local_coords(frame_WCF, group)
903907
frame_RCF.point /= self.scale_factor # must be in meters
904908

905909
joint_positions = self.client.inverse_kinematics(frame_RCF, base_link,
@@ -943,7 +947,7 @@ def forward_kinematics(self, configuration, group=None, backend=None, link_name=
943947
>>> frame_RCF_m = robot.forward_kinematics(configuration, group, backend='model')
944948
>>> frame_RCF_c == frame_RCF_m
945949
True
946-
>>> frame_WCF = robot.represent_frame_in_WCF(frame_RCF_m, group)
950+
>>> frame_WCF = robot.to_world_coords(frame_RCF_m, group)
947951
>>> frame_WCF
948952
Frame(Point(0.300, 0.100, 0.500), Vector(1.000, -0.000, -0.000), Vector(0.000, 1.000, -0.000))
949953
@@ -973,10 +977,10 @@ def forward_kinematics(self, configuration, group=None, backend=None, link_name=
973977
frame_RCF.point *= self.scale_factor
974978
else:
975979
frame_WCF = self.model.forward_kinematics(group_joint_state, link_name)
976-
frame_RCF = self.represent_frame_in_RCF(frame_WCF, group)
980+
frame_RCF = self.to_local_coords(frame_WCF, group)
977981
elif backend == 'model':
978982
frame_WCF = self.model.forward_kinematics(group_joint_state, link_name)
979-
frame_RCF = self.represent_frame_in_RCF(frame_WCF, group)
983+
frame_RCF = self.to_local_coords(frame_WCF, group)
980984
else:
981985
# pass to backend, kdl, ikfast,...
982986
raise NotImplementedError
@@ -1068,7 +1072,7 @@ def plan_cartesian_motion(self, frames_WCF, start_configuration=None,
10681072
frames_RCF = []
10691073
for frame_WCF in frames_WCF:
10701074
# represent in RCF
1071-
frame_RCF = self.represent_frame_in_RCF(frame_WCF, group)
1075+
frame_RCF = self.to_local_coords(frame_WCF, group)
10721076
frame_RCF.point /= self.scale_factor
10731077
frames_RCF.append(frame_RCF)
10741078
base_link = self.get_base_link_name(group)

0 commit comments

Comments
 (0)