reset

Reset Rate object

Description

example

reset(rate) resets the state of the Rate object, including the elapsed time and all statistics about previous periods. reset is useful if you want to run multiple successive loops at the same rate, or if the object is created before the loop is executed.

Input Arguments

expand all

rateControl object, specified as a handle. This object contains the information for the desired rate and other information about the execution. See rateControl for more information.

Examples

expand all

Create a Rate object for running at 20 Hz.

r = robotics.Rate(2);

Start a loop and control operation using the Rate object.

for i = 1:30
    % Your code goes here
    waitfor(r);
end

Display the Rate object properties after loop operation.

disp(r)
  rateControl with properties:

         DesiredRate: 2
       DesiredPeriod: 0.5000
       OverrunAction: 'slip'
    TotalElapsedTime: 15.0098
          LastPeriod: 0.4969

Reset the object to restart the time statistics.

reset(r);
disp(r)
  rateControl with properties:

         DesiredRate: 2
       DesiredPeriod: 0.5000
       OverrunAction: 'slip'
    TotalElapsedTime: 0.0051
          LastPeriod: NaN

See Also

| |

Topics

Introduced in R2019b