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


9 10 11 12 13
region_schema = api.model(
    "RegionSchema",
    {
        "region": fields.Raw(
            required=True,
14 15
            description="Using GEOJSON, exact region of interest in rectangle"
            + " format polygon",
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
            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",
                        },
                    }
                ],
            },
        ),
    },
)

40 41 42 43 44 45
squad_metadata_schema = api.model(
    "SquadMetadataSchema",
    {
        "squad_ID": fields.Integer(
            required=True,
            description="Identifier of given squad",
46
            example=23,
47
        ),
48
        "no_of_platforms": fields.Integer(
49
            required=True,
50 51
            description="Number of platforms",
            example=3,
52
        ),
53 54
        "platforms": fields.List(
            fields.Nested(platform_schema),
55
            required=True,
56
            description="Squad consists of these platforms",
57 58 59
        ),
        "squad_mission_type": fields.String(
            required=True,
60 61
            description="Mission of given squad: `tracking`, `survey`"
            + ", `inspection`",
62 63 64 65 66 67 68
            example="survey",
        ),
        "squad_state": fields.Boolean(
            required=True,
            description="In execution, Waiting.. <define further>",
            example=False,
        ),
69 70 71 72 73 74 75 76 77 78
        "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.",
        ),
79 80 81
    },
)

82 83 84

planning_configuration_schema = api.model(
    "PlanningConfigurationSchema",
85 86
    {
        "message": fields.Nested(
87
            full_message_schema,
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
            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",
        ),
    },
)