Overview
ARC uses the Python 3 compiler.
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 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 controls.
getVar(
variableName )
Retrieves
the value from the Arc’s public global variable storage. These are variables
that are published by robot skill controls, 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 of Arc’s public global variable storage. This allows the variable to
be available to other controls or other scripts by 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 controls
setVar(“$MyValue”,
5)
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
execution of the program for a random milliseconds 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 controls 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 controls and compilers. Public variables are accessed
using setVar or getVar