4.11. Custom exporters

In the software is it possible to also create your own exporters. You can find that in the menu “Show” and press “Export …”.

In the Export dialog that appears you can change the type to “Script Exporter”.

Note: if you cannot find the item your license probably doesn’t support this feature. Please contact us to adjust your license.

After selecting the output location you can press “Export” and you will be presented with a dialog asking for the script location. We currently only support “JS” files. The details are explained bellow.

4.11.1. Creating a script

A minimal script will look like:

function executeStep(timestep, droneId, posX, posY, posZ, colorR, colorG, colorB) {
   print(timestep+', '+droneId+', '+posX+', '+posY+', '+posZ+', '+colorR+', '+colorG+', '+colorB);
}

The executeStep function is the only required function that is needed in the script. The function is called for every drone in the show every 250ms (4fps) with it’s position and color.

  • timestep: the time since the start in ms (integer)

  • drone_id: the unique number of the drone (integer)

  • position: the position is given from the middle of the show (in meters).

  • posX: the left-right position of the drone (double)

  • posY: the depth, front-back, of the drone. Lower numbers are more to the front (double)

  • posZ: the height of the drone, inclusive the “above ground”. Zero is ground. (double)

  • color:

  • colorR: value between 0-1 indicating the red component (double)

  • colorG: value between 0-1 indicating the green component (double)

  • colorB: value between 0-1 indicating the blue component (double)

The print function can be used to print data to the output file. This is de default way to export your data.

4.11.2. Configure the script

By providing a configure function you can adjust how the exporter works.

function configure() {
        return {frameRate:10};
}

the function should return an object with the wanted configuration.

Frame rate

By default the frame rate is 4 fps. By providing “frameRate” in the configure function you can adjust this. If a frame rate is not supported it is rounded towards the closest supported frame rate. A warning will get shown if that happens.

Supported frame rates are: 1, 2, 4, 5, 8, 10, 20, 25, 31.25, 40, 50, 62.5 and 100

4.11.3. Extra functionality

init

The init function will be called after the configure function, but before any “executeStep” calls. This is a good position to initialize variables.

finish

This function is called at the end of the execution. Here you can properly end the execution. Or do some post-processing on the data.

print

This function is a global function that can be used to print data to the selected output file.

4.11.4. Example scripts

CSV

The following script will output the show content as a “Comma Seperated Value” file. A new line will get outputed for every drone every 250ms containing the location and color of the drone at that moment.

function init() {
    print('Time, Drone id, Position X, Position Y, Position Z, Color red, Color green, Color blue');
}
function executeStep(timestep, drone_id, posX, posY, posZ, colorR, colorG, colorB) {
    print(timestep+', '+drone_id+', '+posX+', '+posY+', '+posZ+', '+colorR+', '+colorG+', '+colorB);
}

JSON

This script create json output containing a dictionary for every drone containing a list with positions and colors.

var data = {};
function executeStep(timestep, drone_id, posX, posY, posZ, colorR, colorG, colorB) {
        if (!data[drone_id])
                data[drone_id]=[];

        data[drone_id][data[drone_id].length] = {
                pos: [posX, posY, posZ],
                color: [colorR, colorG, colorB]
        };
}
function finish() {
    print(JSON.stringify(data));
}