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

399 robot is stuck in infinite loop using translate by with wait=true #417

Conversation

FabienDanieau
Copy link
Contributor

The bug was due to the if wait that was not supposed to be triggered with unreachable comment (i.e. there is nothing to wait for). It is fixed by a elif

    response = self._goto_stub.GoToCartesian(request)
    if response.id == -1:
        self._logger.error(f"Target pose:\\n {target} \\nwas not reachable. No command sent.")
    if wait:
        self._logger.info(f"Waiting for movement with {response}.")
        while not self._is_goto_finished(response):
            time.sleep(0.1)
        self._logger.info(f"Movement with {response} finished.")
    return response

I've added this mechanism to all goto functions, even if the goto_joints don't raise unreachable errors for now.
Also there is a timeout in the wait function to be sure that we don't wait forever if something goes bad on the server side (timeout is set to duration + 1 sec.)
+ little bit of refactoring

Copy link

github-actions bot commented Oct 8, 2024

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
965 880 91% 0% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
tests/units/online/test_advanced_goto_functions.py 100% 🟢
TOTAL 100% 🟢

updated for commit: db01002 by action🐍

Copy link
Member

@glannuzel glannuzel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should change how timeouts are triggered

t1 = time.time()
while not self._is_goto_finished(id):
time.sleep(0.1)
if time.time() - t1 > timeout:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think timeout for the gotos should be checked once the movement has begun only.

If we do:

pose2 = get_pose_matrix([0.4, -0.2, -0.1], [0, -90, 0])
reachy.goto_posture("default")
reachy.r_arm.goto_from_matrix(pose2, wait=True)

Then the timeout is triggered, whereas the goto was just queued

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The timeout is now the sum of the duration of all pending movements on the part

Copy link
Member

@glannuzel glannuzel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

@FabienDanieau FabienDanieau merged commit 2edfd20 into develop Oct 9, 2024
6 checks passed
@FabienDanieau FabienDanieau deleted the 399-robot-is-stuck-in-infinite-loop-using-translate_by-with-wait=true branch October 9, 2024 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Robot is stuck in infinite loop using translate_by with wait=True
2 participants