Timer based on RtActivities

RtActivities that wait (optionally for a given time)

In some situations it might be necessary to halt the program/device for a certain amount of time, before further processing is feasible.

Example: A Gripper of a robot is linked to a compressor and it needs to open.

1. We create a first Activity that sends a signal via digital output to the compressor. Pressure is sent to the Gripper and the Gripper starts to open.
2. We cannot just take the pressure away with the next Activity because the Gripper won’t open much this way. So we use an Activity that does nothing for 50 milliseconds.
3. After that, the Gripper opened up enough. Using another RtActivity, we stop the pressure.

The RoboticsAPI supplies the class SleepRtActivity to realize such a behavior.

SleepRtActivities can be described as a ”‘placeholder”’: They do not take control of any devices, nor do they execute any actions. It can however be parameterized in such a way that canceling is possible, allowing a subsequent Activity to take over the SleepActivity and continue the execution of the program. For example: Specifiying 0 as Timeout creates an infinite wait (as long as it isn’t canceled). Also, an alternative parameterization lets the Activity terminate after a previoulsy appointed amount of time.

How to create Summary

SleepRtActivity (RoboticsRuntime, double) constructs a SleepActivity with a given name
and a given SleepTime

Alternative: Invoke RtActivities.sleep(RoboticsRuntime, double) Returns an instantly created and anonymous

Use the method ”‘RtActivity XYZ.getRuntime”’

Below is an example which uses the SleepRtActivity to pause the two Robot Arms of a LWR-Unit between two parallel movements for 3 seconds.

A SleepActivity in LWR


  // Example Code 
    // Creating the Interfaces, as usual 
    PtpInterface left = lwrLeft.use(PtpInterface.class); 
    PtpInterface right = lwrRight.use(PtpInterface.class); 
    // Part 1: Creating a ParallelRtActivity to control the two arms 
    // Creating 2 Ptp's 
    RtActivity leftOne = left.ptp(new double[] { -1.5, 0.8, 0, -1.5, 0, 
        0.8, 0 }); 
    RtActivity rightOne = right.ptp(new double[] { 1.5, -0.5, 0, 1, 0, 
        -0.8, 0 }); 
    // Adding them to a ParallelRtActivity 
    // and execute 
    ParallelRtActivity twoMoves_One = new ParallelRtActivity(); 
    // Part 2: Creating the SleepActivities: 
    // Get the Robotics Runtime from the devices via the RtActivitites 
    RoboticsRuntime SleepGood = leftOne.getRuntime(); 
    RoboticsRuntime SleepTight = rightOne.getRuntime(); 
    // and use them to create two SleepActivities for both arms 
    // with the timer set to 5.0 seconds 
    SleepRtActivity sleepLeft = new SleepRtActivity(SleepGood, 3.0); 
    SleepRtActivity sleepRight = new SleepRtActivity(SleepTight, 3.0); 
    // Then add it to a ParallelActivity 
    // execute (The Arms should not move, everything's ok ;) ) 
    ParallelRtActivity twoMoves_Two = new ParallelRtActivity(); 
    // Part 3: Returning home 
    // via ParallelRtActivity 
    RtActivity homeLeft = left.ptpHome(); 
    RtActivity homeRight = right.ptpHome(); 
    ParallelRtActivity twoMoves_Three = new ParallelRtActivity();