From ad660962e5eebe48a69ef3b7441683d202769ee8 Mon Sep 17 00:00:00 2001 From: ZdenekM Date: Tue, 26 Mar 2024 13:22:33 +0100 Subject: [PATCH] feat: improved FIT objects --- README.md | 4 ++-- compose-files/fit-demo/docker-compose.yml | 8 ++++---- src/docker/arcor2_dobot/BUILD | 2 +- src/docker/arcor2_upload_fit_demo/BUILD | 2 +- src/python/arcor2_dobot/CHANGELOG.md | 6 ++++++ src/python/arcor2_dobot/VERSION | 2 +- src/python/arcor2_dobot/dobot.py | 7 +++++-- src/python/arcor2_dobot/dobot_api.py | 4 ++-- src/python/arcor2_fit_demo/CHANGELOG.md | 6 ++++++ src/python/arcor2_fit_demo/VERSION | 2 +- src/python/arcor2_fit_demo/object_types/conveyor_belt.py | 8 ++++---- src/python/arcor2_fit_demo/object_types/erp.py | 5 ++--- 12 files changed, 35 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index e8884e1cd..45ce3db56 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ The following video by [Kinali](https://www.kinali.cz/en/) shows the use case (o [README](src/python/arcor2_dobot/README.md) | [CHANGELOG](src/python/arcor2_dobot/CHANGELOG.md) - - 2024-02-20: [1.1.1](https://github.com/robofit/arcor2/releases/tag/arcor2_dobot%2F1.1.1) ([docker](https://hub.docker.com/r/arcor2/arcor2_dobot/tags?page=1&ordering=last_updated&name=1.1.1), [pypi](https://pypi.org/project/arcor2-dobot/1.1.1/)). + - 2024-03-26: [1.2.0](https://github.com/robofit/arcor2/releases/tag/arcor2_dobot%2F1.2.0) ([docker](https://hub.docker.com/r/arcor2/arcor2_dobot/tags?page=1&ordering=last_updated&name=1.2.0), [pypi](https://pypi.org/project/arcor2-dobot/1.2.0/)). ### arcor2_execution @@ -108,7 +108,7 @@ The following video by [Kinali](https://www.kinali.cz/en/) shows the use case (o [README](src/python/arcor2_fit_demo/README.md) | [CHANGELOG](src/python/arcor2_fit_demo/CHANGELOG.md) -- 2024-03-25: [1.3.0](https://github.com/robofit/arcor2/releases/tag/arcor2_fit_demo%2F1.3.0) ([docker](https://hub.docker.com/r/arcor2/arcor2_upload_fit_demo/tags?page=1&ordering=last_updated&name=1.3.0), [pypi](https://pypi.org/project/arcor2-fit-demo/1.3.0/)). +- 2024-03-26: [1.4.0](https://github.com/robofit/arcor2/releases/tag/arcor2_fit_demo%2F1.4.0) ([docker](https://hub.docker.com/r/arcor2/arcor2_upload_fit_demo/tags?page=1&ordering=last_updated&name=1.4.0), [pypi](https://pypi.org/project/arcor2-fit-demo/1.4.0/)). ### arcor2_kinect_azure diff --git a/compose-files/fit-demo/docker-compose.yml b/compose-files/fit-demo/docker-compose.yml index 89fe20754..5ce240434 100644 --- a/compose-files/fit-demo/docker-compose.yml +++ b/compose-files/fit-demo/docker-compose.yml @@ -98,7 +98,7 @@ services: - ./calibration.yaml:/root/calibration.yaml fit-demo-dobot-magician: - image: arcor2/arcor2_dobot:1.1.1 + image: arcor2/arcor2_dobot:1.2.0 container_name: fit-demo-dobot-magician depends_on: fit-demo-scene: @@ -114,7 +114,7 @@ services: - ARCOR2_DOBOT_MODEL=magician fit-demo-dobot-magician2: - image: arcor2/arcor2_dobot:1.1.1 + image: arcor2/arcor2_dobot:1.2.0 container_name: fit-demo-dobot-magician2 depends_on: fit-demo-scene: @@ -130,7 +130,7 @@ services: - ARCOR2_DOBOT_MODEL=magician fit-demo-dobot-m1: - image: arcor2/arcor2_dobot:1.1.1 + image: arcor2/arcor2_dobot:1.2.0 container_name: fit-demo-dobot-m1 depends_on: fit-demo-scene: @@ -210,7 +210,7 @@ services: - fit-demo-asset fit-demo-upload-object-types: - image: arcor2/arcor2_upload_fit_demo:1.3.0 + image: arcor2/arcor2_upload_fit_demo:1.4.0 container_name: "fit-demo-upload-object-types" depends_on: fit-demo-project: diff --git a/src/docker/arcor2_dobot/BUILD b/src/docker/arcor2_dobot/BUILD index 6d660afcc..1aad5e225 100644 --- a/src/docker/arcor2_dobot/BUILD +++ b/src/docker/arcor2_dobot/BUILD @@ -1 +1 @@ -docker_image(name="arcor2_dobot", repository="arcor2/arcor2_dobot", image_tags=["1.1.1"]) +docker_image(name="arcor2_dobot", repository="arcor2/arcor2_dobot", image_tags=["1.2.0"]) diff --git a/src/docker/arcor2_upload_fit_demo/BUILD b/src/docker/arcor2_upload_fit_demo/BUILD index d6acba633..be6d50653 100644 --- a/src/docker/arcor2_upload_fit_demo/BUILD +++ b/src/docker/arcor2_upload_fit_demo/BUILD @@ -1 +1 @@ -docker_image(name="arcor2_upload_fit_demo", repository="arcor2/arcor2_upload_fit_demo", image_tags=["1.3.0"]) \ No newline at end of file +docker_image(name="arcor2_upload_fit_demo", repository="arcor2/arcor2_upload_fit_demo", image_tags=["1.4.0"]) \ No newline at end of file diff --git a/src/python/arcor2_dobot/CHANGELOG.md b/src/python/arcor2_dobot/CHANGELOG.md index 963a3d0b4..6aed3ed91 100644 --- a/src/python/arcor2_dobot/CHANGELOG.md +++ b/src/python/arcor2_dobot/CHANGELOG.md @@ -2,6 +2,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +## [1.2.0] - 2024-03-26 + +### Changed + +- Setting belt distance is now blocking operation. + ## [1.1.1] - 2024-02-20 ### Fixed diff --git a/src/python/arcor2_dobot/VERSION b/src/python/arcor2_dobot/VERSION index 8cfbc905b..867e52437 100644 --- a/src/python/arcor2_dobot/VERSION +++ b/src/python/arcor2_dobot/VERSION @@ -1 +1 @@ -1.1.1 \ No newline at end of file +1.2.0 \ No newline at end of file diff --git a/src/python/arcor2_dobot/dobot.py b/src/python/arcor2_dobot/dobot.py index dd6754627..c6ef402ec 100644 --- a/src/python/arcor2_dobot/dobot.py +++ b/src/python/arcor2_dobot/dobot.py @@ -83,8 +83,11 @@ def conveyor_speed(self, speed: float, direction: int = 1) -> None: if not self.simulator: self._dobot.conveyor_belt(speed, direction) - def conveyor_distance(self, speed: float, distance: float, direction: int = 1) -> None: - self._dobot.conveyor_belt_distance(speed, distance, direction) + def conveyor_distance(self, speed: float, distance: float, direction: int = 1, blocking=True) -> None: + idx = self._dobot.conveyor_belt_distance(speed, distance, direction) + + if blocking: + self._dobot.wait_for_cmd(idx) @property def hand_teaching_mode(self) -> bool: diff --git a/src/python/arcor2_dobot/dobot_api.py b/src/python/arcor2_dobot/dobot_api.py index 2226d0fea..e9eb5118c 100644 --- a/src/python/arcor2_dobot/dobot_api.py +++ b/src/python/arcor2_dobot/dobot_api.py @@ -711,11 +711,11 @@ def _set_stepper_motor(self, speed: int, interface: int = 0, motor_control=True) msg.params.extend(bytearray(struct.pack("i", speed))) return self._send_command(msg) - def conveyor_belt_distance(self, speed: float, distance: float, direction: int = 1, interface: int = 0) -> None: + def conveyor_belt_distance(self, speed: float, distance: float, direction: int = 1, interface: int = 0) -> int: if 0.0 <= speed <= 100.0 and (direction == 1 or direction == -1): motor_speed = speed * STEP_PER_CIRCLE / MM_PER_CIRCLE * direction steps = (distance * STEP_PER_CIRCLE / MM_PER_CIRCLE) / HUNGARIAN_CONSTANT - self._set_stepper_motor_distance(int(motor_speed), int(steps), interface) + return self._extract_cmd_index(self._set_stepper_motor_distance(int(motor_speed), int(steps), interface)) else: raise DobotApiException("Wrong conveyor belt parameters.") diff --git a/src/python/arcor2_fit_demo/CHANGELOG.md b/src/python/arcor2_fit_demo/CHANGELOG.md index 5f8769ee8..02c71dcfb 100644 --- a/src/python/arcor2_fit_demo/CHANGELOG.md +++ b/src/python/arcor2_fit_demo/CHANGELOG.md @@ -2,6 +2,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +## [1.4.0] - 2024-03-26 + +### Changed + +- Minor changes to ObjectTypes. + ## [1.3.0] - 2024-03-25 ### Added diff --git a/src/python/arcor2_fit_demo/VERSION b/src/python/arcor2_fit_demo/VERSION index 589268e6f..e21e727f9 100644 --- a/src/python/arcor2_fit_demo/VERSION +++ b/src/python/arcor2_fit_demo/VERSION @@ -1 +1 @@ -1.3.0 \ No newline at end of file +1.4.0 \ No newline at end of file diff --git a/src/python/arcor2_fit_demo/object_types/conveyor_belt.py b/src/python/arcor2_fit_demo/object_types/conveyor_belt.py index c660b58b7..922e70eba 100644 --- a/src/python/arcor2_fit_demo/object_types/conveyor_belt.py +++ b/src/python/arcor2_fit_demo/object_types/conveyor_belt.py @@ -11,8 +11,8 @@ class Direction(StrEnum): - FORWARD: str = "forward" - BACKWARDS: str = "backwards" + LEFT: str = "left" + RIGHT: str = "right" @dataclass @@ -45,7 +45,7 @@ def __init__( raise Arcor2Exception("Failed to connect to the Dobot Service.") def set_velocity( - self, velocity: float = 0.5, direction: Direction = Direction.FORWARD, *, an: None | str = None + self, velocity: float = 0.5, direction: Direction = Direction.RIGHT, *, an: None | str = None ) -> None: """Belt will move indefinitely with given velocity. @@ -69,7 +69,7 @@ def set_distance( self, velocity: float = 0.5, distance: float = 0.55, - direction: Direction = Direction.FORWARD, + direction: Direction = Direction.RIGHT, *, an: None | str = None, ) -> None: diff --git a/src/python/arcor2_fit_demo/object_types/erp.py b/src/python/arcor2_fit_demo/object_types/erp.py index 6cfafabe7..fb3b35c78 100644 --- a/src/python/arcor2_fit_demo/object_types/erp.py +++ b/src/python/arcor2_fit_demo/object_types/erp.py @@ -9,10 +9,9 @@ class Erp(Generic): _ABSTRACT = False - def log_production_step(self, step: str, success: bool, *, an: None | str = None) -> None: - """Logs finished production step. + def log_production_step(self, success: bool = True, *, an: None | str = None) -> None: + """Logs finished production step (described by action name). - :param step: Name of the production step. :param success: Indicates whether the step was successful. :param an: :return: