Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
After sending
move_to()
ormove_by()
commands to Stretch's joints, there are currently two ways to wait to block program flow until the commands are completed:wait_until_at_setpoint()
method belonging to the motor for which the motion was commanded. For example:r.end_of_arm.get_joint('wrist_roll')
). This approach also requires the user to sleep for a small amount of time before callingwait_until_at_setpoint()
because the Python threads need time to perform the USB communication that fetches the latest status and update the robot's status dictionary.This PR introduces
wait_command(timeout=15.0)
to the robot class. The method blocks program execution until all robot motion is complete. Since users can callrobot.wait_command()
, they don't need to query specific joint(s) to find out if the motion completed.wait_command()
takes in an argument calledtimeout
determining how long the method waits for motion to complete.wait_command()
returns a boolean, where True means all motion completed, and False means the motion is ongoing andtimeout
elapsed.Testing
This method hasn't been tested with the waypoint trajectory or the velocity interfaces. This method relies on Python threads to update status dictionaries and Python is known to starve threads to prioritize computation in the main process. Depending on the computation running alongside the Robot class, you may see unexpected behavior from
wait_command()
.This PR has been tested on a RE2 running Ubuntu 22.04 (Python 3.10), and P3 firmware.