Skip to content

Commit

Permalink
Rename ManuallyMoveWorkpiece to ManualWorkpieceMotion
Browse files Browse the repository at this point in the history
  • Loading branch information
yck011522 committed Dec 7, 2023
1 parent 97bbbb4 commit 11dfe5c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

* Added `compas_fab.planning` that contains `Action` classes and `SceneState`
* Added `RoboticAction`, `LinearMotion`, `FreeMotion`, `OpenGripper`, `CloseGripper`, and `ManuallyMoveWorkpiece` actions.
* Added `RoboticAction`, `LinearMotion`, `FreeMotion`, `OpenGripper`, `CloseGripper`, and `ManualWorkpieceMotion` actions.
* Added `SceneState` as container for `WorkpieceState`, `ToolState` and `RobotState`.

### Changed
Expand Down
4 changes: 2 additions & 2 deletions src/compas_fab/planning/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
FreeMotion,
OpenGripper,
CloseGripper,
ManuallyMoveWorkpiece,
ManualWorkpieceMotion,
HideWorkpieces,
ShowWorkpieces,
)
Expand All @@ -95,7 +95,7 @@
"FreeMotion",
"OpenGripper",
"CloseGripper",
"ManuallyMoveWorkpiece",
"ManualWorkpieceMotion",
"HideWorkpieces",
"ShowWorkpieces",
"SceneState",
Expand Down
10 changes: 5 additions & 5 deletions src/compas_fab/planning/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"FreeMotion",
"OpenGripper",
"CloseGripper",
"ManuallyMoveWorkpiece",
"ManualWorkpieceMotion",
"HideWorkpieces",
"ShowWorkpieces",
]
Expand Down Expand Up @@ -531,7 +531,7 @@ def apply_effects(self, scene_state, debug=False):
print("- Workpiece %s attached to tool." % self.attaching_workpiece_id)


class ManuallyMoveWorkpiece(Action):
class ManualWorkpieceMotion(Action):
"""Operator action to move a workpiece from one place to another.
This moves the workpiece to a specific frame.
Typically used for loading a workpiece into a gripper.
Expand All @@ -547,20 +547,20 @@ class ManuallyMoveWorkpiece(Action):
"""

def __init__(self, workpiece_id=None, frame=Frame.worldXY()):
super(ManuallyMoveWorkpiece, self).__init__()
super(ManualWorkpieceMotion, self).__init__()
self.workpiece_id = workpiece_id # type: str
self.frame = frame # type: Frame

@property
def data(self):
data = super(ManuallyMoveWorkpiece, self).data
data = super(ManualWorkpieceMotion, self).data
data["workpiece_id"] = self.workpiece_id
data["frame"] = self.frame
return data

@data.setter
def data(self, data):
super(ManuallyMoveWorkpiece, type(self)).data.fset(self, data)
super(ManualWorkpieceMotion, type(self)).data.fset(self, data)
self.workpiece_id = data.get("workpiece_id", self.workpiece_id)
self.frame = data.get("frame", self.frame)

Expand Down
12 changes: 6 additions & 6 deletions tests/planning/test_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from compas_fab.planning import FreeMotion
from compas_fab.planning import OpenGripper
from compas_fab.planning import CloseGripper
from compas_fab.planning import ManuallyMoveWorkpiece
from compas_fab.planning import ManualWorkpieceMotion

from compas_fab.planning import SceneState
from compas_fab.planning import WorkpieceState
Expand Down Expand Up @@ -94,7 +94,7 @@ def test_action_members():
assert isinstance(FreeMotion(), Action)
assert isinstance(OpenGripper(), Action)
assert isinstance(CloseGripper(), Action)
assert isinstance(ManuallyMoveWorkpiece(), Action)
assert isinstance(ManualWorkpieceMotion(), Action)
# Test child class of RoboticAction
assert isinstance(LinearMotion(), RoboticAction)
assert isinstance(FreeMotion(), RoboticAction)
Expand Down Expand Up @@ -231,26 +231,26 @@ def test_close_gripper_preconditions(start_scene_state):


def test_load_workpiece_preconditions(start_scene_state):
action = ManuallyMoveWorkpiece("w1", None)
action = ManualWorkpieceMotion("w1", None)
# Default state object has one object attached to the robot
assert start_scene_state.get_attached_tool_id() == "t1"
assert start_scene_state.get_attached_workpiece_id() == "w1"
assert action.check_preconditions(start_scene_state)[0] is False

# Detach the workpiece from the robot
start_scene_state.workpiece_states["w1"].attached_to_robot = False
# ManuallyMoveWorkpiece action requires that the workpiece is not attached to the robot
# ManualWorkpieceMotion action requires that the workpiece is not attached to the robot
assert action.check_preconditions(start_scene_state)[0] is True

# Check non-existing workpiece
action = ManuallyMoveWorkpiece("w3", None)
action = ManualWorkpieceMotion("w3", None)
assert action.check_preconditions(start_scene_state)[0] is False


def test_load_workpiece_effect(start_scene_state):
workpiece_frame = Frame(Point(100.0, 200.0, 300.0), Vector(1.0, 0.0, 0.0), Vector(0.0, 1.0, 0.0))
assert start_scene_state.get_attached_workpiece_id() == "w1"
action = ManuallyMoveWorkpiece("w2", workpiece_frame)
action = ManualWorkpieceMotion("w2", workpiece_frame)

action.apply_effects(start_scene_state)
# Workpiece w2 should remain unattached but moved
Expand Down

0 comments on commit 11dfe5c

Please sign in to comment.