[
    {
        "id": "27129f80a96ce509",
        "type": "ros2-websocket-server",
        "url": "${ROS2_WEBSOCKET_URL}"
    },
    {
        "id": "2ee38794734c2d27",
        "type": "ui_tab",
        "name": "AVR Mission 1",
        "icon": "dashboard",
        "order": 2,
        "disabled": false,
        "hidden": false
    },
    {
        "id": "4166ed8cf4b1e7d4",
        "type": "ui_group",
        "name": "Main",
        "tab": "2ee38794734c2d27",
        "order": 1,
        "disp": true,
        "width": 12,
        "collapse": false,
        "className": ""
    },
    {
        "id": "6fe657fb81fc95dd",
        "type": "tab",
        "label": "AVR 2024 Mission 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "b2a8e3f87a509c26",
        "type": "ros2-service-call",
        "z": "6fe657fb81fc95dd",
        "server": "27129f80a96ce509",
        "x": 1180,
        "y": 580,
        "wires": [
            [
                "bf3503ed327d1e7d",
                "108712d3a6681a1b"
            ]
        ]
    },
    {
        "id": "658feb1ef2a39742",
        "type": "ros2-subscribe",
        "z": "6fe657fb81fc95dd",
        "server": "27129f80a96ce509",
        "topicname": "/dexi/gpio_input_22",
        "messagetype": "std_msgs/msg/Bool",
        "x": 130,
        "y": 420,
        "wires": [
            [
                "bbcc1ed99243f626"
            ]
        ]
    },
    {
        "id": "af9624919a1b3582",
        "type": "change",
        "z": "6fe657fb81fc95dd",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "payload.data",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 360,
        "y": 460,
        "wires": [
            [
                "eb6dda84f6eda544",
                "4581b25ed72a3f10"
            ]
        ]
    },
    {
        "id": "eb6dda84f6eda544",
        "type": "ui_led",
        "z": "6fe657fb81fc95dd",
        "order": 3,
        "group": "4166ed8cf4b1e7d4",
        "width": 6,
        "height": 5,
        "label": "",
        "labelPlacement": "left",
        "labelAlignment": "left",
        "colorForValue": [
            {
                "color": "#ff0000",
                "value": "false",
                "valueType": "bool"
            },
            {
                "color": "#008000",
                "value": "true",
                "valueType": "bool"
            }
        ],
        "allowColorForValueInMessage": false,
        "shape": "circle",
        "showGlow": true,
        "name": "",
        "x": 470,
        "y": 400,
        "wires": []
    },
    {
        "id": "0543bde3e74d88a0",
        "type": "led",
        "z": "6fe657fb81fc95dd",
        "name": "White LED",
        "color": "white",
        "x": 830,
        "y": 400,
        "wires": [
            [
                "b2a8e3f87a509c26"
            ]
        ]
    },
    {
        "id": "4581b25ed72a3f10",
        "type": "switch",
        "z": "6fe657fb81fc95dd",
        "name": "toggle white",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "true"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 570,
        "y": 480,
        "wires": [
            [
                "0543bde3e74d88a0",
                "0ff4f35e8cb0bbea"
            ]
        ]
    },
    {
        "id": "c6b9086dbb472900",
        "type": "led",
        "z": "6fe657fb81fc95dd",
        "name": "Black LED (off)",
        "color": "black",
        "x": 1020,
        "y": 280,
        "wires": [
            [
                "d1a33d93bc76c389"
            ]
        ]
    },
    {
        "id": "9d2d8060d837691b",
        "type": "ros2-subscribe",
        "z": "6fe657fb81fc95dd",
        "server": "27129f80a96ce509",
        "topicname": "/detections",
        "messagetype": "apriltag_msgs/msg/AprilTagDetectionArray",
        "x": 120,
        "y": 800,
        "wires": [
            [
                "2414f9d3f6e4223b"
            ]
        ]
    },
    {
        "id": "2bf0733819afc97a",
        "type": "function",
        "z": "6fe657fb81fc95dd",
        "name": "get april tag id",
        "func": "if (msg.payload.detections.length > 0) {\n    msg.payload = msg.payload.detections[0].id\n    flow.set(\"april_tag_detected\", true)\n} else {\n    msg.payload = \"None\"\n}\n\nreturn msg",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 360,
        "y": 800,
        "wires": [
            [
                "263c22771723c3b4",
                "a94951e69f6804d8"
            ]
        ]
    },
    {
        "id": "263c22771723c3b4",
        "type": "switch",
        "z": "6fe657fb81fc95dd",
        "name": "set led color",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "1",
                "vt": "num"
            },
            {
                "t": "eq",
                "v": "2",
                "vt": "num"
            },
            {
                "t": "eq",
                "v": "3",
                "vt": "num"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 3,
        "x": 550,
        "y": 880,
        "wires": [
            [
                "be2c892197ca3898"
            ],
            [
                "f819e55ec4b66bac"
            ],
            [
                "94c5301511da52db"
            ]
        ]
    },
    {
        "id": "7d43fd5f8bd9c45c",
        "type": "inject",
        "z": "6fe657fb81fc95dd",
        "name": "black",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 830,
        "y": 280,
        "wires": [
            [
                "c6b9086dbb472900"
            ]
        ]
    },
    {
        "id": "4943df094ae6b8c7",
        "type": "inject",
        "z": "6fe657fb81fc95dd",
        "name": "white",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 590,
        "y": 340,
        "wires": [
            [
                "0543bde3e74d88a0"
            ]
        ]
    },
    {
        "id": "be2c892197ca3898",
        "type": "led",
        "z": "6fe657fb81fc95dd",
        "name": "Red LED",
        "color": "red",
        "x": 880,
        "y": 840,
        "wires": [
            [
                "b2a8e3f87a509c26"
            ]
        ]
    },
    {
        "id": "f819e55ec4b66bac",
        "type": "led",
        "z": "6fe657fb81fc95dd",
        "name": "Blue LED",
        "color": "blue",
        "x": 880,
        "y": 900,
        "wires": [
            [
                "b2a8e3f87a509c26"
            ]
        ]
    },
    {
        "id": "94c5301511da52db",
        "type": "led",
        "z": "6fe657fb81fc95dd",
        "name": "Yellow LED",
        "color": "yellow",
        "x": 890,
        "y": 960,
        "wires": [
            [
                "b2a8e3f87a509c26"
            ]
        ]
    },
    {
        "id": "2414f9d3f6e4223b",
        "type": "delay",
        "z": "6fe657fb81fc95dd",
        "name": "",
        "pauseType": "rate",
        "timeout": "5",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": true,
        "allowrate": false,
        "outputs": 1,
        "x": 150,
        "y": 920,
        "wires": [
            [
                "790290dee15b5052"
            ]
        ]
    },
    {
        "id": "a94951e69f6804d8",
        "type": "ui_text",
        "z": "6fe657fb81fc95dd",
        "group": "4166ed8cf4b1e7d4",
        "order": 13,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "April Tag ID",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "className": "",
        "style": false,
        "font": "",
        "fontSize": 16,
        "color": "#000000",
        "x": 610,
        "y": 760,
        "wires": []
    },
    {
        "id": "6681b507c333bbd7",
        "type": "comment",
        "z": "6fe657fb81fc95dd",
        "name": "April Tag detection logic",
        "info": "",
        "x": 160,
        "y": 700,
        "wires": []
    },
    {
        "id": "0d0de2296a5bcb2a",
        "type": "comment",
        "z": "6fe657fb81fc95dd",
        "name": "Infrared Beam detection logic",
        "info": "",
        "x": 160,
        "y": 320,
        "wires": []
    },
    {
        "id": "0ff4f35e8cb0bbea",
        "type": "change",
        "z": "6fe657fb81fc95dd",
        "name": "beam detected true",
        "rules": [
            {
                "t": "set",
                "p": "beam_detected",
                "pt": "flow",
                "to": "true",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 890,
        "y": 480,
        "wires": [
            []
        ]
    },
    {
        "id": "92b68e1b6ee8c07d",
        "type": "comment",
        "z": "6fe657fb81fc95dd",
        "name": "IR beam must be detected first",
        "info": "",
        "x": 190,
        "y": 60,
        "wires": []
    },
    {
        "id": "e2647594e160d017",
        "type": "comment",
        "z": "6fe657fb81fc95dd",
        "name": "Set global variable and go into april tag detection mode for 5 seconds",
        "info": "",
        "x": 630,
        "y": 160,
        "wires": []
    },
    {
        "id": "b4960165480cec74",
        "type": "function",
        "z": "6fe657fb81fc95dd",
        "name": "initialize global vars",
        "func": "",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "flow.set(\"beam_detected\", false)\nflow.set(\"april_tag_detected\", false)\n",
        "finalize": "",
        "libs": [],
        "x": 150,
        "y": 200,
        "wires": [
            []
        ]
    },
    {
        "id": "108712d3a6681a1b",
        "type": "delay",
        "z": "6fe657fb81fc95dd",
        "name": "",
        "pauseType": "delay",
        "timeout": "10",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "allowrate": false,
        "outputs": 1,
        "x": 1380,
        "y": 580,
        "wires": [
            [
                "f029b596f71c92c6",
                "c6b9086dbb472900"
            ]
        ]
    },
    {
        "id": "dba3d2e7d18df143",
        "type": "inject",
        "z": "6fe657fb81fc95dd",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 680,
        "y": 1040,
        "wires": [
            [
                "94c5301511da52db"
            ]
        ]
    },
    {
        "id": "bbcc1ed99243f626",
        "type": "function",
        "z": "6fe657fb81fc95dd",
        "name": "check beam and april tag variables",
        "func": "if (flow.get(\"beam_detected\") == false && flow.get(\"april_tag_detected\") == false) {\n    return msg\n}",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 300,
        "y": 600,
        "wires": [
            [
                "af9624919a1b3582"
            ]
        ]
    },
    {
        "id": "bf3503ed327d1e7d",
        "type": "debug",
        "z": "6fe657fb81fc95dd",
        "name": "debug 6",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1420,
        "y": 760,
        "wires": []
    },
    {
        "id": "f029b596f71c92c6",
        "type": "function",
        "z": "6fe657fb81fc95dd",
        "name": "reset flow vars",
        "func": "flow.set(\"beam_detected\", false)\nflow.set(\"april_tag_detected\", false)\n",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1620,
        "y": 580,
        "wires": [
            []
        ]
    },
    {
        "id": "25fe1833b6c28945",
        "type": "comment",
        "z": "6fe657fb81fc95dd",
        "name": "IR beam must be detected first",
        "info": "",
        "x": 190,
        "y": 120,
        "wires": []
    },
    {
        "id": "790290dee15b5052",
        "type": "function",
        "z": "6fe657fb81fc95dd",
        "name": "beam is detected so proceed",
        "func": "if (flow.get(\"beam_detected\")) {\n    return msg\n}",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 360,
        "y": 1040,
        "wires": [
            [
                "2bf0733819afc97a"
            ]
        ]
    },
    {
        "id": "437f1ee8eb899041",
        "type": "inject",
        "z": "6fe657fb81fc95dd",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 120,
        "y": 1140,
        "wires": [
            [
                "f61fb237ec372e64"
            ]
        ]
    },
    {
        "id": "f61fb237ec372e64",
        "type": "function",
        "z": "6fe657fb81fc95dd",
        "name": "print flow vars",
        "func": "flow.keys().forEach((key) => {\n    console.log(`${key} - ${flow.get(key)}`)\n})",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 340,
        "y": 1160,
        "wires": [
            []
        ]
    },
    {
        "id": "de5180721d017b10",
        "type": "comment",
        "z": "6fe657fb81fc95dd",
        "name": "turn led off",
        "info": "",
        "x": 840,
        "y": 240,
        "wires": []
    },
    {
        "id": "d1a33d93bc76c389",
        "type": "ros2-service-call",
        "z": "6fe657fb81fc95dd",
        "server": "27129f80a96ce509",
        "x": 1240,
        "y": 280,
        "wires": [
            []
        ]
    }
]
