RtActivities whose starting depends on the occurrence of a certain condition.
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 RtActivityWithSubActivities |
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.
,