platform_status.py 5.54 KB
Newer Older
1
"""
2
    schema: platform-specific decoded status message
3
"""
4 5
sensor_schema = {
    "type": "object",
6 7
    "description": "Scanning sensor on platform available"
    + " to be controlled by  the Autonomy Engine",
8 9 10 11 12 13
    "properties": {
        "sensor_serial": {
            "type": "string",
            "description": "serial number of sensor",
            "example": "mbes-002a",
        },
14
        "sensor_on": {
15 16 17 18 19 20 21 22 23 24 25 26
            "type": "boolean",
            "description": "Sensor switched on (True) or off (False)",
            "example": True,
        },
        "additional_data": {
            "type": "null",
            "description": "Any addition fields/data to be added here",
            "example": {"payload": [1.2, 434]},
        },
    },
    "required": [],
}
27

28
platform_status_message_schema = {
29
    "allOf": [{"$ref": "#/components/schemas/Message"}],
30 31 32 33 34 35 36
    "type": "object",
    "properties": {
        "platform_ID": {
            "type": "integer",
            "description": "Identifier for platform",
            "example": 1,
        },
37 38 39 40 41 42 43
        "status_source": {
            "type": "string",
            "enum": ["usbl", "onboard_platform"],
            "description": "Indicate if this status message is from the"
            + " platform or USBL",
            "example": "usbl",
        },
44
        "platform_timestamp": {
45 46
            "type": "string",
            "format": "date-time",
47 48 49 50 51 52
            "decription": "Timestamp for onboard platform status message",
            "example": "2022-12-21T00:00:00Z",
        },
        "active": {
            "type": "boolean",
            "description": "When a platform is in deployment (executing a"
53
            + " mission plan) this should be True",
54 55 56
            "example": True,
        },
        "platform_state": {
57
            # TODO: Define enum with potential STATES of each platform
58 59
            "type": "string",
            "description": "Current state executed by platform. E.g. "
60
            + "STOP, IDLE, ABORT.",
61 62
            "example": "ABORT",
        },
63
        "autonomy_engine_plan_ID": {
64
            "type": "integer",
65 66
            "description": "Last mission plan ID (according to Autonomy"
            + " Engine's mission plan number sent) executed by platform",
67 68
            "example": 1,
        },
69 70
        "latitude": {
            "type": "number",
71
            "format": "float",
72 73 74 75 76
            "description": "Latitude in decimal degrees.",
            "example": 178.2,
        },
        "longitude": {
            "type": "number",
77
            "format": "float",
78 79 80 81 82
            "description": "Longitude in decimal degrees.",
            "example": -10.122,
        },
        "depth": {
            "type": "number",
83
            "format": "float",
84 85 86 87 88 89
            "description": "Target depth in metres",
            "example": 50,
            "default": 0,
        },
        "altitude": {
            "type": "number",
90
            "format": "float",
91 92 93
            "description": "Target altitude in metres",
            "example": 20,
        },
94 95 96 97 98 99 100 101
        "mission_track_ID": {
            "type": "integer",
            "description": "Track number - stage in mission (e.g. "
            + "4 --> Waypoint 3 to Waypoint 4)",
            "example": 4,
        },
        "mission_action_ID": {
            "type": "integer",
102
            "description": "",  # TODO: Add description
103 104 105 106
            "example": 1,
        },
        "range_to_go": {
            "type": "number",
107
            "format": "float",
108 109 110 111 112
            "description": "Estimated distance to reach next waypoint",
            "example": 124.3,
        },
        "speed_over_ground": {
            "type": "number",
113 114
            "format": "float",
            "description": "",  # TODO: Add description
115 116 117 118
            "example": 124.3,
        },
        "water_current_velocity": {
            "type": "number",
119 120
            "format": "float",
            "description": "",  # TODO: Add description
121 122 123 124
            "example": 124.3,
        },
        "thrust_applied": {
            "type": "number",
125 126
            "format": "float",
            "description": "",  # TODO: Add description
127 128
            "example": 124.3,
        },
129 130
        "heading": {
            "type": "number",
131
            "format": "float",
132 133 134 135
            "description": "Angular distance relative to north, usually 000°"
            + " at north, clockwise through 359°, in degrees",
            "example": 124.3,
        },
136 137 138 139 140 141 142 143
        "health_status": {
            "type": "string",
            "description": "Health status extracted by respective platform "
            + "if any diagnosis is available to check sensors",
            "example": "Warning",
        },
        "localisation_error": {
            "type": "number",
144
            "format": "float",
145 146 147 148 149
            "description": "Localisation error at last USBL update.",
            "example": 0.000129,
        },
        "usbl_fix_seconds_ago": {
            "type": "number",
150
            "format": "float",
151 152 153 154 155
            "description": "USBL Fix received x second ago.",
            "example": 10.0,
        },
        "battery_remaining_capacity": {
            "type": "number",
156
            "format": "float",
157
            "description": "Battery remaining % provided by respective C2",
158 159
            "example": 80.2,
        },
160 161
        "current_pitch": {
            "type": "number",
162
            "format": "float",
163 164 165
            "description": "Current pitch of platform",
            "example": -4.0,
        },
166
        "sensor_config": sensor_schema,
167
    },
168 169
    "required": [
        "platform_ID",
170
        "status_source",
171
        "platform_timestamp",
172 173
        "latitude",
        "longitude",
174 175
    ],
}