STorM32 Scripts

From STorM32-BGC Wiki V1
Revision as of 14:27, 15 May 2015 by OlliW (talk | contribs)
Jump to navigation Jump to search

by OlliW, descriptions refer to firmware v0.77a and later

With firmware version v0.51 the possibility of downloading scripts to the STorM32 controller, which are then executed online, without connection to a PC, has been introduced. It allows you to programmatically affect the behavior of the controller in order to achieve user specific needs and tasks with unprecedented flexibility. The STorM32 controller was the first of its kind to offer this innovative feature, which was then later adopted by other controllers.

The on-board scripts bring great new possibilities, but also allow us to do nonsense and to confuse the controller. So, it needs some understanding of the user. This article gives hence also some background, but mainly presents examples.

Overview of Script Types

It is important to not confuse the STorM32's on-board scripts with other types of scripts, thus a short overview:

  • On-board Scripts: These scripts are downloaded and stored into the controller, and are executed permanently by the controller. They are programmed by the user via the GUI's [Scripts] tab.
  • Motion Control Scripts: The GUI has also incorporated a dedicated Motion Control processor, which can be accessed via the [Motion Control Tool] in the [Tools] menu. These scripts are executed on the PC, allowing us to send commands to the STorM32 controller via e.g. the USB, Bluetooth, or any other serial connection between the PC and the controller. The Motion Control scripts are essentially Perl scripts, with some convenience functions added.
  • Mission Planner Scripts: The ArduPilot's Mission Planner allows to run Python scripts, which, akin to the STorM32 Motion Control scripts, are executed on the PC, sending messages to the autopilot.

For all these scripts, the source code is stored in plain ASCII text files (and could hence be edited by any text editor), but which file is which script type can be determined from the default file extension:

.scr = STorM32 on-board script
.mcs = STorM32 Motion Control script
.py  = Mission Planner Python script

When using the respective tools for handling the scripts, only the correct scripts, i.e. files with the correct file extension should be accessible.

This article focuses exclusively on the on-board scripts in the following.

Technical Background

Since the code space on the STorM32 controller is very limited (currently only 128 bytes are available in total for the scripts), and especially for performance reasons the script is stored in the controller as some binary pseudo code.

The workflow is thus such, that the scripts written in the STorM32 on-board scripting language are translated into the pseudo code with a home-brewed compiler, which is integrated into the GUI. The pseudo code is then stored into the STorM32 controller board with each [Write]. The pseudo code is permanently executed online by the STorM32 controller with the help of a pseudo code processor.

STorM32 on-board Scripting Language

The on-board scripting language has a relatively rich set of commands, which allow you to modify the controllers behavior upon inputs, as well as to control the camera for motion control.

CASE#DEFAULT
CASE#1
CASE#2
CASE#3
STOP
REPEAT
SET parametername(string) value(int)
SETMINMAX parametername(string) minvalue(int) maxvalue(int)
RESTORE
RESTOREALL
WAIT time(int, in 0.1secs) 
SETANGLEPITCH angle(float, in degree°)
SETANGLEROLL angle(float, in degree°)
SETANGLEYAW angle(float, in degree°)
SETANGLE pitchangle(float, in degree°) rollangle(float, in degree°) yawangle(float, in degree°)
SETSTANDBY 0/1
DOCAMERA 0/1/2/3/4
DORECENTER
SETPWM pwmvalue(int)

Examples