Dependent RtActivities

RtActivities whose starting depends on the occurrence of a certain condition.

A RtActivity with a Sub


  // Example Code 
    //Linking interfaces with arms 
    PtpInterface leftInterface = lwrLeft.use(PtpInterface.class); 
    PtpInterface rightInterface = lwrRight.use(PtpInterface.class); 
    // create the main RtActivity 
    PlannedRtActivity left = leftInterface.ptp(new double[] { -1.5, 0.8, 0, 
        -1.5, 0, 0.8, 0 }); 
    // Instanciate the class RtActivityWithSubActivities 
    // along with defining the MainActivity (left) 
    RtActivityWithSubactivities mainWithOneSub = new RtActivityWithSubactivities(left); 
    // Creating a SubActivity 
    RtActivity right = rightInterface.ptp(new double[] { -1, 1.8, 1, 1, 1, 1,0}); 
    //Creating a condition using the class State 
    // make the State dependent on the MainActivity 
    State motionHalfDone = left.getMotionTimeProgress(0.5); 
    //Adding condition and SubActivty to the MainActivity 
    mainWithOneSub.addSubActivity(motionHalfDone, right); 

Often times a running robot program requires the execution of an additional Activity if certain conditions are met.
For example: The robot is instructed to rotate the tool it holds, but only after a certain motion is halfway completed. To enable such a behavior, the Robotics-API provides the class RtActivityWithSubactivities.

Implementing this class correctly requires the user to commit an Activity to the constructor. This Activity will be deemed a Main-Activity. Main-Activities can be enhanced by adding additional Activities to it. These Activities are in turn called Sub-Activities and can only be executed under certain conditions.

How to create Summary

RtActivityWithSubactivities (RtActivity main) Instanciates a new RtActivityWithSubactivities
with a chosen Main-Activity (can be used directly)

RtActivityWithSubactivities(String name, RtActivity main) Instanciates a new RtActivityWithSubactivities
with a chosen Main-Activity and name

Alternative: Invoke RtActivities.subActivity
(mainActivity, startCondition, subActivity)
Returns an instantly created and anonymous

Adding another Activity to the Main-Activity requires such a condition, which acts as a ”Trigger” to its respective added Activity and ensures that it can only execute if the condition is fulfilled. These conditions are usually represented as States. (To learn more about States, please click on the link or turn to chapter 1.4.6)

Methods Summary

addSubActivity(State condition, T subactivity)links the committed Activity to a MainActivity,
the returned Object is the SubActivity itself

In sum, this means that each Sub-Activity depends on two prerequisites which need to be met before an execution can be initiated:

1. Since Sub-Activities are committed to a single Main-Activity, the Main-Actvitiy needs to get called and executed
2. The created condition (which can be a different one for each Sub-Activity) has to be fulfilled.

It is recommended to use the Subclass RtActivities if SubActivities need to be created. Also, there is no limit on how many SubActivities can be added to a single MainActivity.