Main Content

waitfor

Pause code execution to achieve desired execution rate

Description

waitfor(rate) pauses execution until the code reaches the desired execution rate. The function accounts for the time that is spent executing code between waitfor calls.

numMisses = waitfor(rate) returns the number of iterations missed while executing code between calls.

Input Arguments

collapse all

Rate object, specified as a handle. This object contains the information for the desired rate and other information about the execution. See rateControl (Robotics System Toolbox) for more information.

Output Arguments

collapse all

Number of missed task executions, returned as a scalar. waitfor returns the number of times the task was missed in the Rate object based on the LastPeriod time. For example, if the desired rate is 1 Hz and the last period was 3.2 seconds, numMisses returns 3.

Version History

Introduced in R2019b

See Also

| (Robotics System Toolbox)

Topics