platform_status.py 10.5 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 29 30 31 32 33 34 35 36
platform_status_message_schema = {
    "allOf": [{"$ref": "#/components/schemas/Message"}],
    "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 45 46 47 48 49 50 51
        "platform_timestamp": {
            "type": "date-time",
            "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"
52
            + " mission plan) this should be True",
53 54 55
            "example": True,
        },
        "platform_state": {
56
            # TODO: Define dictionary with potential STATES of each platform
57 58
            "type": "string",
            "description": "Current state executed by platform. E.g. "
59
            + "STOP, IDLE, ABORT.",
60 61
            "example": "ABORT",
        },
62
        "autonomy_engine_plan_ID": {
63
            "type": "integer",
64 65
            "description": "Last mission plan ID (according to Autonomy"
            + " Engine's mission plan number sent) executed by platform",
66 67
            "example": 1,
        },
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
        "latitude": {
            "type": "number",
            "description": "Latitude in decimal degrees.",
            "example": 178.2,
        },
        "longitude": {
            "type": "number",
            "description": "Longitude in decimal degrees.",
            "example": -10.122,
        },
        "depth": {
            "type": "number",
            "description": "Target depth in metres",
            "example": 50,
            "default": 0,
        },
        "altitude": {
            "type": "number",
            "description": "Target altitude in metres",
            "example": 20,
        },
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 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
        "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",
            "description": "TODO: add description",
            "example": 1,
        },
        "range_to_go": {
            "type": "number",
            "description": "Estimated distance to reach next waypoint",
            "example": 124.3,
        },
        "speed_over_ground": {
            "type": "number",
            "description": "TODO: add description",
            "example": 124.3,
        },
        "water_current_velocity": {
            "type": "number",
            "description": "TODO: add description",
            "example": 124.3,
        },
        "thrust_applied": {
            "type": "number",
            "description": "TODO: Needs further consideration",
            "example": 124.3,
        },
        "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",
            "description": "Localisation error at last USBL update.",
            "example": 0.000129,
        },
        "usbl_fix_seconds_ago": {
            "type": "number",
            "description": "USBL Fix received x second ago.",
            "example": 10.0,
        },
        "battery_remaining_capacity": {
            "type": "number",
138
            "description": "Battery remaining % provided by respective C2",
139 140
            "example": 80.2,
        },
141 142 143 144 145
        "current_pitch": {
            "type": "number",
            "description": "Current pitch of platform",
            "example": -4.0,
        },
146
        "sensor_config": sensor_schema,
147
    },
148 149
    "required": [
        "platform_ID",
150
        "status_source",
151
        "platform_timestamp",
152 153
        "latitude",
        "longitude",
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 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254
    ],
}

# gps_schema = api.model(
#     "GPS",
#     {
#         "gps_source": fields.Float(  # TODO: TBD with partners
#             required=False,
#             description=(
#                 "Source of gps position. E.g. USBL (external),"
#                 + "platform itself (internal)"
#             ),
#             example="internal",
#         ),
#         "latitude_type": fields.String(
#             required=False,
#             description="",
#             example="",
#         ),
#         "longitude_type": fields.String(
#             required=False,
#             description="",
#             example="",
#         ),
#         "latitude": fields.Float(
#             required=False,
#             description="Latitude in <DEFINE UNITS>",
#             example="",
#         ),
#         "longitude": fields.Float(
#             required=False,
#             description="Longitude in <DEFINE UNITS>",
#             example="",
#         ),
#         "depth": fields.Float(
#             required=False,
#             description="Depth in <DEFINE UNITS>",
#             example="",
#         ),
#         "altitude": fields.Float(
#             required=False,
#             description="Altitude in <DEFINE UNITS>",
#             example="",
#         ),
#         # "gps_fix_seconds_ago"
#     },
# )

# sensor_schema = api.model(
#     "SensorSchema",
#     {
#         "sensor_ID": fields.Integer(
#             required=True,
#             description="unique identifier for platform",
#             example=2,
#         ),
#         "serial": fields.String(
#             required=False,
#             description="serial number of sensor",
#             example="mbes-001",
#         ),
#         "sensor_status": fields.Boolean(
#             required=False,
#             description="Sensor switched on (True) or off (False)",
#             example=True,
#         ),
#         "additional_data": fields.Raw(
#             required=False,
#             description="Any addition fields/data to be added here",
#         ),
#     },
# )

# platform_status_message_schema = api.model(
#     "platformStatusMessage",
#     {
#         "message": fields.Nested(
#             full_message_schema,
#             required=True,
#             description="Message header",
#         ),
#         "platform_ID": fields.Integer(
#             required=True,
#             description="unique identifier for platform",
#             example=1,
#         ),
#         "active": fields.Boolean(
#             required=False,
#             description="When a platform is in deployment (executing a"
#             + " mission plan) this should be True",
#             example=True,
#         ),
#         "platform_state": fields.String(
#             # TODO: Define dictionary with potential STATES of each platform
#             required=False,
#             description="Current state executed by platform. E.g. "
#             + "STOP, IDLE, ABORT.",
#             example="IDLE",
#         ),
#         "autonomy_plan_ID": fields.Integer(
#             required=False,
255 256
#             description="Last mission plan ID (
#             + "according to Autonomy Engine's"
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325
#             + " mission plan number) executed by platform",
#             example=1,
#         ),
#         "mission_track_ID": fields.Integer(
#             required=False,
#             description=(
#                 "Track number - stage in mission (e.g. "
#                 + "4 --> Waypoint 3 to Waypoint 4)"
#             ),
#             example=4,
#         ),
#         "mission_action_ID": fields.Integer(
#             required=False,
#             description="to add description",
#             example=1,
#         ),
#         "range_to_go": fields.Float(
#             required=False,
#             description="Estimated distance to reach next waypoint",
#             example=124.3,
#         ),
#         "speed_over_ground": fields.Float(
#             required=False,
#             description="",
#             example=124.3,
#         ),
#         "water_current_velocity": fields.Float(
#             required=False,
#             description="",
#             example=124.3,
#         ),
#         "thrust_applied": fields.Float(
#             required=False,
#             description="TODO: Needs further consideration",
#             example=124.3,
#         ),
#         "health_status": fields.String(
#             required=False,
#             description="Health status extracted by respective platform "
#             + "if any diagnosis available checks on sensors",
#             example="Warning",
#         ),
#         "gps_data": fields.List(
#             fields.Nested(gps_schema),  # TODO: TBD Do we want a list of
#             # gps readings to allow > 1 reading i.e. platform + usbl
#             required=True,
#             description="Metadata pf each platform",
#         ),
#         "localisation_error": fields.Float(
#             required=False,
#             description="Localisation error at last USBL update.",
#             example="",
#         ),
#         "usbl_fix_seconds_ago": fields.Float(
#             required=False,
#             description="",
#             example="",
#         ),
#         "battery_remaining_capacity": fields.Float(
#             required=True,
#             description="Battery remaining capacity % provided by respective"
#             + " platform/C2.",
#             example=80.0,
#         ),
#         "sensor_config": fields.Nested(
#             sensor_schema
#         ),  # TODO: TBD Do we want a list of sensors to allow > 1 sensor
#     },
# )
326

327
# # TBD: Do we append beacon positions with platform positions?