Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
yck011522 committed Oct 31, 2024
1 parent 5486b14 commit 86b15a2
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from compas import IPY
from compas.utilities import await_callback
from compas_robots.model import LinkGeometry

from compas_fab.backends.interfaces import SetRobotCell
from compas_fab.backends.ros.messages import ApplyPlanningSceneRequest
Expand Down
2 changes: 1 addition & 1 deletion src/compas_fab/ghpython/scene/gh_scene_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
if not IPY:
from typing import TYPE_CHECKING

if TYPE_CHECKING:
if TYPE_CHECKING: # pragma: no cover
from typing import Optional # noqa: F401
from typing import List # noqa: F401

Expand Down
4 changes: 1 addition & 3 deletions src/compas_fab/ghpython/scene/rigid_body_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
from __future__ import print_function


from compas_ghpython.drawing import draw_mesh
from .gh_scene_object import GHSceneObject
from compas_rhino.conversions import transformation_to_rhino


from compas_fab.scene import BaseRigidBodyObject
Expand All @@ -14,7 +12,7 @@
if not IPY:
from typing import TYPE_CHECKING

if TYPE_CHECKING:
if TYPE_CHECKING: # pragma: no cover
from typing import Optional # noqa: F401
from typing import List # noqa: F401

Expand Down
11 changes: 6 additions & 5 deletions src/compas_fab/robots/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def __eq__(self, value):
try:
if not self.robot_configuration.close_to(value.robot_configuration):
return False
except:
except Exception:
return False
else:
if self.robot_configuration != value.robot_configuration:
Expand Down Expand Up @@ -396,7 +396,8 @@ def __eq__(self, value):
# type: (ToolState) -> bool
if value is None:
return False
# Wrap the tests in try block, if any of the attributes cannot be compared,
# In order to allow duck typing we do not assert value.__class__ to be equal to self.__class__
# Therefore, we wrap the tests in try block, if any of the attributes cannot be compared,
# it will raise exception and return False
try:
if self.frame != value.frame:
Expand All @@ -411,14 +412,14 @@ def __eq__(self, value):
try:
if not self.configuration.close_to(value.configuration):
return False
except:
except Exception:
return False
else:
if self.configuration != value.configuration:
return False
if self.is_hidden != value.is_hidden:
return False
except:
except Exception:
return False
return True

Expand Down Expand Up @@ -569,6 +570,6 @@ def __eq__(self, value):
return False
if self.is_hidden != value.is_hidden:
return False
except:
except Exception:
return False
return True
2 changes: 1 addition & 1 deletion src/compas_fab/scene/base_rigid_body_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
if not IPY:
from typing import TYPE_CHECKING

if TYPE_CHECKING:
if TYPE_CHECKING: # pragma: no cover
from typing import Optional # noqa: F401
from typing import List # noqa: F401
from compas_fab.robots import RigidBody # noqa: F401
Expand Down
13 changes: 5 additions & 8 deletions src/compas_fab/scene/base_robot_cell_object.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
from compas import IPY
from compas.scene import SceneObject
from compas_fab.robots import RobotCellState


if not IPY:
from typing import TYPE_CHECKING

if TYPE_CHECKING:
if TYPE_CHECKING: # pragma: no cover
from typing import List # noqa: F401
from typing import Optional # noqa: F401

from .base_robot_model_object import BaseRobotModelObject # noqa: F401

# from compas_fab.scene import BaseToolObject
from compas_fab.robots import RigidBody # noqa: F401
from compas_fab.robots import RigidBodyState # noqa: F401
from compas_fab.robots import RobotCell # noqa: F401

from compas_fab.robots import RobotCellState # noqa: F401
from compas_fab.scene import BaseRigidBodyObject # noqa: F401

from .base_robot_model_object import BaseRobotModelObject # noqa: F401


