-
Notifications
You must be signed in to change notification settings - Fork 15
PNP variables
In PNP, there is the possibility to write parametric plans (i.e., plans that contain variables).
Variables are represented with a string starting with the @ character, they are reset at the beginning of each execution (init place), can get values during plan execution, and use the values later on in the plan.
For example, it is possible to define an action GoTo_@X_@Y_@Theta
where the three variables @X
, @Y
, and @Theta
are instantiated at plan execution time, before execution of the action.
There are several ways to instantiate PNP global variables:
- send an event of the form
GoTo_instance1_instance2_instance3
, it will instantiate the variables with the instances provided (in this case X=instance1, Y=instance2, Theta=instance3).
Example: use topic /pnp/conditionEvent
of type String
rostopic pub /pnp/conditionEvent ... 'setvar_@X_instance1'
-
use the ROS service
pnp/setVariableValue
of typePNPSetVariableValue
string variable string value ---
Example: rossrv call pnp/setVariableValue ...
- execute the action
setvar_<var>_<value>
in the plan
Example: setvar_@X_instance1
After instantiation, the global variables can be used in the plan (for example in execution nodes, such as in a node called GoTo_@X_@[email protected]
).
To modify the values of the variables, just re-instantiate them as previously explained.
ROS Service pnp/getVariableValue
of type PNPGetVariableValue
string variable
---
string answer
can be used to read the value of a PNP global variable