Parameterizing RtActivities

RtActivities can be parameterized to vary their execution according to the needs of different applications. For example, the path speed of a linear motion may be adapted to the process that is being executed. In the Robotics API, this is supported by the concept of DeviceParameters. Different kinds of devices provide implementations of this generic interface that are applicable for the respective devices. E.g., devices that can perform motions in Cartesian space, like robots, respect Cartesian velocity and acceleration values supplied by CartesianParameters when executing motion activities.

DeviceParameters can be supplied when creating an RtActivity. Each DeviceInterface method that returns an RtActivity accepts an optional list of DeviceParameters. Consider the following example:

LWR lwr = RoboticsRegistry.get("lwr", LWR.class); 
LinInterface linInterface = lwr.use(LinInterface.class); 
Frame goal = ... // some cartesian goal 
linInterface.lin(goal, new CartesianParameters(1, 2, 0.5, 1)).execute();

Here, a linear motion is parameterized with CartesianParameters that specify translational velocity of 1 m/s, translational acceleration of 2 m/s2, rotational velocity of 0.5 rad/s and rotational acceleration of 1 rad/s2.

Besides specifying DeviceParameters for each RtActivity separately, instances of DeviceInterfaces as well as Devices store a set of default DeviceParameters. This set can be modified by updating parameters, which will affect all usages of the respective DeviceInterface instance or the Device throughout the application. The following example illustrates modifying the default DeviceParameters of a DeviceInterface:

LWR lwr = RoboticsRegistry.get("lwr", LWR.class); 
LinInterface linInterface = lwr.use(LinInterface.class); 
linInterface.addDefaultParameters(new CartesianParameters(1, 2, 0.5, 1)); 
Frame goal = ... // some cartesian goal 
linInterface.lin(goal).execute();

Compared to the previous example, CartesianParameters are set on an instance of the LWR’s LinInterface via addDefaultParameters(...). These DeviceParameters are thus used as default parameters for every Activity created by this DeviceInterface’s instance (note that calls to Device#use(...) create new instances of DeviceInterfaces).

An even more global method for setting default DeviceParameters is setting them as default parameters of the Device itself:

LWR lwr = RoboticsRegistry.get("lwr", LWR.class); 
lwr.addDefaultParameters(new CartesianParameters(1, 2, 0.5, 1)); 
LinInterface linInterface = lwr.use(LinInterface.class); 
Frame goal = ... // some cartesian goal 
linInterface.lin(goal).execute();

DeviceParameters that are set on DeviceInterface instances have precedence over parameters of Devices. When DeviceParameters are provided to methods creating RtActivities, those parameters have precedence over default parameters of the DeviceInterface instance (and thus transitively also over the Device’s parameters).