Tormach Robot Programming Language
The TRPL is based on Python. All commands interpreted by the TRPL interpreter are Python code, which means you can use any Python code to control the robot. However, the graphical conversational programming utility only supports re-interpretation of a subset of commands as defined here.
Contents
- 1 Contents
- 2 Program structure
- 3 Linear and Angular Units
- 4 Waypoints
- 5 Movement
- 6 User and Tool Frames
- 6.1 User Frames
- 6.2 Tool Frames
- 7 Digital I/O
- 8 PathPilot Remote
- 9 Notifications
- 10 Program Flow
- 10.1 Loops
- 10.2 Conditions
- 10.3 Subprograms
- 11 Persistent Parameter Storage
- 12 Probing
- 13 Interrupts
- 14 Calibration
- 15 List of Supported and Deprecated Commands
A TRPL program is a simple Python file with a single main function containing the program code. The support RPL commands are imported per default; any additional external libraries can be imported if required.
Note that the program interpreter only can track code execution in the main program file. Blocking commands in external libraries might, therefore, lock up the program execution
The main function is executed in a loop. If you want to break this behavior, use the exit statement.
from robot_command.rpl import * # import all robot commands
set_units("mm", "deg") # set the linear and angular unit types for the program
# waypoints are defined in the header of the program
waypoint_1 = j[0.764, 1.64, 0.741, 0.433, 0.140, 2.74]
waypoint_2 = p[361.53,947.19, 937.11, 45, 0, 0]
# the main function contains the program code
def main():
movel(waypoint_1) # a linear move command
sleep(0.5) # wait for 0.5 seconds
movej(waypoint_2) # a joint move command
sleep(0.5) # wait for 0.5 secondsThe following Python method names have a special meaning in the TRPL interpreter:
main: The robot programs main loop. Required in every program.
on_abort: Called when the program is aborted as a result of an error or controlled exit by the operator.
on_pause: Called when the program is paused.
The on_abort and on_pause methods are useful for disabling digital outputs or cleaning up initialized resources. If an error occurs in the on_pause method on_abort will be called as a fallback. If an error occurs in the on_abort method the program will exit instantly.
Below you can find Python stub files, supported in most modern IDEs.
To use them, install the robot_command-stubs package by issuing the python3 setup.py install command.
The TRPL supports multiple linear and angular measurement units. It is advised to define the units used in a program as the first line of the program. Changing units at runtime is supported, but highly discouraged.
Supported linear unit types:
“m” - Meters
“mm” - Millimeters
“in” - Inches
Supported angular unit types:
“deg” - Degrees
“rad” - Radians
robot_command.rpl.set_units(linear: str | SharedRegistryObject | None = None, angular: str | SharedRegistryObject | None = None, time: str | SharedRegistryObject | None = None)
Sets the active linear, angular and time units for the program.
Parameters: |
|
Examples
set_units("mm", "deg", "s")
set_units(linear="in")
set_units(angular="rad")
set_units(time="s")robot_command.rpl.get_units(with_time: bool = False) -> Tuple[str, str] | Tuple[str, str, str]
Returns the active linear, angular and time units from the program.
Parameters: | time – return the time unit type when set to True |
Returns: | Linear/length unit type, angular/rotation unit type and time unit type |
Examples
linear, angular = get_units()
linear, angular, time = get_units(with_time=True)Waypoints are defined either as joint configuration, as list of joint positions, or as a robot pose with location in Cartesian coordinates XYZ and orientation in Euler angles ABC. Robot poses furthermore relate to a frame from the world origin, usually located at the robot base. If no frame is active or specified with the waypoint, reference to the world origin is assumed.
Global waypoints are waypoints that can be reused between programs. These waypoints are referenced by name inside the TRPL. Contrary, local waypoints are defined in the beginning of a robot program as Python variables.