We were wondering if we can use your goto() function to send the arm to a specific goal position but be able to stop it before it reaches the position.
I read in the API that calling goto() returns:
trajectory player that can be used to monitor the trajectory, stop it, etc
but I am not sure how I can use that returned trajectoryPlayer to stop the arm while it’s still moving.
I also came across this commit, which is exactly what we need, but I’m unclear on how to implement the stop - can you please clarify how this can be done?
We were wondering if we can use your goto() function to send the arm to a specific goal position but be able to stop it before it reaches the position.
Yes, that’s exactly the purpose! The goto method will always return a list of TrajectoryInterpolation object (one per controlled motor) that can be wait, stop, etc.
You can used it in combination with the wait=False parameter of te goto method.
For instance, in the example below I’m running a goto trajectory that suppose to last for 3 seconds but I’m actually stopping it after 1 second:
import time
trajs = reachy.goto({
'left_arm.shoulder_pitch': 0,
'left_arm.shoulder_roll': 0,
'left_arm.arm_yaw': 0,
'left_arm.elbow_pitch': -90,
'left_arm.hand.forearm_yaw': 0,
'left_arm.hand.wrist_pitch': 0,
'left_arm.hand.wrist_roll': 0,
'left_arm.hand.gripper': 0,
}, duration=3, wait=False)
time.sleep(1)
for t in trajs:
t.stop()