planning_configuration.py 6.91 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
# from . import api, full_message_schema, platform_schema
# from flask_restx import fields
7 8


9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
constraints_schema = {
    "type": "object",
    "properties": {
        "min_altitude": {
            "type": "number",
            "description": "Minimum altitude set for squad.",
            "example": 15.2,
        },
        "min_velocity": {
            "type": "number",
            "description": "Minimum velocity set for squad.",
            "example": 0.1,
        },
        "max_velocity": {
            "type": "number",
            "description": "Maximum altitude set for squad.",
            "example": 0.9,
        },
27
    },
28 29
    "required": ["min_altitude", "min_velocity", "max_velocity"],
}
30

31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
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",
        },
        "constraints": constraints_schema,
    },
    "required": ["platform_ID", "serial", "model", "constraints"],
}

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],
                ]
            ],
        },
67
    },
68 69 70
    "description": "Using GEOJSON, exact 4-point region (rectangle shaped)",
    "required": ["geometry_coordinates"],
}
71

72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
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,
        "exclusion_zones": {
            "type": "array",
            "items": region_schema,
            "description": "Exclusion zones per squad.",
        },
    },
    "required": [
        "squad_ID",
        "no_of_platforms",
        "platforms",
        "squad_mission_type",
        "squad_state",
        "exclusion_zones",
    ],
}
118

119 120 121 122 123 124 125
planning_configuration_schema = {
    "allOf": [{"$ref": "#/components/schemas/Message"}],
    "type": "object",
    "properties": {
        "config_ID": {
            "type": "integer",
            "description": "Unique identifier tagged to version of this"
126
            + " configuration plan",
127 128 129 130 131 132
            "example": 3,
        },
        "squads": {
            "type": "array",
            "items": squad_metadata_schema,
        },
133
    },
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231
    "required": ["config_ID", "squads"],
}

# region_schema = api.model(
#     "RegionSchema",
#     {
#         "region": fields.Raw(
#             required=True,
#             description="Using GEOJSON, exact region of interest in rectangle"
#             + " format polygon",
#             example={
#                 "type": "FeatureCollection",
#                 "features": [
#                     {
#                         "type": "Feature",
#                         "properties": {},
#                         "geometry": {
#                             "coordinates": [
#                                 [
#                                     [-4.187143188645706, 50.37072283932642],
#                                     [-4.202697005964865, 50.368816892405874],
#                                     [-4.203156724702808, 50.365640144076906],
#                                     [-4.19449868846155, 50.362267670845654],
#                                 ]
#                             ],
#                             "type": "Polygon",
#                         },
#                     }
#                 ],
#             },
#         ),
#     },
# )

# squad_metadata_schema = api.model(
#     "SquadMetadataSchema",
#     {
#         "squad_ID": fields.Integer(
#             required=True,
#             description="Identifier of given squad",
#             example=23,
#         ),
#         "no_of_platforms": fields.Integer(
#             required=True,
#             description="Number of platforms",
#             example=3,
#         ),
#         "platforms": fields.List(
#             fields.Nested(platform_schema),
#             required=True,
#             description="Squad consists of these platforms",
#         ),
#         "squad_mission_type": fields.String(
#             required=True,
#             description="Mission of given squad: `tracking`, `survey`"
#             + ", `inspection`",
#             example="survey",
#         ),
#         "squad_state": fields.Boolean(
#             required=True,
#             description="In execution, Waiting.. <define further>",
#             example=False,
#         ),
#         "region_of_interest": fields.List(
#             fields.Nested(region_schema),
#             required=False,
#             description="Region of interest and exclusion zones per squad.",
#         ),
#         "exclusion_zones": fields.List(
#             fields.Nested(region_schema),
#             required=True,
#             description="Exclusion zones exclusion zones per squad.",
#         ),
#     },
# )


# planning_configuration_schema = api.model(
#     "PlanningConfigurationSchema",
#     {
#         "message": fields.Nested(
#             full_message_schema,
#             required=True,
#             description="Message header",
#         ),
#         "ID": fields.Integer(
#             required=True,
#             description="Unique identifier tagged to version of this"
#             + " configuration plan",
#             example=3,
#         ),
#         "squads": fields.Nested(
#             squad_metadata_schema,
#             required=False,
#             description="Details of each squad",
#         ),
#     },
# )