diff --git a/README.md b/README.md index 28e9ef8de8407138a40cbdff741dfdd272be1907..84c31a3cd222da5cc19fa46f76949bd0bdc116f3 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Each message below will be wrapped in a `message_wrapper`: ``` python3 generate_swagger.py ``` -2. Go to `http://127.0.0.1:5000/soardocs/` +2. Go to `http://127.0.0.1:5000` # Quick Links 1. [Schema Fields Definitions](https://git.noc.ac.uk/communications-backbone-system/backbone-message-format/-/tree/7-message-formats-initial/formats) diff --git a/examples/all/platform_status.json b/examples/all/platform_status.json index 8a24e980f8a347f58a85e195853d8917d68af9cd..d169523752479aade6a610d7e3eb199018e66d2d 100644 --- a/examples/all/platform_status.json +++ b/examples/all/platform_status.json @@ -1,41 +1,40 @@ { - "message_ID": "b427003c-0000-11aa-a1eb-bvcdfghjgfdd", - "timestamp": "2022-11-16T00:00:00Z", - "version": 2, - "source": "hydrosurv_adapter", - "destination": "autonomy_engine", - "delivery_type": "publish", - "encoded": false, - "message_type": "platform_status", - "active": true, - "autonomy_plan_ID": 1, - "battery_remaining_capacity": 80.2, - "gps_data": [ - { - "altitude": 20, - "depth": 50, - "gps_source": "internal", - "latitude": 178.2, - "latitude_type": "string", - "longitude": -10.122, - "longitude_type": "string" - } - ], - "health_status": "Warning", - "localisation_error": null, - "mission_action_ID": 1, - "mission_track_ID": 4, - "platform_ID": 1, - "platform_state": "ABORT", - "platform_timestamp": "2022-12-21T00:00:00Z", - "range_to_go": 124.3, - "sensor_config": { - "additional_data": {}, - "sensor_serial": null, - "sensor_status": null + "message_ID": "b427003c-0000-11aa-a1eb-bvcdfghjgfdd", + "timestamp": "2022-11-16T00:00:00Z", + "version": 2, + "source": "hydrosurv_adapter", + "destination": "autonomy_engine", + "delivery_type": "publish", + "encoded": false, + "message_type": "platform_status", + "autonomy_engine_mission_plan_ID": 1, + "active": true, + "status_source": "onboard_platform", + "altitude": 20, + "battery_remaining_capacity": 80.2, + "depth": 50, + "health_status": "Warning", + "latitude": 178.2, + "localisation_error": 0.000129, + "longitude": -10.122, + "mission_action_ID": 1, + "mission_track_ID": 4, + "platform_ID": 1, + "platform_state": "ABORT", + "platform_timestamp": "2022-12-21T00:00:00Z", + "range_to_go": 124.3, + "sensor_config": { + "additional_data": { + "payload": [ + 1.2, + 434 + ] }, - "speed_over_ground": 124.3, - "thrust_applied": 124.3, - "usbl_fix_seconds_ago": null, - "water_current_velocity": 124.3 - } + "sensor_serial": "mbes-002a", + "sensor_status": true + }, + "speed_over_ground": 124.3, + "thrust_applied": 124.3, + "usbl_fix_seconds_ago": 10, + "water_current_velocity": 124.3 +} \ No newline at end of file diff --git a/examples/ecosub_c2/mission_plan.json b/examples/ecosub_c2/mission_plan.json index 07591cffe02303be3dc2f7a6c256f9a37a4a6275..14256ffd7dd08f0216c29d7292a7ef37bc6bcb4f 100644 --- a/examples/ecosub_c2/mission_plan.json +++ b/examples/ecosub_c2/mission_plan.json @@ -1,25 +1,54 @@ { - "message_ID": "b427003c-7bc8-11ed-a1eb-0242ac120002", - "timestamp": "2022-11-16T00:00:00Z", - "version": 2, - "source": "autonomy_engine", - "destination": "ecosub_c2", - "encoded": false, - "type": "mission_plan", - "payload": { - "plan_ID": 3, - "platform_serial": "ecosub-4", - "plan": [ - { - "action": "move", - "flight_style": "dive", - "latitude_waypoint": -4.187143188645706, - "longitude_waypoint": 50.37072283932642, - "altitude": 20, - "depth": null, - "activate_payload": true, - "send_environmental_data": false - } - ] + "message_ID": "b427003c-0000-11aa-a1eb-bvcdfghjgfdd", + "timestamp": "2022-11-16T00:00:00Z", + "version": 2, + "source": "autonomy_engine", + "destination": "ecosub_c2", + "delivery_type": "publish", + "encoded": false, + "message_type": "mission_plan", + "platform_serial": "reav-60", + "autonomy_engine_mission_plan_ID": 1, + "plan": [ + { + "action": "move", + "flight_style": "go to waypoint", + "latitude_waypoint": -3.237143188645706, + "longitude_waypoint": 52.37072283932642, + "altitude": null, + "depth": 0.0, + "activate_payload": false, + "send_environmental_data": false + }, + { + "action": "dive", + "flight_style": "dive to depth", + "latitude_waypoint": -3.237143188645706, + "longitude_waypoint": 52.37072283932642, + "altitude": 10, + "depth": null, + "activate_payload": false, + "send_environmental_data": false + }, + { + "action": "scanline", + "flight_style": "go to waypoint", + "latitude_waypoint": -0.237143188645706, + "longitude_waypoint": 60.00000000000000, + "altitude": 10, + "depth": null, + "activate_payload": true, + "send_environmental_data": false + }, + { + "action": "climb", + "flight_style": "go to surface", + "latitude_waypoint": -0.237143188645706, + "longitude_waypoint": 52.37072283932642, + "altitude": null, + "depth": 0, + "activate_payload": false, + "send_environmental_data": true } + ] } \ No newline at end of file diff --git a/examples/ecosub_c2/observation.json b/examples/ecosub_c2/observation.json index a4a857461b03f20b1e05700697645a7f52f06bee..ad763177f9d8d9995c62d97c6ade7c803a188b8c 100644 --- a/examples/ecosub_c2/observation.json +++ b/examples/ecosub_c2/observation.json @@ -1,18 +1,24 @@ { - "message_ID": "b427003c-7bc8-11ed-a1eb-0242ac120002", + "message_ID": "b427003c-0000-11aa-a1eb-bvcdfghjgfdd", "timestamp": "2022-11-16T00:00:00Z", "version": 2, "source": "ecosub_c2", "destination": "autonomy_engine", + "delivery_type": "publish", "encoded": false, - "type": "platform_status", - "payload": { - "platform_serial":"ecosub-3", - "points_of_interest": [], - "region_surveyed": [], - "quality_of_points": 0.98, - "additional_data": { - "sensor_x": false + "message_type": "observation", + "platform_ID": 3, + "points_of_interest": [ + { + "latitude": 178.2, + "longitude": -10.122, + "quality_of_point": 0.98 + }, + { + "latitude": 50.1382, + "longitude": -11.122, + "quality_of_point": 0.50 } - } + ], + "region_surveyed": "" } \ No newline at end of file diff --git a/examples/ecosub_c2/platform_status-from_usbl_example.json b/examples/ecosub_c2/platform_status-from_usbl_example.json new file mode 100644 index 0000000000000000000000000000000000000000..839428334fe0f485c3b6ead3325e4bee29315ac9 --- /dev/null +++ b/examples/ecosub_c2/platform_status-from_usbl_example.json @@ -0,0 +1,17 @@ +{ + "message_ID": "b427003c-0000-11aa-a1eb-bvcdfghjgfdd", + "timestamp": "2022-11-16T00:00:00Z", + "version": 2, + "source": "hermes", + "destination": "autonomy_engine", + "delivery_type": "publish", + "encoded": false, + "message_type": "platform_status", + "platform_ID": 1, + "platform_timestamp": "2022-12-21T00:00:00Z", + "status_source": "usbl", + "latitude": 178.2, + "longitude": -10.122, + "depth": 50, + "altitude": 20 +} diff --git a/examples/ecosub_c2/platform_status.json b/examples/ecosub_c2/platform_status.json index 460bc82ca5c11494bd0d8913029be74f5886673e..ab543803c8454588bea9e3ea40dbfa27375dd4ff 100644 --- a/examples/ecosub_c2/platform_status.json +++ b/examples/ecosub_c2/platform_status.json @@ -1,44 +1,39 @@ { - "message_ID": "b427003c-7bc8-11ed-a1eb-0242ac120002", + "message_ID": "b427003c-0000-11aa-a1eb-bvcdfghjgfdd", "timestamp": "2022-11-16T00:00:00Z", - "version": 1, - "source": "hermes_ecosub", + "version": 2, + "source": "ecosub_c2", "destination": "autonomy_engine", + "delivery_type": "publish", "encoded": false, - "type": "platform_status", - "payload": { - "platform_ID": 2, - "active": true, - "platform_state": "IDLE", - "autonomy_plan_ID": 1, - "mission_track_ID": 4, - "mission_action_ID": 1, - "range_to_go": 12.3, - "speed_over_ground": 10.3, - "water_current_velocity": 10.3, - "thrust_applied": 0.3, - "health_status": "Warning", - "gps_data": [ - { - "gps_source": "internal", - "latitude_type": "", - "longitude_type": "", - "latitude": -7.432, - "longitude": 50.365, - "depth": 5.0, - "altitude": 20.0 - } - ], - "localisation_error": null, - "usbl_fix_seconds_ago": null, - "battery_remaining_capacity": 80, - "sensor_config": { - "sensor_ID": 22, - "serial": "sidescan-2x", - "sensor_status": true, - "additional_data": { - "whiskers_on": true - } - } - } - } \ No newline at end of file + "message_type": "platform_status", + "platform_ID": 1, + "platform_timestamp": "2022-12-21T00:00:00Z", + "status_source": "onboard_platform", + "autonomy_engine_plan_ID": 1, + "battery_remaining_capacity": 80.2, + "active": true, + "platform_state": "ABORT", + "mission_action_ID": 1, + "mission_track_ID": 4, + "latitude": 178.2, + "longitude": -10.122, + "depth": 50, + "altitude": 20, + "health_status": "Warning", + "localisation_error": null, + "usbl_fix_seconds_ago": null, + "range_to_go": 124.3, + "sensor_config": { + "sensor_ID": 22, + "serial": "sidescan-2x", + "sensor_on": true, + "additional_data": { + "whiskers_on": true + } + }, + "current_pitch": -4, + "speed_over_ground": 4.3, + "thrust_applied": 124.3, + "water_current_velocity": 124.3 +} diff --git a/examples/hydrosurv_adapter/acknowledgement.json b/examples/hydrosurv_adapter/acknowledgement.json index e8ca46085718cb42f6917b069700f6248ab666e5..21ca73e1336953fea34e1b707748b01fb37666ec 100644 --- a/examples/hydrosurv_adapter/acknowledgement.json +++ b/examples/hydrosurv_adapter/acknowledgement.json @@ -1,12 +1,12 @@ { "message_ID": "b427003c-0000-11aa-a1eb-bvcdfghjgfdd", "timestamp": "2022-11-16T00:00:00Z", - "version": 2, - "source": "autonomy_engine", - "destination": "ah1", + "version": 1, + "source": "hydrosurv_adapter", + "destination": "autonomy_engine", "delivery_type": "publish", "encoded": false, - "message_type": "platform_status", - "acknowledged_message_ID": "02125022255-7bc8-11ed-a1eb-0242ac999999", - "status": "executed by platform" + "message_type": "acknowledgement", + "acknowledged_message_ID": "11111111-7bc8-11ed-a1eb-0242ac999999", + "status": "Approved and sent to platform" } \ No newline at end of file diff --git a/examples/hydrosurv_adapter/mission_plan.json b/examples/hydrosurv_adapter/mission_plan.json index c99d52bf2e386eff6470b1d2077c057ac78928d4..81a6ff71a426f0c5ff72b50a56fa178013ce764b 100644 --- a/examples/hydrosurv_adapter/mission_plan.json +++ b/examples/hydrosurv_adapter/mission_plan.json @@ -1,24 +1,26 @@ { - "message_ID": "b427003c-0000-11aa-a1eb-bvcdfghjgfdd", - "timestamp": "2022-11-16T00:00:00Z", - "version": 2, - "source": "autonomy_engine", - "destination": "hydrosurv_adapter", - "delivery_type": "publish", - "encoded": false, - "message_type": "mission_plan", - "plan_ID": 1, - "plan": [ - { - "action": "move", - "flight_style": "orbit", - "activate_payload": true, - "altitude": 15, - "depth": 15, - "latitude_waypoint": -4.187143188645706, - "longitude_waypoint": 50.37072283932642, - "send_environmental_data": false - } - ], - "platform_serial": "reav-60" -} + "message_ID": "b427003c-0000-11aa-a1eb-bvcdfghjgfdd", + "timestamp": "2022-11-16T00:00:00Z", + "version": 2, + "source": "autonomy_engine", + "destination": "hydrosurv_adapter", + "delivery_type": "publish", + "encoded": false, + "message_type": "mission_plan", + "platform_serial": "reav-60", + "autonomy_engine_plan_ID": 1, + "plan": [ + { + "latitude_waypoint": -4.187143188645706, + "longitude_waypoint": 50.37072283932642 + }, + { + "latitude_waypoint": -3.187143188645706, + "longitude_waypoint": 51.37072283932642 + }, + { + "latitude_waypoint": -3.237143188645706, + "longitude_waypoint": 52.37072283932642 + } + ] +} \ No newline at end of file diff --git a/examples/hydrosurv_adapter/platform_status.json b/examples/hydrosurv_adapter/platform_status.json index 8a24e980f8a347f58a85e195853d8917d68af9cd..dc24112255a1946bf5e9b238322a1f7d5f237f27 100644 --- a/examples/hydrosurv_adapter/platform_status.json +++ b/examples/hydrosurv_adapter/platform_status.json @@ -1,41 +1,25 @@ { - "message_ID": "b427003c-0000-11aa-a1eb-bvcdfghjgfdd", - "timestamp": "2022-11-16T00:00:00Z", - "version": 2, - "source": "hydrosurv_adapter", - "destination": "autonomy_engine", - "delivery_type": "publish", - "encoded": false, - "message_type": "platform_status", - "active": true, - "autonomy_plan_ID": 1, - "battery_remaining_capacity": 80.2, - "gps_data": [ - { - "altitude": 20, - "depth": 50, - "gps_source": "internal", - "latitude": 178.2, - "latitude_type": "string", - "longitude": -10.122, - "longitude_type": "string" - } - ], - "health_status": "Warning", - "localisation_error": null, - "mission_action_ID": 1, - "mission_track_ID": 4, - "platform_ID": 1, - "platform_state": "ABORT", - "platform_timestamp": "2022-12-21T00:00:00Z", - "range_to_go": 124.3, - "sensor_config": { - "additional_data": {}, - "sensor_serial": null, - "sensor_status": null - }, - "speed_over_ground": 124.3, - "thrust_applied": 124.3, - "usbl_fix_seconds_ago": null, - "water_current_velocity": 124.3 - } + "message_ID": "b427003c-0000-11aa-a1eb-bvcdfghjgfdd", + "timestamp": "2022-11-16T00:00:00Z", + "version": 2, + "source": "hydrosurv_adapter", + "destination": "autonomy_engine", + "delivery_type": "publish", + "encoded": false, + "message_type": "platform_status", + "autonomy_engine_plan_ID": 1, + "active": true, + "status_source": "onboard_platform", + "battery_remaining_capacity": 80.2, + "health_status": "Lost Connection", + "latitude": 178.2, + "longitude": -10.122, + "mission_action_ID": 1, + "mission_track_ID": 4, + "platform_ID": 1, + "platform_state": "ABORT", + "platform_timestamp": "2022-12-21T00:00:00Z", + "speed_over_ground": 4.5, + "range_to_go": null, + "thrust_applied": null +} \ No newline at end of file diff --git a/formats/acknowledgement.py b/formats/acknowledgement.py index 5021b4f6eb75634203c07cdfbacd288073d3a1c0..4f3352cfc21b138c46dfe9bab64ca2ea504617fb 100644 --- a/formats/acknowledgement.py +++ b/formats/acknowledgement.py @@ -14,9 +14,9 @@ acknowledgement_schema = { }, "status": { "type": "string", - "description": "Highest level of acknowledgement. I.e. `c2_received`:" - + " Received by C2, `c2_sent`: Sent from C2->Platform, `executed`:" - + " Executed by platform", + "description": "Highest level of acknowledgement. I.e." + + " `c2_received`: Received by C2, `c2_sent`: Sent from" + + " C2->Platform, `executed`: Executed by platform", "example": "executed by platform", }, }, @@ -39,9 +39,9 @@ acknowledgement_schema = { # ), # "status": fields.String( # required=True, -# description="Highest level of acknowledgement. I.e. `c2_received`:" -# + " Received by C2, `c2_sent`: Sent from C2->Platform, `executed`:" -# + " Executed by platform", +# description="Highest level of acknowledgement. " +# + " I.e. `c2_received`: Received by C2, `c2_sent`:" +# + " Sent from C2->Platform, `executed`: Executed by platform", # ), # }, # ) diff --git a/formats/message_wrapper.py b/formats/message_wrapper.py index 8762dd6e44b31217f620c4574b738d46393672a1..ead7cf1102d2dd32bff39bf5a4ddb7ee9788e2e3 100644 --- a/formats/message_wrapper.py +++ b/formats/message_wrapper.py @@ -1,7 +1,7 @@ """ schemas: Message Wrapper is used to wrap all message types that contain - details of where the message is coming from, which end client is its destination - and the type of message. + details of where the message is coming from, which end client is its + destination and the type of message. """ message_wrapper_schema = { @@ -12,7 +12,7 @@ message_wrapper_schema = { "properties": { "message_ID": { "type": "string", - "description": "An identifier for the type of " + "message received.", + "description": "An identifier for the type of message received.", "example": "b427003c-0000-11aa-a1eb-bvcdfghjgfdd", }, "timestamp": { @@ -27,7 +27,7 @@ message_wrapper_schema = { }, "version": { "type": "string", - "description": "Version of comms bacbone messaging format protocol", + "description": "Version of comms bacbone message format protocol", "example": 2.0, }, "source": { @@ -37,7 +37,8 @@ message_wrapper_schema = { }, "destination": { "type": "string", - "description": "Publisher topic; What is the destination of this message", + "description": "Publisher topic; What is the destination" + + " of this message", "example": "ah1", }, "encoded": { diff --git a/formats/mission_plan.py b/formats/mission_plan.py index 46243caa4b2bb5a4c93ee134b476f3b22292105b..e46096c2f3c35fb25137d01ea7ef914a22aecdff 100644 --- a/formats/mission_plan.py +++ b/formats/mission_plan.py @@ -1,5 +1,5 @@ """ - schemas: Mission plan (un-complied) geenrated by the Autonomy Engine + schemas: Mission plan (un-compiled) geenrated by the Autonomy Engine sent to the respective platform's C2 to compile into a platform-specific mission plan. """ @@ -49,13 +49,12 @@ action_schema = { }, "send_environmental_data": { "type": "boolean", - "description": "To trigger the platform to send list of observations" - + " if any found", + "description": "To trigger the platform to send list of" + + " observations if any found", "example": False, }, }, "required": [ - "action", "latitude_waypoint", "longitude_waypoint", ], @@ -65,7 +64,7 @@ mission_plan_schema = { "allOf": [{"$ref": "#/components/schemas/Message"}], "type": "object", "properties": { - "plan_ID": {"type": "integer"}, + "autonomy_engine_plan_ID": {"type": "integer"}, "platform_serial": {"type": "string"}, "plan": { "type": "array", @@ -118,8 +117,8 @@ mission_plan_schema = { # ), # "send_environmental_data": fields.Boolean( # required=False, -# description="To trigger the platform to send list of observations" -# + " if any found", +# description="To trigger the platform to send list of" +# + " observations if any found", # example=False, # ), # }, @@ -146,8 +145,9 @@ mission_plan_schema = { # "plan": fields.List( # fields.Nested(action_schema), # required=True, -# description="Sequence of actions/instructions generated by the " -# + " Autonomy Engine that should be compiled by the respective C2.", +# description="Sequence of actions/instructions generated by the" +# + " Autonomy Engine that should be compiled by the", +# + " respective C2.", # ), # }, # ) diff --git a/formats/observation.py b/formats/observation.py index da8cd04ccacbebef0b704f38727c2a88b6579079..8d0097a246b494b560196d8850b9b8a5f056c023 100644 --- a/formats/observation.py +++ b/formats/observation.py @@ -1,34 +1,55 @@ """ - schema: Observation Message sent by platforms when points of interest are found. + schema: Observation Message sent by platforms when points of + interest are found. """ # from . import full_message_schema, api # from flask_restx import fields +hits_schema = { + "type": "object", + "properties": { + "latitude": { + "type": "number", + "description": "Identified x-coordinate of point of interest", + "example": 178.2, + }, + "longitude": { + "type": "number", + "description": "Identified y-coordinate of point of interest", + "example": -10.122, + }, + "quality_of_point": { + "type": "number", + "description": "Quality/strength of points from features of" + + " interest identified by platform. TODO: DEFINE FORMAT.", + "example": 0.98, + }, + }, + "required": [], +} + observation_schema = { "allOf": [{"$ref": "#/components/schemas/Message"}], "type": "object", "properties": { - "platform_serial": { - "description": "Serial of platform to sendign observations", + "platform_ID": { + "type": "integer", + "description": "ID of platform to sending observations", "example": "ecosub-3", }, # "observation_type" ==> payloads tied to different types maybe? # properties of each observation? "points_of_interest": { + "type": "array", + "items": hits_schema, "description": "Points from features of interest identified by" + " platform if any found. DEFINE FORMAT.", - "example": "", }, "region_surveyed": { "description": "Region surveyed by given platform. DEFINE FORMAT." - + " GEOJSON?", + + " GEOJSON", "example": "", }, - "quality_of_points": { - "description": "Quality/strength of points from features of interest" - + " identified by platform. DEFINE FORMAT.", - "example": 0.98, - }, "additional_data": { "description": "Placeholder field for any additional data", "example": {"sensor_payload": False}, @@ -66,8 +87,8 @@ observation_schema = { # ), # "quality_of_points": fields.Float( # required=False, -# description="Quality/strength of points from features of interest" -# + " identified by platform. DEFINE FORMAT.", +# description="Quality/strength of points from features of" +# + " interest identified by platform. DEFINE FORMAT.", # example=0.98, # ), # "additional_data": fields.Raw( diff --git a/formats/planning_configuration.py b/formats/planning_configuration.py index 7f1d84eff6d75defec19601c961552f7b504c7ff..d4fb1e58847cb123730f793101cee4671e183385 100644 --- a/formats/planning_configuration.py +++ b/formats/planning_configuration.py @@ -5,29 +5,41 @@ # from . import api, full_message_schema, platform_schema # from flask_restx import fields - -constraints_schema = { +emergency_schema = { "type": "object", "properties": { - "min_altitude": { + "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", + }, + "latitude_waypoint": { "type": "number", - "description": "Minimum altitude set for squad.", - "example": 15.2, + "description": "X-coordinate of safe place for respective platform", + "example": -7.432, }, - "min_velocity": { + "longitude_waypoint": { "type": "number", - "description": "Minimum velocity set for squad.", - "example": 0.1, + "description": "Y-coordinate of safe place for respective platform", + "example": 50.365, }, - "max_velocity": { + "target_depth": { "type": "number", - "description": "Maximum altitude set for squad.", - "example": 0.9, + "description": "Z-coordinate of safe place for respective platform" + + " . If platform to NOT stay at depth, key in `0.0`", + "example": 10, + }, + "additional_data": { + "type": "null", + "description": "Any addition fields/data to be added here", + "example": {}, }, }, - "required": ["min_altitude", "min_velocity", "max_velocity"], + "required": ["latitude_waypoint", "longitude_waypoint", "target_depth"], } + platform_schema = { "type": "object", "properties": { @@ -45,9 +57,29 @@ platform_schema = { "type": "string", "example": "reav", }, - "constraints": constraints_schema, + "emergency": emergency_schema, + "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, + }, + "additional_data": { + "type": "null", + "description": "Any addition fields/data to be added here", + "example": {"swath_width": 10.0, "scan_type": "DVL"}, + }, }, - "required": ["platform_ID", "serial", "model", "constraints"], + "required": ["platform_ID", "serial", "model", "emergency", "min_altitude", "min_velocity", "max_velocity"], } region_schema = { @@ -100,11 +132,6 @@ squad_metadata_schema = { "example": False, }, "region_of_interest": region_schema, - "exclusion_zones": { - "type": "array", - "items": region_schema, - "description": "Exclusion zones per squad.", - }, }, "required": [ "squad_ID", @@ -120,18 +147,27 @@ planning_configuration_schema = { "allOf": [{"$ref": "#/components/schemas/Message"}], "type": "object", "properties": { - "config_ID": { + "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": ["config_ID", "squads"], + "required": [ + "config_ID", + "squads", + "exclusion_zones", + ], } # region_schema = api.model( @@ -139,8 +175,8 @@ planning_configuration_schema = { # { # "region": fields.Raw( # required=True, -# description="Using GEOJSON, exact region of interest in rectangle" -# + " format polygon", +# description="Using GEOJSON, exact region of " +# + "interest in rectangle format polygon", # example={ # "type": "FeatureCollection", # "features": [ diff --git a/formats/platform_status.py b/formats/platform_status.py index d3c81579eb6ddb9f4de01fa89ce638ef5bee1b45..0bb15a5e698926ddaa4a1ab6271871e41eb2ee12 100644 --- a/formats/platform_status.py +++ b/formats/platform_status.py @@ -1,66 +1,17 @@ """ schema: platform-specific decoded status message """ -# from . import full_message_schema, api -# from flask_restx import fields - - -gps_schema = { - "type": "object", - "properties": { - "gps_source": { - "type": "string", - "description": "Source of gps position. E.g. USBL (external)," - + "platform itself (internal)", - "example": "internal", - }, - "latitude_type": { - "type": "string", - "description": "TODO: Add description", - }, - "longitude_type": { - "type": "string", - "description": "TODO: Add description", - }, - "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, - }, - }, - "required": [ - "gps_source", - "latitude", - "longitude", - ], -} - sensor_schema = { "type": "object", - "description": "Scanning sensor on platform available to be controlled by the Autonomy Engine", + "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_status": { + "sensor_on": { "type": "boolean", "description": "Sensor switched on (True) or off (False)", "example": True, @@ -83,6 +34,13 @@ platform_status_message_schema = { "description": "Identifier for platform", "example": 1, }, + "status_source": { + "type": "string", + "enum": ["usbl", "onboard_platform"], + "description": "Indicate if this status message is from the" + + " platform or USBL", + "example": "usbl", + }, "platform_timestamp": { "type": "date-time", "decription": "Timestamp for onboard platform status message", @@ -101,12 +59,33 @@ platform_status_message_schema = { + "STOP, IDLE, ABORT.", "example": "ABORT", }, - "autonomy_plan_ID": { + "autonomy_engine_plan_ID": { "type": "integer", - "description": "Last mission plan ID (according to Autonomy Engine's" - + " mission plan number) executed by platform", + "description": "Last mission plan ID (according to Autonomy" + + " Engine's mission plan number sent) executed by platform", "example": 1, }, + "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, + }, "mission_track_ID": { "type": "integer", "description": "Track number - stage in mission (e.g. " @@ -144,11 +123,6 @@ platform_status_message_schema = { + "if any diagnosis is available to check sensors", "example": "Warning", }, - "gps_data": { - "type": "array", - "description": "position of platform", - "items": gps_schema, - }, "localisation_error": { "type": "number", "description": "Localisation error at last USBL update.", @@ -161,16 +135,22 @@ platform_status_message_schema = { }, "battery_remaining_capacity": { "type": "number", - "description": "Battery remaining capacity % provided by respective", + "description": "Battery remaining % provided by respective C2", "example": 80.2, }, + "current_pitch": { + "type": "number", + "description": "Current pitch of platform", + "example": -4.0, + }, "sensor_config": sensor_schema, }, "required": [ "platform_ID", + "status_source", "platform_timestamp", - "gps_data", - "battery_remaining_capacity", + "latitude", + "longitude", ], } @@ -272,7 +252,8 @@ platform_status_message_schema = { # ), # "autonomy_plan_ID": fields.Integer( # required=False, -# description="Last mission plan ID (according to Autonomy Engine's" +# description="Last mission plan ID ( +# + "according to Autonomy Engine's" # + " mission plan number) executed by platform", # example=1, # ), diff --git a/generate_swagger.py b/generate_swagger.py index 1abd4b92e520aef7f0fb8880eaaa5013db00ab29..dc0657e1291dfa5f7626983ef177e869d913b7d3 100644 --- a/generate_swagger.py +++ b/generate_swagger.py @@ -15,7 +15,7 @@ swagger_config = { "headers": [], "openapi": "3.0.2", "swagger_ui": True, - "specs_route": "/soardocs/", + "specs_route": "/", "info": { "title": "Backbone Message Formats", "version": "0.1", @@ -90,7 +90,7 @@ swagger_config = { "consumes": ["application/json"], } message_types = [ - "Message", + # "Message", "Acknowledgement", "MissionPlan", "Observation",