schemas.py 17.8 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 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
message_header = {
    "type": "object",
    "discriminator": {
        "propertyName": "message_type",
    },
    "properties": {
        "message_ID": {
            "type": "string",
            "description": "An identifier for the type of message received.",
            "example": "b427003c-0000-11aa-a1eb-bvcdfghjgfdd",
        },
        "timestamp": {
            "type": "string",
            "format": "date-time",
            "description": "Timestamp of message",
            "example": "2022-11-16T00:00:00Z",
        },
        "version": {
            "type": "number",
            "format": "float",
            "description": "Version of comms backbone message format protocol",
            "example": 2.0,
        },
        "source": {
            "type": "string",
            "description": "The sender; Where is this message from",
            "example": "autonomy_engine",
        },
        "destination": {
            "type": "string",
            "description": "Publisher topic; What is the destination"
            + " of this message",
            "example": "ah1",
        },
        "encoded": {
            "type": "boolean",
            "description": "Indicate that message raw (encoded) or decoded. "
            + "Options: encoded=True, decoded=False",
            "example": False,
        },
        "delivery_type": {
            "type": "string",
            "description": "To publish or broadcast this message.",
            "enum": ["broadcast", "publish"],
            "example": "publish",
            "default": "publish",
        },
    },
}

acknowledgement_schema = {
    "type": "object",
    "properties": {
        "message_type": {
            "type": "string",
            "description": "Type of message",
            "example": "acknowledgement",
        },
59 60 61 62 63
        "autonomy_engine_plan_ID": {
            "type": "integer",
            "description": "Mission plan ID (according to Autonomy"
            + " Engine's mission plan number sent) executed by platform",
            "example": 1,
64
        },
65
        "platform_ID": {
66
            "type": "string",
67 68 69 70 71
            "description": "Unique identifier for this platform",
            "example": "reav-x-1",
        },
        "approved": {
            "type": "boolean",
Trishna Saeharaseelan's avatar
Trishna Saeharaseelan committed
72 73
            "description": "Human-in-the-loop approval. "
            + "1 - Plan approved; 0 - Plan Rejected",
74 75
        },
    },
Trishna Saeharaseelan's avatar
Trishna Saeharaseelan committed
76 77 78 79 80 81
    "required": [
        "message_type",
        "autonomy_engine_plan_ID",
        "platform_ID",
        "approved",
    ],
82 83 84 85 86 87 88 89 90 91 92 93
}


action_schema = {
    "type": "object",
    "properties": {
        "action": {
            "type": "string",
            "description": "Autonomy Engine's action from `move`, `payload`,"
            + " `dive`, `send_hits`, `scanline`, `scanpoint`.",
            "example": "move",
        },
94
        "start_point_latitude": {
95 96
            "type": "number",
            "format": "float",
97
            "description": "Start point, x-coordinate",
98 99
            "example": -4.187143188645706,
        },
100
        "start_point_longitude": {
101 102
            "type": "number",
            "format": "float",
103 104 105 106 107 108 109 110 111 112 113 114 115
            "description": "Start point, y-coordinate",
            "example": 50.37072283932642,
        },
        "target_waypoint_latitude": {
            "type": "number",
            "format": "float",
            "description": "Target waypoint, x-coordinate",
            "example": -4.187143188645706,
        },
        "target_waypoint_longitude": {
            "type": "number",
            "format": "float",
            "description": "Target waypoint, y-coordinate",
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
            "example": 50.37072283932642,
        },
        "altitude": {
            "type": "number",
            "format": "float",
            "description": "Altitude of next action",
            "example": 15.0,
        },
        "depth": {
            "type": "number",
            "format": "float",
            "description": "Depth of next action",
            "example": 15.0,
        },
        "activate_payload": {
            "type": "boolean",
            "description": "To activate/deactivate sensor for Autosub "
            + "Hover-1 --> `MBES` sensor and for EcoSUB --> `Sidescan`",
            "example": True,
        },
136 137 138 139 140 141
        "timeout": {
            "type": "number",
            "format": "float",
            "description": "Timeout set to perform action",
            "example": 1800.0,
        },
142 143
    },
    "required": [
144 145
        "target_waypoint_latitude",
        "target_waypoint_longitude",
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
    ],
}

mission_plan_schema = {
    "type": "object",
    "properties": {
        "message_type": {
            "type": "string",
            "description": "Type of message",
            "example": "mission_plan",
        },
        "autonomy_engine_plan_ID": {
            "type": "integer",
            "description": "Unique identifier for this plan"
            + "generated by the Autonomy Engine",
            "example": 3,
        },
        "platform_ID": {
            "type": "string",
            "description": "Unique identifier for this platform",
            "example": "reav-x-1",
        },
        "plan": {
            "type": "array",
            "items": action_schema,
        },
    },
Trishna Saeharaseelan's avatar
Trishna Saeharaseelan committed
173 174 175 176 177 178
    "required": [
        "message_type",
        "autonomy_engine_plan_ID",
        "platform_ID",
        "plan",
    ],
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
}


