Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug #383: remove is_goto_plyaing function #418

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions src/examples/2_goto_introduction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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}')"
]
Expand Down
13 changes: 0 additions & 13 deletions src/reachy2_sdk/reachy_sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion tests/units/offline/test_reachy_sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
52 changes: 0 additions & 52 deletions tests/units/online/test_advanced_goto_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)

Expand All @@ -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)
Expand All @@ -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)
Expand Down
1 change: 0 additions & 1 deletion tests/units/online/test_multiple_connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading