From 52e13ec768eb1df4c33357dbfeef82f7018f6fdc Mon Sep 17 00:00:00 2001 From: beverly Date: Tue, 16 Feb 2021 10:12:32 +0100 Subject: [PATCH 1/2] mimic joints are not configurable --- CHANGELOG.md | 2 ++ src/compas/robots/model/joint.py | 2 +- tests/compas/robots/test_model.py | 15 +++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 482b0d86cbef..053d5454dfed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +* Fixed bug where mimic joints were considered configurable. + ### Removed diff --git a/src/compas/robots/model/joint.py b/src/compas/robots/model/joint.py index 5e382c71e5c5..9c88599750ea 100644 --- a/src/compas/robots/model/joint.py +++ b/src/compas/robots/model/joint.py @@ -835,7 +835,7 @@ def calculate_transformation(self, position): def is_configurable(self): """Returns ``True`` if the joint can be configured, otherwise ``False``.""" - return self.type != Joint.FIXED + return self.type != Joint.FIXED and self.mimic is None def is_scalable(self): """Returns ``True`` if the joint can be scaled, otherwise ``False``.""" diff --git a/tests/compas/robots/test_model.py b/tests/compas/robots/test_model.py index 7cf4299c81ea..c8c638098396 100644 --- a/tests/compas/robots/test_model.py +++ b/tests/compas/robots/test_model.py @@ -604,6 +604,21 @@ def test_unknown_axis_attribute_data(urdf_with_unknown_attr): assert r.joints[0].axis.attr['rpy'] == '0 0 0' +def test_get_configurable_joints(urdf_file): + model = RobotModel.from_urdf_file(urdf_file) + expected_joints = [ + 'panda_joint1', + 'panda_joint2', + 'panda_joint3', + 'panda_joint4', + 'panda_joint5', + 'panda_joint6', + 'panda_joint7', + 'panda_finger_joint1', + ] + assert model.get_configurable_joint_names() == expected_joints + + def test_ensure_geometry(urdf_file, urdf_file_with_shapes_only): robot = RobotModel.from_urdf_file(urdf_file) with pytest.raises(Exception): From 8774b3f559d34a2ed20b94cd2921695b8b8a97b8 Mon Sep 17 00:00:00 2001 From: beverly Date: Tue, 16 Feb 2021 10:18:25 +0100 Subject: [PATCH 2/2] better test --- tests/compas/robots/test_model.py | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/tests/compas/robots/test_model.py b/tests/compas/robots/test_model.py index c8c638098396..f52707de0242 100644 --- a/tests/compas/robots/test_model.py +++ b/tests/compas/robots/test_model.py @@ -604,19 +604,9 @@ def test_unknown_axis_attribute_data(urdf_with_unknown_attr): assert r.joints[0].axis.attr['rpy'] == '0 0 0' -def test_get_configurable_joints(urdf_file): +def test_get_configurable_joint_names(urdf_file): model = RobotModel.from_urdf_file(urdf_file) - expected_joints = [ - 'panda_joint1', - 'panda_joint2', - 'panda_joint3', - 'panda_joint4', - 'panda_joint5', - 'panda_joint6', - 'panda_joint7', - 'panda_finger_joint1', - ] - assert model.get_configurable_joint_names() == expected_joints + assert 'panda_finger_joint2' not in model.get_configurable_joint_names() def test_ensure_geometry(urdf_file, urdf_file_with_shapes_only):