hits_schema = {
    "type": "object",
    "properties": {
        "latitude": {
            "type": "number",
            "format": "float",
            "description": "Identified x-coordinate of point of interest",
            "example": 178.2,
        },
        "longitude": {
            "type": "number",
            "format": "float",
            "description": "Identified y-coordinate of point of interest",
            "example": -10.122,
        },
        "quality_of_point": {
            "type": "number",
            "format": "float",
            "description": "Quality/strength of points from features of"
            + " interest identified by platform.",  # TODO: DEFINE FORMAT.
            "example": 0.98,
        },
    },
    "required": ["latitude", "longitude"],
}

observation_schema = {
    "type": "object",
    "properties": {
        "message_type": {
            "type": "string",
            "description": "Type of message",
            "example": "observation",
        },
        "platform_ID": {
            "type": "string",
            "description": "Unique identifier for this platform",
            "example": "reav-x-1",
        },
        "points_of_interest": {
            "type": "array",
            "items": hits_schema,
            "description": "Points from features of interest identified by"
            + " platform if any found.",  # TODO: DEFINE FORMAT.
        },
        "region_surveyed": {
            "nullable": True,
            "description": "Region surveyed by given platform."
            + " GEOJSON",  # TODO: DEFINE FORMAT.
            "example": "",
        },
        "additional_data": {
            "description": "Placeholder field for any additional data",
            "example": {"sensor_payload": False},
        },
    },
    "required": ["message_type", "platform_ID"],
}

emergency_schema = {
    "type": "object",
    "properties": {
        "safe_command": {
            "type": "string",
            "enum": ["go_home", "abort_now", "stop_mission"],
            "description": "Command/Action that is native to respective"
            + " partner's platform/C2",
            "example": "go_home",
        },
251
        "target_waypoint_latitude": {
252 253 254 255 256
            "type": "number",
            "format": "float",
            "description": "X-coordinate safe place for respective platform",
            "example": -7.432,
        },
257
        "target_waypoint_longitude": {
258 259 260 261 262 263 264 265 266 267
            "type": "number",
            "format": "float",
            "description": "Y-coordinate safe place for respective platform",
            "example": 50.365,
        },
        "target_depth": {
            "type": "number",
            "format": "float",
            "description": "Z-coordinate safe place for respective platform"
            + " . If platform to NOT stay at depth, key in `0.0`",
268
            "example": 10.0,
269 270 271 272 273 274
        },
        "additional_data": {
            "description": "Any addition fields/data to be added here",
            "example": {},
        },
    },
Trishna Saeharaseelan's avatar
Trishna Saeharaseelan committed
275 276 277 278 279
    "required": [
        "target_waypoint_latitude",
        "target_waypoint_longitude",
        "target_depth",
    ],
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
}


platform_schema = {
    "type": "object",
    "properties": {
        "platform_ID": {
            "type": "string",
            "description": "Unique identifier for this platform",
            "example": "reav-x-1",
        },
        "model": {
            "type": "string",
            "example": "reav",
        },
        "emergency": emergency_schema,
        "min_altitude": {
            "type": "number",
            "format": "float",
            "description": "Minimum altitude set for squad.",
            "example": 15.2,
        },
        "min_velocity": {
            "type": "number",
            "format": "float",
            "description": "Minimum velocity set for squad.",
            "example": 0.1,
        },
        "max_velocity": {
            "type": "number",
            "format": "float",
            "description": "Maximum altitude set for squad.",
            "example": 0.9,
        },
314
        "additional_data": {
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477
            "description": "Any addition fields/data to be added here",
            "example": {"swath_width": 10.0, "scan_type": "DVL"},
        },
    },
    "required": [
        "platform_ID",
        "model",
        "emergency",
        "min_altitude",
        "min_velocity",
        "max_velocity",
    ],
}

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],
                ]
            ],
        },
    },
    "description": "Using GEOJSON, exact 4-point region (rectangle shaped)",
}

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",
    ],
}

planning_configuration_schema = {
    "type": "object",
    "properties": {
        "message_type": {
            "type": "string",
            "description": "Type of message",
            "example": "planning_configuration",
        },
        "planning_config_ID": {
            "type": "integer",
            "description": "Unique identifier tagged to version of this"
            + " configuration plan",
            "example": 3,
        },
        "exclusion_zones": {
            "type": "array",
            "items": region_schema,
            "description": "Exclusion zones for all platforms",
        },
        "squads": {
            "type": "array",
            "items": squad_metadata_schema,
        },
    },
    "required": [
        "message_type",
        "planning_config_ID",
        "squads",
        "exclusion_zones",
    ],
}


sensor_schema = {
    "type": "object",
    "description": "Scanning sensor on platform available"
    + " to be controlled by  the Autonomy Engine",
    "properties": {
        "sensor_serial": {
            "type": "string",
            "description": "serial number of sensor",
            "example": "mbes-002a",
        },
        "sensor_on": {
            "type": "boolean",
            "description": "Sensor switched on (True) or off (False)",
            "example": True,
        },
        "additional_data": {
            "description": "Any addition fields/data to be added here",
            "example": {"payload": [1.2, 434]},
        },
    },
}

