Python library function documentation
This document contains the documentation of the functions available in the library files included in the Realtime example python code.
1 Library Files
The library files which can be referenced to when creating new python scripts for the task manager contain valuable functions that allow the user to communicate with the controller and send commands through the RTR Controller.
1.1 PythonCommander
The Python Commander contains a class that talks with the Realtime Controller over socket communication.
The class is initialized by passing the IP address of the Realtime Controller and a port number as arguments
self.cmdr = PythonCommander(self.ip_addr, 9999)
The functions available in the PythonCommander class are summarized in the table below.
Function Name | Description |
---|---|
Reconnect | Deletes all the sockets, creates new ones and reconnects. If an addr and port is specified (both must be), then it'll use the new pair, otherwise it'll use the latest one in cache. |
Setup | Caches the group name and project name |
GetMode | Sends the GetMode command which queries the Realtime Controller's state Returns:
|
BeginOperation | Sends the BeginOperation command which attempts CONFIG -> RUN transition. Returns:
|
EndOperation | Sends the EndOperation command which attempts RUN -> CONFIG transition. Returns:
|
ClearFaults | Sends the ClearFaults command which attempts FAULT -> CONFIG transition. Returns:
|
InitGroup | Sends the InitGroup command with initial workspace. Must call Setup(...) first, or specify both the group_name and project_name args Parameters:
Returns:
|
TerminateGroup | Sends the TerminateGroup command which unloads a deconfliction group. Must call Setup(...) first, or specify the group_name parameter Parameters:
Returns:
|
WaitForMove | Waits for MoveResult to be received Parameters:
Returns:
|
SetInterruptBehavior | Sets the planning parameters. Must call Setup(...) first. Parameters:
Returns:
|
MoveToHub | Sends a Move to Hub command. Must call Setup(...) first. Parameters:
Returns:
|
MoveToPose | Sends a Move to Pose command. Must call Setup(...) first.
Returns:
|
BlindMove | Sends a Blind Move command. Must call Setup(...) first. Parameters:
Returns:
|
OffroadToHub | Sends an Offroad to Hub command. Must call Setup(...) first. Moves robot from off roadmap to specified hub with static collision checking only. Parameters:
Returns:
|
AcquireControl | Sends an Acquire Control command. Must call Setup(...) first. Command to indicate the user is done with an operation that required RTR to release external control of the robot, and the RTR controller should resume control, with the state of the robot in the workspace indicated. Parameters:
Returns:
|
ReleaseControl | Sends a Release Control command. Must call Setup(...) first. Command to indicate the user would like to take temporary control of the robot to get/set IOs, or execute a portion of their robot program that is not suitable for RTR control at this point. Parameters:
Returns:
|
CancelMove | Sends a Cancel Move command. Must call Setup(...) first. This command tells the RTR Motion Planning Server to abort planning and motion for the specified robot, and informs the Motion Planning Server what state the robot is in after the cancellation. Parameters:
Returns:
|
ChangeWorkspace | Sends a Change Workspace command. Must call Setup(...) first. Parameters:
Returns:
|
1.2 CommonOperations
The Common Operations library contains functions that make use of a combination of Python Commander sequence commands for common operations such as start and finish sequence, putting the robots back on the roadmap and attempting fault recovery.
The functions available in the CommonOperations are summarized in the table below.
Function Name | Description |
---|---|
startup_sequence | This function calls InitGroup for each project in a group. If all InitGroup calls succeed, the Controller is placed in run mode Parameters:
Returns:
|
shutdown | This function takes the controller out of Operation mode and into Config mode. Parameters:
|
put_on_roadmap | This function attempts to put all robots back on the roadmap. Parameters:
Returns:
|
attempt_fault_recovery | This function clears faults on the controller and puts all robots back on the roadmap. It is assumed that all projects in the group have a hub named 'home' or that all projects have a hub with the same name. Parameters:
|
2.3 Python Commander Helper
The Python Commander Helper library communicates with the controler using a REST API.
The functions available in the CommonOperations are summarized in the table below.
Function Name | Description |
---|---|
send_get_request | This function sends a get request to the passed URL extension and returns the response in JSON form Parameters:
Returns:
|
send_put_request | This function sends a put request to the passed URL extension Parameters:
|
get_control_panel_state | This function is called with no arguments and returns the current state of the control panel Returns:
|
get_group_info | This function is called with no arguments and returns a nested dictionary with all the group names. For each group it also returns if the group is loaded and the projects installed in that group. Returns:
|
get_installed_projects | This function is called with no arguments and returns a list of all projects installed on the Controller Returns:
|
put_load_group | This function is passed a group name and attempts to load that group in the Control Panel Parameters:
|
put_unload_group | This function is passed a group name and attempts to unload that group from the Control Panel Parameters:
|
get_project_info | This function is passed project names and returns relevant information about each project. It is easiest to call get_group_info() first, Parameters:
Returns:
|
put_config_mode | This function puts the controller in config mode |
put_teleport_robot | This function teleports a robot to a specified hub. NOTE: the controller must be in config mode to teleport a simulated robot Parameters:
|