planning_configuration.py 5.35 KB
Newer Older
1 2
"""
    schemas: configuration sent to Autonomy Engine (i.e. during an emergency,
3
    if a platform needs to be removed from the mission planning)
4 5
"""

6
emergency_schema = {
7 8
    "type": "object",
    "properties": {
9 10 11
        "safe_command": {
            "type": "string",
            "enum": ["go_home", "abort_now", "stop_mission"],
12 13
            "description": "Command/Action that is native to respective"
            + " partner's platform/C2",
14 15 16
            "example": "go_home",
        },
        "latitude_waypoint": {
17
            "type": "number",
18
            "format": "float",
19
            "description": "X-coordinate safe place for respective platform",
20
            "example": -7.432,
21
        },
22
        "longitude_waypoint": {
23
            "type": "number",
24
            "format": "float",
25
            "description": "Y-coordinate safe place for respective platform",
26
            "example": 50.365,
27
        },
28
        "target_depth": {
29
            "type": "number",
30
            "format": "float",
31
            "description": "Z-coordinate safe place for respective platform"
32 33 34 35 36 37
            + " . If platform to NOT stay at depth, key in `0.0`",
            "example": 10,
        },
        "additional_data": {
            "description": "Any addition fields/data to be added here",
            "example": {},
38
        },
39
    },
40
    "required": ["latitude_waypoint", "longitude_waypoint", "target_depth"],
41
}
42

43

44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
platform_schema = {
    "type": "object",
    "properties": {
        "platform_ID": {
            "type": "integer",
            "description": "Identifier for platform",
            "example": 23,
        },
        "serial": {
            "type": "string",
            "description": "platform serial number",
            "example": "reav-60",
        },
        "model": {
            "type": "string",
            "example": "reav",
        },
61 62 63
        "emergency": emergency_schema,
        "min_altitude": {
            "type": "number",
64
            "format": "float",
65 66 67 68 69
            "description": "Minimum altitude set for squad.",
            "example": 15.2,
        },
        "min_velocity": {
            "type": "number",
70
            "format": "float",
71 72 73 74 75
            "description": "Minimum velocity set for squad.",
            "example": 0.1,
        },
        "max_velocity": {
            "type": "number",
76
            "format": "float",
77 78 79
            "description": "Maximum altitude set for squad.",
            "example": 0.9,
        },
80
        "additional_specs": {
81 82 83
            "description": "Any addition fields/data to be added here",
            "example": {"swath_width": 10.0, "scan_type": "DVL"},
        },
84
    },
85 86 87 88 89 90 91 92 93
    "required": [
        "platform_ID",
        "serial",
        "model",
        "emergency",
        "min_altitude",
        "min_velocity",
        "max_velocity",
    ],
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
}

region_schema = {
    "type": "object",
    "properties": {
        "geometry_coordinates": {
            "type": "array",  # TODO: Check if config defn is right.
            "example": [
                [
                    [-4.187143188645706, 50.37072283932642],
                    [-4.202697005964865, 50.368816892405874],
                    [-4.203156724702808, 50.365640144076906],
                    [-4.19449868846155, 50.362267670845654],
                ]
            ],
        },
110
    },
111 112 113
    "description": "Using GEOJSON, exact 4-point region (rectangle shaped)",
    "required": ["geometry_coordinates"],
}
114

115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
squad_metadata_schema = {
    "type": "object",
    "properties": {
        "squad_ID": {
            "type": "integer",
            "description": "Identifier of given squad",
            "example": 23,
        },
        "no_of_platforms": {
            "type": "integer",
            "description": "Number of platforms",
            "example": 3,
        },
        "platforms": {
            "type": "array",
            "items": platform_schema,
            "description": "Squad consists of these platforms",
        },
        "squad_mission_type": {
            "type": "string",
            "enum": ["tracking", "survey", "inspection"],
            "description": "Mission of given squad: `tracking`, `survey`"
            + ", `inspection`",
            "example": "survey",
        },
        "squad_state": {
            "type": "string",
            "description": "In execution, Waiting.. <define further>",
            "example": False,
        },
        "region_of_interest": region_schema,
    },
    "required": [
        "squad_ID",
        "no_of_platforms",
        "platforms",
        "squad_mission_type",
        "squad_state",
    ],
}
155

156 157 158
planning_configuration_schema = {
    "type": "object",
    "properties": {
159 160 161 162 163
        "message_type": {
            "type": "string",
            "description": "Type of message",
            "example": "planning_configuration",
        },
164
        "planning_config_ID": {
165 166
            "type": "integer",
            "description": "Unique identifier tagged to version of this"
167
            + " configuration plan",
168 169
            "example": 3,
        },
170 171 172 173 174
        "exclusion_zones": {
            "type": "array",
            "items": region_schema,
            "description": "Exclusion zones for all platforms",
        },
175 176 177 178
        "squads": {
            "type": "array",
            "items": squad_metadata_schema,
        },
179
    },
180
    "required": [
181
        "message_type",
182
        "planning_config_ID",
183 184 185
        "squads",
        "exclusion_zones",
    ],
186
}