From 46142c3564b7f743926256c6cc2eb84bd52033c4 Mon Sep 17 00:00:00 2001 From: Trishna Saeharaseelan <trishna.saeharaseelan@noc.ac.uk> Date: Tue, 10 Jan 2023 16:55:30 +0800 Subject: [PATCH] fix(acknowledgement): schema for swagger, update hydrosurv egs# --- README.md | 7 ++ examples/all/acknowledgement.json | 17 +++-- examples/all/mission_plan.json | 39 +++++------ examples/all/platform_status.json | 70 +++++++++---------- .../hydrosurv_adapter/acknowledgement.json | 17 +++-- examples/hydrosurv_adapter/mission_plan.json | 39 +++++------ .../hydrosurv_adapter/platform_status.json | 70 +++++++++---------- formats/acknowledgement.py | 8 ++- formats/message_wrapper.py | 2 +- formats/observation.py | 2 +- generate_swagger.py | 4 +- project/SOAR_README.md | 7 ++ 12 files changed, 148 insertions(+), 134 deletions(-) diff --git a/README.md b/README.md index 56bbe31..28e9ef8 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,14 @@ Each message below will be wrapped in a `message_wrapper`: * `platform_status`: these would be two message types, i. encoded (platform-specific serialized message) and ii. parsed, human-readable message. * `observation`: this would be desired scientific data sent by the platform * `acknowledgement`: level of acknowledgment where an acknowledgement is sent when a message is i. received, ii. sent to the next destination (e.g. platform in the water). +* `planning_configuration`: sent from the GUI to initialise the AI model (autonomy engine). +# Run Docs +1. Run the command below +``` +python3 generate_swagger.py +``` +2. Go to `http://127.0.0.1:5000/soardocs/` # 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/acknowledgement.json b/examples/all/acknowledgement.json index 4052202..e8ca460 100644 --- a/examples/all/acknowledgement.json +++ b/examples/all/acknowledgement.json @@ -1,13 +1,12 @@ { - "message_ID": "b427003c-7bc8-11ed-a1eb-0242ac120002", + "message_ID": "b427003c-0000-11aa-a1eb-bvcdfghjgfdd", "timestamp": "2022-11-16T00:00:00Z", - "version": 1, - "source": "hydrosurv_adapter", - "destination": "autonomy_engine", + "version": 2, + "source": "autonomy_engine", + "destination": "ah1", + "delivery_type": "publish", "encoded": false, - "type": "acknowledgement", - "payload": { - "message_ID": "b427003c-7bc8-11ed-a1eb-0242ac999999", - "status": "executed" - } + "message_type": "platform_status", + "acknowledged_message_ID": "02125022255-7bc8-11ed-a1eb-0242ac999999", + "status": "executed by platform" } \ No newline at end of file diff --git a/examples/all/mission_plan.json b/examples/all/mission_plan.json index add7383..c99d52b 100644 --- a/examples/all/mission_plan.json +++ b/examples/all/mission_plan.json @@ -1,25 +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": "autonomy_engine", - "destination": "ah-1", + "destination": "hydrosurv_adapter", + "delivery_type": "publish", "encoded": false, - "type": "platform_status", - "payload": { - "plan_ID": 1, - "platform_serial": "reav-60", - "plan": [ - { - "action": "move", - "flight_style": "orbit", - "latitude_waypoint": -4.187143188645706, - "longitude_waypoint": 50.37072283932642, - "altitude": 0, - "depth": 0, - "activate_payload": false, - "send_environmental_data": false - } - ] - } -} \ No newline at end of file + "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" +} diff --git a/examples/all/platform_status.json b/examples/all/platform_status.json index b459ecb..8a24e98 100644 --- a/examples/all/platform_status.json +++ b/examples/all/platform_status.json @@ -1,41 +1,41 @@ { - "message_ID": "b427003c-7bc8-11ed-a1eb-0242ac120002", + "message_ID": "b427003c-0000-11aa-a1eb-bvcdfghjgfdd", "timestamp": "2022-11-16T00:00:00Z", - "version": 1, + "version": 2, "source": "hydrosurv_adapter", "destination": "autonomy_engine", + "delivery_type": "publish", "encoded": false, - "type": "platform_status", - "payload": { - "platform_ID": 1, - "active": true, - "platform_state": "ORBIT", - "autonomy_plan_ID": 1, - "mission_track_ID": 4, - "mission_action_ID": 1, - "range_to_go": 0.3, - "speed_over_ground": 0.3, - "water_current_velocity": 0.3, - "thrust_applied": 0.3, - "health_status": "Warning", - "gps_data": [ - { - "gps_source": "internal", - "latitude_type": "", - "longitude_type": "", - "latitude": -7.432, - "longitude": 50.365, - "depth": 0.0, - "altitude": 0.0 - } - ], - "localisation_error": null, - "usbl_fix_seconds_ago": null, - "battery_remaining_capacity": 80, - "sensor_config": { - "sensor_name": null, - "sensor_status": false, - "additional_data": null + "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" } - } - } \ No newline at end of file + ], + "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 + } diff --git a/examples/hydrosurv_adapter/acknowledgement.json b/examples/hydrosurv_adapter/acknowledgement.json index 4052202..e8ca460 100644 --- a/examples/hydrosurv_adapter/acknowledgement.json +++ b/examples/hydrosurv_adapter/acknowledgement.json @@ -1,13 +1,12 @@ { - "message_ID": "b427003c-7bc8-11ed-a1eb-0242ac120002", + "message_ID": "b427003c-0000-11aa-a1eb-bvcdfghjgfdd", "timestamp": "2022-11-16T00:00:00Z", - "version": 1, - "source": "hydrosurv_adapter", - "destination": "autonomy_engine", + "version": 2, + "source": "autonomy_engine", + "destination": "ah1", + "delivery_type": "publish", "encoded": false, - "type": "acknowledgement", - "payload": { - "message_ID": "b427003c-7bc8-11ed-a1eb-0242ac999999", - "status": "executed" - } + "message_type": "platform_status", + "acknowledged_message_ID": "02125022255-7bc8-11ed-a1eb-0242ac999999", + "status": "executed by platform" } \ No newline at end of file diff --git a/examples/hydrosurv_adapter/mission_plan.json b/examples/hydrosurv_adapter/mission_plan.json index add7383..c99d52b 100644 --- a/examples/hydrosurv_adapter/mission_plan.json +++ b/examples/hydrosurv_adapter/mission_plan.json @@ -1,25 +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": "autonomy_engine", - "destination": "ah-1", + "destination": "hydrosurv_adapter", + "delivery_type": "publish", "encoded": false, - "type": "platform_status", - "payload": { - "plan_ID": 1, - "platform_serial": "reav-60", - "plan": [ - { - "action": "move", - "flight_style": "orbit", - "latitude_waypoint": -4.187143188645706, - "longitude_waypoint": 50.37072283932642, - "altitude": 0, - "depth": 0, - "activate_payload": false, - "send_environmental_data": false - } - ] - } -} \ No newline at end of file + "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" +} diff --git a/examples/hydrosurv_adapter/platform_status.json b/examples/hydrosurv_adapter/platform_status.json index b459ecb..8a24e98 100644 --- a/examples/hydrosurv_adapter/platform_status.json +++ b/examples/hydrosurv_adapter/platform_status.json @@ -1,41 +1,41 @@ { - "message_ID": "b427003c-7bc8-11ed-a1eb-0242ac120002", + "message_ID": "b427003c-0000-11aa-a1eb-bvcdfghjgfdd", "timestamp": "2022-11-16T00:00:00Z", - "version": 1, + "version": 2, "source": "hydrosurv_adapter", "destination": "autonomy_engine", + "delivery_type": "publish", "encoded": false, - "type": "platform_status", - "payload": { - "platform_ID": 1, - "active": true, - "platform_state": "ORBIT", - "autonomy_plan_ID": 1, - "mission_track_ID": 4, - "mission_action_ID": 1, - "range_to_go": 0.3, - "speed_over_ground": 0.3, - "water_current_velocity": 0.3, - "thrust_applied": 0.3, - "health_status": "Warning", - "gps_data": [ - { - "gps_source": "internal", - "latitude_type": "", - "longitude_type": "", - "latitude": -7.432, - "longitude": 50.365, - "depth": 0.0, - "altitude": 0.0 - } - ], - "localisation_error": null, - "usbl_fix_seconds_ago": null, - "battery_remaining_capacity": 80, - "sensor_config": { - "sensor_name": null, - "sensor_status": false, - "additional_data": null + "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" } - } - } \ No newline at end of file + ], + "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 + } diff --git a/formats/acknowledgement.py b/formats/acknowledgement.py index 6c6d965..5021b4f 100644 --- a/formats/acknowledgement.py +++ b/formats/acknowledgement.py @@ -3,12 +3,14 @@ receipt of message. """ acknowledgement_schema = { + "allOf": [{"$ref": "#/components/schemas/Message"}], + "type": "object", "properties": { - "message_ID": { + "acknowledged_message_ID": { "type": "string", "description": "Identifier of message received and executed with " + "success for mission plans sent by the Autonomy Engine.", - "example": "b427003c-7bc8-11ed-a1eb-0242ac999999", + "example": "02125022255-7bc8-11ed-a1eb-0242ac999999", }, "status": { "type": "string", @@ -18,7 +20,7 @@ acknowledgement_schema = { "example": "executed by platform", }, }, - "required": ["message_ID", "status"], + "required": ["acknowledged_message_ID", "status"], } # acknowledgement_schema = api.model( diff --git a/formats/message_wrapper.py b/formats/message_wrapper.py index b9bebfa..8762dd6 100644 --- a/formats/message_wrapper.py +++ b/formats/message_wrapper.py @@ -13,7 +13,7 @@ message_wrapper_schema = { "message_ID": { "type": "string", "description": "An identifier for the type of " + "message received.", - "example": "PlatformStatus", + "example": "b427003c-0000-11aa-a1eb-bvcdfghjgfdd", }, "timestamp": { "type": "date-time", diff --git a/formats/observation.py b/formats/observation.py index 8cfa412..da8cd04 100644 --- a/formats/observation.py +++ b/formats/observation.py @@ -1,5 +1,5 @@ """ - schema: platform-specific decoded status message (DRAFT) + schema: Observation Message sent by platforms when points of interest are found. """ # from . import full_message_schema, api # from flask_restx import fields diff --git a/generate_swagger.py b/generate_swagger.py index 678c1bb..1abd4b9 100644 --- a/generate_swagger.py +++ b/generate_swagger.py @@ -7,6 +7,7 @@ from formats.mission_plan import mission_plan_schema from formats.observation import observation_schema from formats.planning_configuration import planning_configuration_schema from formats.platform_status import platform_status_message_schema +from formats.acknowledgement import acknowledgement_schema app = Flask(__name__) @@ -35,6 +36,7 @@ swagger_config = { "Observation": observation_schema, "PlanningConfiguration": planning_configuration_schema, "PlatformStatus": platform_status_message_schema, + "Acknowledgement": acknowledgement_schema, }, }, "paths": { @@ -50,7 +52,7 @@ swagger_config = { "oneOf": [ { "$ref": "#/components/" - + "schemas/Coordinate" + + "schemas/Acknowledgement" }, { "$ref": "#/components/" diff --git a/project/SOAR_README.md b/project/SOAR_README.md index b73f417..74338d8 100644 --- a/project/SOAR_README.md +++ b/project/SOAR_README.md @@ -42,3 +42,10 @@ Squad of Adaptive Robots Project | NOC (AH1) | emergency | GUI | TBD – AH1 (ABORT command via Black Box) | TBD | TBD | TBD – all platforms pre-compiled ABORT via Black box | | NOC (GUI) | planning configuration | GUI | Autonomy Engine | Yes | No | N/A | | NOC (GUI) | emergency | GUI | TBD | TBD | TBD | TBD | + +## Run Docs +1. Run the command below +``` +python3 generate_swagger.py +``` +2. Go to `http://127.0.0.1:5000/soardocs/` -- GitLab