From 39dfbf3ab71a3554a64a7dd8a8fb4f55eefe3257 Mon Sep 17 00:00:00 2001 From: Fabien Danieau Date: Tue, 8 Oct 2024 15:01:37 +0200 Subject: [PATCH] bug #383: remove is_goto_plyaing function --- src/examples/2_goto_introduction.ipynb | 7 +-- src/reachy2_sdk/reachy_sdk.py | 13 ----- tests/units/offline/test_reachy_sdk.py | 1 - .../online/test_advanced_goto_functions.py | 52 ------------------- .../units/online/test_multiple_connections.py | 1 - 5 files changed, 1 insertion(+), 73 deletions(-) diff --git a/src/examples/2_goto_introduction.ipynb b/src/examples/2_goto_introduction.ipynb index 99a9ca7e..8967a7ee 100644 --- a/src/examples/2_goto_introduction.ipynb +++ b/src/examples/2_goto_introduction.ipynb @@ -474,9 +474,8 @@ "id": "43", "metadata": {}, "source": [ - "For a specific goto, you may want to know its current state. You can get information on the goto given its id with 3 methods available at reachy's level:\n", + "For a specific goto, you may want to know its current state. You can get information on the goto given its id with 2 methods available at reachy's level:\n", "\n", - "- **`is_goto_playing()`**: return True if the movement is currently being played\n", "- **`is_goto_finished()`**: return True if the movement is over, but also if it won't be played because it has been cancelled for example\n", "- **`get_goto_joints_request()`**: will return the joints goal positions sent to the part by the corresponding goto command \n", "\n", @@ -496,16 +495,12 @@ "time.sleep(1)\n", "\n", "# Goto is currently being played\n", - "goto1_is_playing = reachy.is_goto_playing(goto_1)\n", - "print(f'After 1 second, goto 1 is playing : {goto1_is_playing}')\n", "goto1_is_finished = reachy.is_goto_finished(goto_1)\n", "print(f'After 1 second, goto 1 is finished : {goto1_is_finished}\\n')\n", "\n", "time.sleep(3)\n", "\n", "# Goto is now over\n", - "goto1_is_playing = reachy.is_goto_playing(goto_1)\n", - "print(f'After 4 seconds, goto 1 is playing : {goto1_is_playing}')\n", "goto1_is_finished = reachy.is_goto_finished(goto_1)\n", "print(f'After 4 seconds, goto 1 is finished : {goto1_is_finished}')" ] diff --git a/src/reachy2_sdk/reachy_sdk.py b/src/reachy2_sdk/reachy_sdk.py index 8643756b..dde35a9b 100644 --- a/src/reachy2_sdk/reachy_sdk.py +++ b/src/reachy2_sdk/reachy_sdk.py @@ -623,19 +623,6 @@ def is_goto_finished(self, goto_id: GoToId) -> bool: ) return result - def is_goto_playing(self, goto_id: GoToId) -> bool: - """Return True if goto is currently playing, False otherwise.""" - if not self._grpc_connected: - self._logger.warning("Reachy is not connected!") - return False - if not isinstance(goto_id, GoToId): - raise TypeError(f"goto_id must be a GoToId, got {type(goto_id).__name__}") - if goto_id.id == -1: - self._logger.error("is_goto_playing() asked for unvalid movement. Goto not played.") - return False - state = self._get_goto_state(goto_id) - return bool(state.goal_status == GoalStatus.STATUS_EXECUTING) - def cancel_all_goto(self) -> GoToAck: """Cancel all the goto tasks.""" if not self._grpc_connected: diff --git a/tests/units/offline/test_reachy_sdk.py b/tests/units/offline/test_reachy_sdk.py index b2071b3f..426074c8 100644 --- a/tests/units/offline/test_reachy_sdk.py +++ b/tests/units/offline/test_reachy_sdk.py @@ -75,4 +75,3 @@ def test_unconnected() -> None: assert rsdk.get_goto_joints_request(GoToId(id=1)) is None assert rsdk.is_goto_finished(GoToId(id=1)) is False - assert rsdk.is_goto_playing(GoToId(id=1)) is False diff --git a/tests/units/online/test_advanced_goto_functions.py b/tests/units/online/test_advanced_goto_functions.py index 5a6d41e1..e6f70985 100644 --- a/tests/units/online/test_advanced_goto_functions.py +++ b/tests/units/online/test_advanced_goto_functions.py @@ -529,57 +529,11 @@ def test_is_goto_finished(reachy_sdk_zeroed: ReachySDK) -> None: reachy_sdk_zeroed.is_goto_finished(3) -@pytest.mark.online -def test_is_goto_playing(reachy_sdk_zeroed: ReachySDK) -> None: - req1 = reachy_sdk_zeroed.head.goto_joints([30, 0, 0], duration=2) - req2 = reachy_sdk_zeroed.l_arm.goto_joints([10, 10, 15, -20, 15, -15, -10], duration=3, interpolation_mode="linear") - req3 = reachy_sdk_zeroed.r_arm.goto_joints([0, 10, 20, -40, 10, 10, -15], duration=4) - - time.sleep(1) - assert reachy_sdk_zeroed.is_goto_playing(req1) - assert reachy_sdk_zeroed.is_goto_playing(req2) - assert reachy_sdk_zeroed.is_goto_playing(req3) - - req4 = reachy_sdk_zeroed.head.goto_joints([0, 0, 0], duration=1) - req5 = reachy_sdk_zeroed.l_arm.goto_joints([0, 0, 0, 0, 0, 0, 0], duration=1) - req6 = reachy_sdk_zeroed.r_arm.goto_joints([0, 0, 0, 0, 0, 0, 0], duration=4) - - time.sleep(1) - assert reachy_sdk_zeroed._get_goto_state(req1).goal_status == GoalStatus.STATUS_SUCCEEDED - assert reachy_sdk_zeroed._get_goto_state(req2).goal_status == GoalStatus.STATUS_EXECUTING - assert reachy_sdk_zeroed._get_goto_state(req3).goal_status == GoalStatus.STATUS_EXECUTING - assert not reachy_sdk_zeroed.is_goto_playing(req1) - assert reachy_sdk_zeroed.is_goto_playing(req2) - assert reachy_sdk_zeroed.is_goto_playing(req3) - assert reachy_sdk_zeroed.is_goto_playing(req4) - assert not reachy_sdk_zeroed.is_goto_playing(req5) - assert not reachy_sdk_zeroed.is_goto_playing(req6) - - cancel = reachy_sdk_zeroed.l_arm.cancel_all_goto() - assert cancel.ack - assert not reachy_sdk_zeroed.is_goto_playing(req2) - - time.sleep(2) - assert reachy_sdk_zeroed._get_goto_state(req1).goal_status == GoalStatus.STATUS_SUCCEEDED - assert reachy_sdk_zeroed._get_goto_state(req2).goal_status == GoalStatus.STATUS_CANCELED - assert reachy_sdk_zeroed._get_goto_state(req3).goal_status == GoalStatus.STATUS_SUCCEEDED - assert not reachy_sdk_zeroed.is_goto_playing(req1) - assert not reachy_sdk_zeroed.is_goto_playing(req2) - assert not reachy_sdk_zeroed.is_goto_playing(req3) - assert not reachy_sdk_zeroed.is_goto_playing(req4) - assert not reachy_sdk_zeroed.is_goto_playing(req5) - assert reachy_sdk_zeroed.is_goto_playing(req6) - - with pytest.raises(TypeError): - reachy_sdk_zeroed.is_goto_finished(3) - - @pytest.mark.online def test_single_joint_goto(reachy_sdk_zeroed: ReachySDK) -> None: req1 = reachy_sdk_zeroed.r_arm.elbow.pitch.goto(-90, duration=3) time.sleep(0.5) - assert reachy_sdk_zeroed.is_goto_playing(req1) while not is_goto_finished(reachy_sdk_zeroed, req1): time.sleep(0.1) @@ -588,7 +542,6 @@ def test_single_joint_goto(reachy_sdk_zeroed: ReachySDK) -> None: req2 = reachy_sdk_zeroed.r_arm.elbow.pitch.goto(0, duration=1) time.sleep(0.5) - assert reachy_sdk_zeroed.is_goto_playing(req2) while not is_goto_finished(reachy_sdk_zeroed, req2): time.sleep(0.1) @@ -599,9 +552,6 @@ def test_single_joint_goto(reachy_sdk_zeroed: ReachySDK) -> None: req5 = reachy_sdk_zeroed.l_arm.wrist.pitch.goto(15, duration=1) time.sleep(0.5) - assert reachy_sdk_zeroed.is_goto_playing(req3) - assert not reachy_sdk_zeroed.is_goto_playing(req4) - assert not reachy_sdk_zeroed.is_goto_playing(req5) assert len(reachy_sdk_zeroed.l_arm.get_goto_queue()) == 2 while not is_goto_finished(reachy_sdk_zeroed, req5): time.sleep(0.1) @@ -612,8 +562,6 @@ def test_single_joint_goto(reachy_sdk_zeroed: ReachySDK) -> None: req7 = reachy_sdk_zeroed.head.neck.yaw.goto(10, duration=1) time.sleep(0.5) - assert reachy_sdk_zeroed.is_goto_playing(req6) - assert not reachy_sdk_zeroed.is_goto_playing(req7) assert len(reachy_sdk_zeroed.head.get_goto_queue()) == 1 while not is_goto_finished(reachy_sdk_zeroed, req7): time.sleep(0.1) diff --git a/tests/units/online/test_multiple_connections.py b/tests/units/online/test_multiple_connections.py index 78d61e2b..18fca3fa 100644 --- a/tests/units/online/test_multiple_connections.py +++ b/tests/units/online/test_multiple_connections.py @@ -45,7 +45,6 @@ def test_same_robot(reachy_sdk_zeroed: ReachySDK) -> None: move1_id = reachy_sdk_zeroed.l_arm.goto_joints(move1_goal, duration=5) time.sleep(0.1) - assert reachy_sdk_zeroed.is_goto_playing(move1_id) == reachy2.is_goto_playing(move1_id) while not reachy_sdk_zeroed.is_goto_finished(move1_id): # update loops are not synchronized, we do not expect the same values