Google Speech Recognition icon Google Speech Recognition — Google Speech for ARC: cloud speech recognition with waveform, configurable response scripts and PandoraBot support Try it →
 

Index

This section explains how to write scripts in ARCx: the short programs that tie robot skills together and give a robot its own behaviours. It covers the editor every script is written in, and the three languages you can write them in, Blockly, JavaScript and Python, with a page for every command and every block.

Where to find it: scripts are written wherever a robot skill shows a script button, and on Top bar → Workspaces → Script and Top bar → Workspaces → Blockly


Contents

  1. What is in this section
  2. Scripting
  3. Script Editor
  4. Blockly
  5. JavaScript
  6. Python
  7. Where to start

What is in this section

Page What you will find
Scripting The overview: what scripts are, where they live in a project, global variables, control commands, port names, how scripts run, and which language to choose.
Script Editor The editor every script opens in: the toolbar, the views down the left, suggestions as you type, the console, the problems list, saving and keyboard shortcuts.
Blockly Programming by snapping blocks together, plus a page for each of the 24 categories of the block toolbox.
JavaScript The JavaScript language in ARCx, plus a page for each group of commands.
Python The Python language in ARCx, plus a page for each group of commands.

Scripting

The Scripting page is the place to begin. It explains what a script is and where scripts are kept: in the Script, Script Collection and Script Scheduler robot skills, in the script fields of other robot skills, in the project's startup script and in Custom UI widgets. It introduces the ideas every language shares:

  • Global variables, the values every script and robot skill in ARCx can read and write.
  • Control commands, which ask a robot skill to do something, the same as clicking a button on it.
  • Port names such as d0, v0 and adc0.
  • How scripts run: one at a time per robot skill, how to stop them, and the Script Monitor.

It ends with advice on choosing a language.

Script Editor

Every script in ARCx, in any language, is written in the same editor. The Script Editor page is a tour of it, with screenshots:

  • Opening it from a robot skill's script button, or as Workspaces → Script.
  • The toolbar: choosing the language, Run, Stop, picking a control command, Panic, Discard and Save & Close.
  • The views down the left: Control Commands, the ARCx API, Snippets, Variables, Ports, Project Notes, the AI Assistant, a camera view, Settings and Help.
  • Writing code with suggestions, parameter hints and syntax checking.
  • The console, the one-line prompt under it, and the Problems list.
  • Saving, and every keyboard shortcut.

Blockly

Blockly builds programs from coloured blocks that snap together, with nothing to type. It is the easiest way to start, and every Blockly program becomes JavaScript before it runs.

Page What you will find
Blockly How to build with blocks: adding, connecting and deleting blocks, block shapes, the help on every block, variables, functions, running a program, and reading the JavaScript your blocks make.
Index Every toolbox category and every block in it, on one page.
Logic to Debug One page per toolbox category, in toolbox order. Each block has a picture, what it does, when to use it, an example, tips and the JavaScript it turns into.

JavaScript

JavaScript is the main typed language for ARCx scripts. The editor suggests every ARCx command as you type it.

Page What you will find
JavaScript Your first script, a five minute introduction to the language, how ARCx commands are written, complete examples, what the JavaScript engine does and does not support, and common mistakes.
Index Every group of commands and every command in it, on one page.
Built-in The everyday commands that need no group name: print, sleep, getVar, setVar, controlCommand and more, and the port names.
ADC to Utility One page per group of commands, such as Servo, Movement, Audio and Ping. Each command has what it does, the ways to call it, the values it takes and what it gives back.

Python

Python is the second typed language, for people who know it or prefer its easy-to-read style. It has the same commands as JavaScript, written with a capital first letter.

Page What you will find
Python Your first script, a five minute introduction to the language, how ARCx commands are written in Python, complete examples, what ARCx's Python supports (the standard library, .NET, your own modules), and common mistakes.
Index Every group of commands and every command in it, on one page.
Built-in The everyday commands that need no group name, and the port names.
ADC to Utility One page per group of commands, with what each command does, takes and gives back.

Where to start

  • New to programming: read Scripting, then Blockly, and build your first program.
  • Ready for typed code: read the JavaScript page, and keep its Index open while you write.
  • Already know Python: go to Python, then look commands up in its Index.
  • Looking for one command or block: open the Index of its language and search the page.
  • Getting to know the editor: the Script Editor page shows every part of it.