Wait Time

A wait time is an instruction that lets the robot pause for a given duration on the robot side. Unlike std::thread::sleep, which only holds up your program, wait_time() is queued like a motion: it takes its place in the instruction queue, and the instruction that follows starts when the wait has elapsed. This keeps a timed dwell, for example while a gripper closes, inside the same block as the motions around it.

Waiting Between Motions

wait_time() from the WaitTime trait is a block step like any motion. It takes the duration as a Duration:

robot
    .move_ptp(poses::home())
    .wait_time(Duration::from_secs(2))
    .move_ptp(poses::vertical())
    .start()?
    .join()?;
info!("Vertical reached after a 2 s robot-side wait.");

The wait is executed by the robot, not by this program. Because the whole block is sent at once, the second motion is already known to the control when the wait ends.

A standalone wait is an instruction like any other, with the same start() and join():

robot.wait_time(Duration::from_secs(1)).start()?.join()?;

Waits and Blending

A wait can follow any unblended step, and a motion can follow a wait with or without blending. A wait cannot be blended into: after .blending() only a motion may follow, so move_ptp(..).blending(..).wait_time(..) does not compile.

robot
    .move_ptp(poses::home())
    .wait_time(Duration::from_secs(1))
    .move_ptp(poses::vertical())
    .blending(Percent(30.0))
    .move_ptp(JointPose::default())
    .start()?
    .join()?;
info!("Zero reached after sequence.");

Wait Time vs. Thread Sleep

wait_time()

std::thread::sleep()

Where it executes

Robot control

Your program

Part of the instruction queue

Yes

No

Blocks the calling thread

No; join() does if you want it to

Yes

Usable inside a block

Yes

No

Full Example

Trait Definition