class BaseRobotCellObject(SceneObject):
"""Base class for all robot cell objects.
Expand Down
12 changes: 5 additions & 7 deletions src/compas_fab/scene/base_robot_model_object.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
from compas import IPY
from compas.datastructures import Mesh
from compas.geometry import Frame

from compas.geometry import Transformation
from compas.geometry import Scale
from compas.scene import SceneObject
from compas_robots.model import MeshDescriptor

if not IPY:
from typing import TYPE_CHECKING

if TYPE_CHECKING:
if TYPE_CHECKING: # pragma: no cover
from typing import List # noqa: F401
from typing import Optional # noqa: F401

from compas_robots import Configuration # noqa: F401
from compas_robots import RobotModel # noqa: F401
from compas_robots.model import Collision # noqa: F401
from compas_robots.model import Link # noqa: F401
from compas_robots.model import Visual # noqa: F401

from compas.datastructures import Mesh # noqa: F401
from compas.geometry import Frame # noqa: F401


class BaseRobotModelObject(SceneObject):
Expand Down
4 changes: 2 additions & 2 deletions tests/robots/test_robot_cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from typing import TYPE_CHECKING

if TYPE_CHECKING: # pragma: no cover
from typing import Tuple
from typing import Tuple # noqa: F401


@pytest.fixture
Expand Down Expand Up @@ -161,7 +161,7 @@ def test_get_link_names(panda, rfl, ur10e_gripper_one_beam, abb_irb4600_40_255_g
def _test(rc, rcs):
# type: (RobotCell, RobotCellState) -> None

all_link_names = [l.name for l in rc.robot_model.links]
all_link_names = [link.name for link in rc.robot_model.links]
for group in rc.group_names:
group_link_names = rc.get_link_names(group)
assert all(link_name in all_link_names for link_name in group_link_names)
Expand Down
2 changes: 1 addition & 1 deletion tests/robots/test_semantics.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def test_panda_srdf_file(panda_srdf, panda_urdf):
def test_ur5_semantics():
robot_cell, robot_cell_state = RobotCellLibrary.ur5(load_geometry=False)
semantics = robot_cell.robot_semantics
assert sorted(semantics.group_names) == sorted(["manipulator", "endeffector"])
assert semantics.group_names == ["manipulator"]
assert semantics.main_group_name == "manipulator"
assert semantics.get_base_link_name() == "base_link"
assert semantics.get_end_effector_link_name() == "tool0"
Expand Down
19 changes: 4 additions & 15 deletions tests/robots/test_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,22 @@

import pytest
from compas import IPY
from compas.data import Data
from compas.geometry import Frame
from compas.geometry import Transformation

if not IPY:
from typing import TYPE_CHECKING

if TYPE_CHECKING: # pragma: no cover
from typing import Dict # noqa: F401
from typing import List # noqa: F401
from typing import Tuple # noqa: F401

from compas_robots import Configuration # noqa: F401

from compas_fab.robots import RobotCell # noqa: F401
from compas_fab.robots import RobotCellState # noqa: F401

from compas_fab.robots import RigidBodyState
from compas_fab.robots import RobotCellLibrary
from compas_fab.robots import RobotCellState
from compas_fab.robots import ToolState
from compas_robots import Configuration

# In this file context
# - rbs stands for RigidBodyState
Expand Down Expand Up @@ -314,12 +309,6 @@ def test_rcs_eq(rcs_ur10e_gripper_one_beam):
assert a is not b
assert a == b

b = deepcopy(a)
b.robot_flange_frame = Frame([3, 2, 1], [0.1, 0.2, 0.3])
assert a != b
b.robot_flange_frame = None
assert a != b

b = deepcopy(a)
b.robot_configuration.joint_values[0] = 999
assert a != b
Expand Down Expand Up @@ -403,13 +392,13 @@ def test_rcs_set_attach_functions(rc_rcs_ur10e_gripper_one_beam, ts_stationary):

assert rcs.get_attached_tool_id(group) == gripper_id
assert rcs.tool_states[gripper_id].attached_to_group == group
assert rcs.tool_states[gripper_id].frame == None
assert rcs.tool_states[gripper_id].frame is None
assert rcs.tool_states[gripper_id].attachment_frame == Frame.worldXY()
assert rcs.tool_states[gripper_id].touch_links == []

# Detach tool manually
rcs.tool_states[gripper_id].attached_to_group = None
assert rcs.get_attached_tool_id(group) == None
assert rcs.get_attached_tool_id(group) is None
assert rcs.get_detached_tool_ids() == [gripper_id]
# Attach tool to group using function
attachment_frame = Frame([1, 2, 3], [0.1, 0.2, 0.3])
Expand All @@ -435,7 +424,7 @@ def test_rcs_set_attach_functions(rc_rcs_ur10e_gripper_one_beam, ts_stationary):
# Detach the print tool
rcs.set_tool_detached(print_tool_id)
rcs.set_tool_detached(gripper_id, frame=Frame.worldXY(), touch_links=["link0"])
assert rcs.get_attached_tool_id(group) == None
assert rcs.get_attached_tool_id(group) is None
assert rcs.get_attached_workpiece_ids(group) == []

# Attach workpiece to tool
Expand Down

0 comments on commit 86b15a2

Please sign in to comment.