Overview

Python, renowned for its simplicity and versatility, is seamlessly integrated into Synthiam ARC, a powerful platform for robot programming and automation. Synthiam ARC stands out in the realm of robotics for its user-friendly interface and comprehensive suite of tools, catering to both hobbyists and professionals. The integration of Python within this platform is a testament to its commitment to flexibility and accessibility. Users can leverage Python's straightforward syntax and extensive libraries to develop complex robotic behaviors, algorithms, and integrations. This not only broadens the scope of what can be achieved in robotic programming but also makes Synthiam ARC a more inclusive and adaptable tool. By including Python as one of the language options, Synthiam ARC empowers users to harness the full potential of both the language's robust programming capabilities and the platform's advanced robotic functionalities. This synergy between Python and Synthiam ARC facilitates the creation of more dynamic, intelligent, and responsive robots, paving the way for innovative advancements in the field of robotics.

Python Version: ARC uses the Python 3 compiler.


Additional Modules

Additional Python modules (py files) can be installed in the user's My Documents\ARC\Python Modules folder.


Using PIP

PIP is a python installer to install python modules. By default, it will install the modules in Windows in a different folder than ARC uses. You can change the PIP install folder by editing the INI file. You will need to specify the default install location within a pip.ini file, which, is usually located as follows...

  • On Unix and Mac OS X the configuration file is: $HOME/.pip/pip.conf
  • On Windows, the configuration file is: %HOME%\pip\pip.ini
  1. The %HOME% is located in C:\Users\Bob on windows assuming your name is Bob. So, it would be C:\Users\\pip\pip.ini
  2. You may have to create the pip.ini file when you find your pip directory. Within your pip.ini or pip.config you will then need to put (assuming you're on windows) something like...

    [global]
    target=C:\Users\Bob\My Documents\ARC\Python Modules
    Except that you would replace "C:\Users\Bob\My Documents\ARC\Python Modules" with whatever path contains the Synthiam ARC Python folder in your My Documents.
    
    


Python Functions

 

In addition to the built-in Python libraries, ARC includes several classes with methods to control your robot, read sensors, interact with the operating system, and more. To view built-in ARC Python methods…

 

1)     Check the intellisense checkbox.

 

2)     Type one of the following class names, press ‘.’, and scroll through the available methods.

 

ADC  – EZB analog to digital converter functions

Audio  – streaming audio functions

COM  – local serial COM port functions

Digital  – EZB digital I/O functions

EZB  – EZB-specific functions for getting voltage and checking the connection, etc.

File  – writing and reading local files

I2C  – EZB I2C helper functions

Movement  – movement panel control of directions

Net  – networking functions

Ping  – EZB ultrasonic distance sensor functions

PWM  – EZB pulse width modulation on digital I/O pins

Servo  – EZB servo movement functions

UART  – EZB hardware UART and software Serial functions

Utility  – various utility functions

Supported Python Commands

The Python interpreter has several built-in functions that are available. This will be documented in the future.

 

 

Root Commands

Root commands do not belong to a class and are included for convenience to access global variables and send commands to other robot skills.

 

 

getVar( variableName )

Retrieves the value from the Arc’s public global variable storage. Robot skill controls publish these variables, such as the Camera, Auto Position, Speech Recognition, etc.

 

{variableName} - The name of the global variable as a string

{return} – The value of the global variable

 

Example:

// Get the current direction the robot is moving

var direction = getVar(“$Direction”)

 

 

setVar( variableName, value )

Sets the value from Arc’s public global variable storage. This allows the variable to be available to other robot skills or scripts using getVar().

 

{variableName} - The name of the global variable as a string

{value} – The value that you wish to store in the global variable

 

Example:

// Set a value of 5 to be accessible by other robot skills

setVar(“$MyValue”, 5)

 

 

setVarObject( variableName, value )

Sets the value from Arc’s public global variable storage of the object. This allows the variable to be available to other robot skills or scripts using getVar(). (Read More). This differs from setVar() because it sets the value as an object without translation. So you can pass entire objects, such as functions, classes, or multidimensional arrays.

 

{variableName} - The name of the global variable as a string

{value} – The object value that you wish to store in the global variable

 

Example:

// Set the multidimensional array to be accessible by other robot skills using getVar()

x = [ [0, 1, 2], [3, 4, 5] ];

setVar(“$MyValue”, x);

 

 

varExists( variableName )

Check if the global variable exists.

 

{variableName} - The name of the global variable as a string

{return} – true/false Boolean if the variable exists

 

Example:

// print if the variable exists

print(varExists(“$MyValue”))

 

 

print( txt )

Writes the value to the console output.

 

{txt} – The value/data to print

 

Example:

// Print a string to the console output

print(“Hello World”)

 

 

sleep( timeMs )

Pauses the execution of the program for the specified time in milliseconds

 

{timeMS} – The time to pause

 

Example:

// Print a string, pause for 5 seconds, and print another string

print(“Hello”)

sleep(5000)

print(“ World”)

 

 

sleepRandom( minTimeMS, maxTimeMS )

Pauses the program's execution for a random millisecond between the min and max.

 

{minTimeMS} – The minimum time to pause

{maxTimeMS} – The maximum time to pause

 

Example:

// Print a string, pause for random time, and print another string

print(“Hello”)

sleepRandom(1000, 5000)

print(“ World”)

 

 

controlCommand( controlName, command, [parameters] )

Sends the command to the control name with the optional parameters. The cheat sheet displays all of the interrogated control commands supported by robot skills in the project.

 

 

Example:

// Start the camera

controlCommand(“Camera”, “StartCamera”)

print(“Camera has started”)

 

 

showControl( controlName )

Shows the user interface control. This also adds the control to the stack, which can be

 

 

Example:

// Start the camera

controlCommand(“Camera”, “StartCamera”)

print(“Camera has started”)

 

 

closeControl( controlName )

Closes the control on the user interface and displays the previous control in the display stack

 

 

Example:

CloseControl();

 

 

 

Variables

Python variables are private to the namespace of each script engine. That means a variable created in a Python script does not exist in other Python scripts. If you have variables declared in the Python of the Camera control, the variables are not accessible in the Python of the WiiMote control.

 

Public/global variables use ARC’s variable manager, which is global across all robot skills and compilers. Public variables are accessed using setVar or getVar


Python Constants

A constant is a global variable available throughout the Python environment within ARC. The variable value cannot be changed and is declared behind the scenes when your code is executed. These constant variables are also unique because they do not need to be surrounded by "quotes" when referenced. This is because their actual value is a number. Numbers (such as integers and decimal floats) do not need to be surrounded by quotes (although you may surround them with quotes if you prefer). Only string values need to be wrapped in quotes.

D0 ... D23
V0 ... V99
ADC0 ... ADC7