Overview
Python in Synthiam ARC
Python, known for its simplicity and wide ecosystem, is fully integrated into Synthiam ARC, a powerful platform for robot programming and automation. ARC combines a user-friendly interface with advanced robotics tools for hobbyists and professionals alike.
By offering Python as a language option, ARC lets you use clear syntax and popular libraries to implement complex behaviors, algorithms, and integrations. This combination makes it easier to develop dynamic, intelligent, and responsive robots while keeping the platform accessible and flexible.
Python version: ARC uses the Python 3 compiler.
Additional Python Modules
Additional Python module files (*.py) can be installed into your local ARC module folder:
My Documents\ARC\Python Modules
Place custom .py files in this folder to make them available to ARC scripts.
Installing Modules with pip
pip is the standard Python package installer. By default, pip installs packages into the system/user Python site-packages directory, which is different from ARC's module folder. To have pip install directly into ARC's Python Modules folder, configure pip's default target in a pip configuration file.
pip configuration file locations
- Unix / macOS:
$HOME/.pip/pip.conf - Windows:
%HOME%\pip\pip.ini(typicallyC:\Users\<username>\pip\pip.ini)
Steps to configure pip for ARC
- Create the pip directory if it does not exist (for example,
C:\Users\Bob\pip). - Create or edit
pip.ini(Windows) orpip.conf(Unix/macOS) and set the default target to ARC's Python Modules folder.
[global] target=C:\Users\Bob\My Documents\ARC\Python Modules
C:\Users\Bob\My Documents\ARC\Python Modules with your actual ARC Python Modules path.ARC Python Helper Classes
In addition to Python's standard libraries, ARC exposes several helper classes and methods for robot control, sensor access, OS interaction, and more. You can use the editor's intellisense to discover available ARC classes and methods.
Tip: Enable intellisense in the ARC editor, type a class name, press the period (.) and browse available methods.
Root Commands (Global Helper Functions)
Root commands are global functions provided by ARC. They are not methods of a specific class and are useful for accessing ARC variables, sending commands to controls and other robot skills, and printing to the ARC console.
getVar(variableName)
Retrieve a value from ARC's public global variable storage. Robot skills publish these variables (for example, Camera, Auto Position, Speech Recognition, etc.).
- variableName — string name of the global variable (for example, "$Direction").
- returns — value of the global variable.
// Get the current direction the robot is moving
var direction = getVar("$Direction")
setVar(variableName, value)
Store a value in ARC's public global variable storage so other robot skills or scripts can access it with getVar().
- variableName — string name of the global variable.
- value — value to store (string, number, boolean, etc.).
// Set a value of 5 to be accessible by other robot skills
setVar("$MyValue", 5)
setVarObject(variableName, value)
Store an object in ARC's public variable storage without translation. Use this to pass entire objects such as functions, classes, or multidimensional arrays between robot skills. See the variable picker documentation for more details.
- variableName — string name of the global variable.
- value — object to store (array, object, function, etc.).
// Set the multidimensional array to be accessible by other robot skills
x = [[0, 1, 2], [3, 4, 5]]
setVarObject("$MyValue", x)
varExists(variableName)
Check whether a given global variable exists in ARC's public storage.
- variableName — string name of the global variable.
- returns — boolean true/false indicating existence.
// Print whether the variable exists
print(varExists("$MyValue"))
print(txt)
Write the given value to the ARC console output.
- txt — value or data to print (string, number, variable, etc.).
// Print a string to the console output
print("Hello World")
sleep(timeMs)
Pause script execution for the specified number of milliseconds.
- timeMs — time in milliseconds to pause.
// Print a string, pause for 5 seconds, and print another string
print("Hello")
sleep(5000)
print(" World")
sleepRandom(minTimeMs, maxTimeMs)
Pause execution for a random number of milliseconds between the minimum and maximum values.
- minTimeMs — minimum pause time in milliseconds.
- maxTimeMs — maximum pause time in milliseconds.
// Print a string, pause for a random time between 1 and 5 seconds, then print another string
print("Hello")
sleepRandom(1000, 5000)
print(" World")
controlCommand(controlName, command, [parameters])
Send a command to a named control with optional parameters. Use the ARC cheat sheet or control interrogation to view supported commands for controls in your project.
- controlName — the name of the control (for example, "Camera").
- command — command string the control understands (for example, "StartCamera").
- parameters — optional parameters for the command.
// Start the camera control
controlCommand("Camera", "StartCamera")
print("Camera has started")
showControl(controlName)
Display the specified user interface control and add it to the display stack.
// Show the camera control
showControl("Camera")
closeControl(controlName)
Close the specified control on the interface and return to the previous control in the display stack.
// Close the current control closeControl()
Variables
Python variables are local to each script engine namespace. A variable created in one script engine (for example, the Camera control) is not automatically available in another script engine (for example, the WiiMote control).
To share data across robot skills and compilers, use ARC's public/global variable manager via setVar, setVarObject, and getVar.
Python Constants (Predefined)
ARC defines a set of constants that are available throughout the Python environment. These constants are numeric and do not require quotes when referenced. Common constants include:
D0 ... D23
V0 ... V99
ADC0 ... ADC7
Note: Numeric constants may be written with or without quotes, but string values must be quoted.