Python Template
The Python template used for translation of TXT scripts (aka, SG scripts) was externalized in Dial 2.1.2, such that it allows for any needed edits.
Template location
- Only one template is recognized, and we refer to this as the "global python template".
- The file name is
GLOBAL_PYTHON_TEMPLATE.py, and expected to be under the configured Dial workspace. In the compaslabdev instance, this corresponds to:Sandbox/Dial/GLOBAL_PYTHON_TEMPLATE.py. - If not yet existent, the file is automatically created (as a copy of an internal template).
Placeholders
According to the setup that has been used so far, the recognized placeholders can be summarized as follows:
| Placeholder (schematic) | Description |
|---|---|
{{TXT_CONTENT}} |
The txt script itself |
{{controlledAxes.*}} |
Controlled access parameters |
{{navParams.*}} |
Navigation parameters |
{{linearTwistMax/Min}} |
Linear twist parameters |
The concrete placeholders can be seen in the actual complete template:
##! Template for getting the resulting python version from a TXT script
##! and associated parameters, as captured in the Dial UI.
##! Lines starting with `##!` are not transferred to the python version.
from mission_script.context import *
from mission_script.nav import ScriptGoal, NavigationParameters, ControlledAxes
from mission_script import models
script = """
{{TXT_CONTENT}}
"""
controlled_axes = ControlledAxes(
x={{controlledAxes.x}},
y={{controlledAxes.y}},
z={{controlledAxes.z}},
roll={{controlledAxes.roll}},
pitch={{controlledAxes.pitch}},
yaw={{controlledAxes.yaw}},
)
linear_twist_max = {{linearTwistMax}}
angular_twist_max = {{angularTwistMax}}
twist_max = models.Twist(
linear=models.Point(x=linear_twist_max, y=linear_twist_max, z=linear_twist_max),
angular=models.Point(x=angular_twist_max, y=angular_twist_max, z=angular_twist_max)
)
params = NavigationParameters(
relative={{navParams.relative}},
controlled_axes=controlled_axes,
linear_epsilon={{navParams.linearEpsilon}},
angular_epsilon_rad={{navParams.angularEpsilonRad}},
linear_horizon={{navParams.linearHorizon}},
angular_horizon={{navParams.angularHorizon}},
twist_max=twist_max,
)
run(navigate(ScriptGoal(script, params=params)))