platform_status_schema = {
    "type": "object",
    "properties": {
        "message_type": {
            "type": "string",
            "description": "Type of message",
            "example": "platform_status",
        },
        "platform_ID": {
            "type": "string",
            "description": "Unique identifier for this platform",
            "example": "reav-x-1",
        },
        "status_source": {
            "type": "string",
            "enum": ["usbl", "onboard_platform"],
            "description": "Indicate if this status message is from the"
            + " platform or USBL",
            "example": "usbl",
        },
        "transmission_mode": {
            "type": "string",
            "enum": ["acoustics", "iridium", "wifi", "starlink"],
            "description": "Mode in which status message was transmitted"
            + " when on the surface (e.g. iridium/wifi) or underwater"
            + " (e.g. acoustics)",
            "example": "wifi",
        },
        "platform_timestamp": {
            "type": "string",
            "format": "date-time",
            "description": "Timestamp for onboard platform status message",
            "example": "2022-12-21T00:00:00Z",
        },
        "platform_state": {
Trishna Saeharaseelan's avatar
Trishna Saeharaseelan committed
478
            "type": "string",
479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504
            "description": "Current state executed by platform. E.g. "
            + "STOP, IDLE, ABORT.",
            "example": "ABORT",
        },
        "autonomy_engine_plan_ID": {
            "type": "integer",
            "description": "Last mission plan ID (according to Autonomy"
            + " Engine's mission plan number sent) executed by platform",
            "example": 1,
        },
        "latitude": {
            "type": "number",
            "format": "float",
            "description": "Latitude in decimal degrees.",
            "example": 178.2,
        },
        "longitude": {
            "type": "number",
            "format": "float",
            "description": "Longitude in decimal degrees.",
            "example": -10.122,
        },
        "depth": {
            "type": "number",
            "format": "float",
            "description": "Target depth in metres",
Trishna Saeharaseelan's avatar
Trishna Saeharaseelan committed
505 506
            "example": 50.0,
            "default": 0.0,
507 508 509 510 511 512 513 514 515 516 517 518 519
        },
        "altitude": {
            "type": "number",
            "format": "float",
            "description": "Target altitude in metres",
            "example": 20,
        },
        "mission_track_ID": {
            "type": "integer",
            "description": "Track number - stage in mission (e.g. "
            + "4 --> Waypoint 3 to Waypoint 4)",
            "example": 4,
        },
520
        "mission_plan_ID": {
521
            "type": "integer",
Trishna Saeharaseelan's avatar
Trishna Saeharaseelan committed
522
            "description": "Mission plan ID according to platform-C2 system",
523 524 525 526 527 528 529 530 531 532 533
            "example": 1,
        },
        "range_to_go": {
            "type": "number",
            "format": "float",
            "description": "Estimated distance to reach next waypoint",
            "example": 124.3,
        },
        "speed_over_ground": {
            "type": "number",
            "format": "float",
534
            "description": "Speed over ground",
535 536 537
            "example": 124.3,
        },
        "water_current_velocity": {
538
            "format": "string",
539
            "description": "Water current magnitude and direction",
540
            "example": "124.3NE",
541 542 543 544
        },
        "thrust_applied": {
            "type": "number",
            "format": "float",
545
            "description": "Thrust applied",
546 547 548 549 550 551 552 553 554 555
            "example": 124.3,
        },
        "heading": {
            "type": "number",
            "format": "float",
            "description": "Angular distance relative to north, usually 000°"
            + " at north, clockwise through 359°, in degrees",
            "example": 124.3,
        },
        "health_status": {
556
            "type": "boolean",
Trishna Saeharaseelan's avatar
Trishna Saeharaseelan committed
557 558
            "description": "Health status where 0 is OK, 1 is platform"
            + " has an ERROR",
559
            "example": False,
560
        },
561
        "localisation_north_error": {
562 563
            "type": "number",
            "format": "float",
Trishna Saeharaseelan's avatar
Trishna Saeharaseelan committed
564 565
            "description": "Difference in NORTH between deadreckoning"
            + " and USBL update.",
566
            "example": 0.000129,
567
        },
568
        "localisation_east_error": {
569 570
            "type": "number",
            "format": "float",
Trishna Saeharaseelan's avatar
Trishna Saeharaseelan committed
571 572
            "description": "Difference in EAST between deadreckoning"
            + " and USBL update.",
573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597
            "example": 0.000129,
        },
        "usbl_fix_seconds_ago": {
            "type": "number",
            "format": "float",
            "description": "USBL Fix received x second ago.",
            "example": 10.0,
        },
        "battery_remaining_capacity": {
            "type": "number",
            "format": "float",
            "description": "Battery remaining % provided by respective C2",
            "example": 80.2,
        },
        "sensor_config": sensor_schema,
    },
    "required": [
        "message_type",
        "platform_ID",
        "status_source",
        "platform_timestamp",
        "latitude",
        "longitude",
    ],
}