top of page
Colored Logo (Tagline).png

Parsing Tutorial

​

Quanomous has two robot files.

Decoder (Quanomous.java) — Usually untouched

Handles:

  • Base64 decoding

  • GZIP decompression

  • JSON parsing

  • Saving/loading files

String jsonText = Quanomous.decode(qrData);

JSONArray commands = Quanomous.parse(jsonText);

You only edit this if you change:

  • Compression

  • Storage

  • File naming

​​

Command Parser (QuanomousCommands.java) — Logic is here

This file:

  • Maps "cmd" → robot action

  • Converts JSON → FTC Commands

Step 1: Register the Command

put("spin", Lambda.unchecked(QuanomousCommands::spin));

The string must match the Blockly "cmd".

Step 2: Create the Handler

public static Command spin(JSONObject obj) {

    double degrees = obj.getDouble("degrees");

    return auto.spin(degrees);

}

​​

​

How Commands Run

JSONArray jsonArray = Quanomous.load(config.quanomous);

 

for (int i = 0; i < jsonArray.length(); i++) {

    JSONObject jsonObject = jsonArray.getJSONObject(i);

    String cmd = jsonObject.getString("cmd");

    group.addCommands(commands.get(cmd).apply(jsonObject));

}

​

  • Commands run in order

  • Each block becomes one command

  • If the command name matches, it executes

​

Each command follows the same schema:

{

  "cmd": "drive",

  "...": "command-specific fields"

}

​

Examples:

{ "cmd": "delay", "seconds": 2 }

{ "cmd": "intake", "spike": 1 }

{ "cmd": "spin", "degrees": 360 }

 

Essentially to add a new block:

  1. Create Blockly block → outputs JSON

  2. Add to toolbox

  3. Add handler in QuanomousCommands

  4. Make sure "cmd" strings match

​

If the JSON matches the parser, it works

​

​

Quanomous - Visual Auto Programming for FTC

built with love by FTC team #11206, Devildogs

bottom of page