Commit f7ad53ea authored by Trishna Saeharaseelan's avatar Trishna Saeharaseelan
Browse files

fix: examples for hydrosurv and correct SOAR_README.md

parent 42a832fe
This commit is part of merge request !2. Comments created here will be created in the context of that merge request.
......@@ -2,6 +2,7 @@
from flask_restx import Api
from flask import Flask
# import os
__all__ = [
......@@ -11,4 +12,3 @@ __all__ = [
app = Flask(__name__)
api = Api(app)
# api = Marshmallow(app)
......@@ -18,7 +18,8 @@ swagger_template = dict(
"title": LazyString(lambda: "SoAR Backbone Message Formats"),
"version": LazyString(lambda: "0.1"),
"description": LazyString(
lambda: "Backbone Message Format component for the Squad of Autonomous Robots (SoAR) message definitions."
lambda: "Backbone Message Format component for the Squad of"
+ " Autonomous Robots (SoAR) message definitions."
),
},
host=LazyString(lambda: request.host),
......@@ -28,11 +29,21 @@ swagger_template = dict(
full_message_schema = api.model(
"FullMessageSchema",
{
"message_ID": fields.String(
required=True,
description="UUID assigned to this message",
example="b427003c-7bc8-11ed-a1eb-0242ac120002",
),
"timestamp": fields.DateTime(
required=True,
description="Timestamp of message",
example="2022-11-16T00:00:00Z",
),
"version": fields.Float(
required=True,
description="Version of comms bacbone messaging format protocol",
example=2.0,
),
"source": fields.String(
required=True,
description="Where is this message from",
......@@ -61,7 +72,30 @@ full_message_schema = api.model(
),
},
)
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",
),
},
)
constraints_schema = api.model(
"ConstraintsSchema",
{
......@@ -89,27 +123,23 @@ platform_schema = api.model(
"platform_ID": fields.Integer(
required=True,
description="unique identifier for platform",
example="ah-1",
example=1,
),
"serial": fields.Integer(
"serial": fields.String(
required=True,
description="platform serial number",
example="ah-1",
example="reav-60",
),
"model": fields.Integer(
"model": fields.String(
required=True,
description="platform serial number",
example="ah-1",
example="reav",
),
"constraints": fields.Nested(constraints_schema),
"active": fields.Boolean(
required=False,
description="When a platform is in deployment (executing a mission plan) this should be True",
example=True,
),
},
)
action_schema = api.model(
"AutonomyEngineAction",
{
......@@ -121,7 +151,8 @@ action_schema = api.model(
),
"flight_style": fields.String(
required=False,
description="Platform-specific modes/flight styles to perform next action",
description="Platform-specific modes/flight styles to perform"
+ " next action",
example="orbit",
),
"latitude_waypoint": fields.Float(
......@@ -152,17 +183,8 @@ action_schema = api.model(
),
"send_environmental_data": fields.Boolean(
required=False,
description="To trigger the platform to send list of observations if any found",
example=False,
),
"scanline": fields.Boolean(
required=False,
description="To trigger the platform to scan-line",
example=False,
),
"scanpoint": fields.Boolean(
required=False,
description="To trigger the platform to send list of observations if any found",
description="DO WE NEED THIS? To trigger the platform to send"
+ " list of observations if any found",
example=False,
),
},
......@@ -189,8 +211,8 @@ mission_plan_schema = api.model(
"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.",
),
},
)
......@@ -212,17 +234,20 @@ observation_schema = api.model(
# properties of each observation?
"points_of_interest": fields.Float(
required=False,
description="Points from features of interest identified by platform if any found. DEFINE FORMAT.",
description="Points from features of interest identified by"
+ " platform if any found. DEFINE FORMAT.",
example="",
),
"region_surveyed": fields.Float(
required=False,
description="Region surveyed by given platform. DEFINE FORMAT. GEOJSON?",
description="Region surveyed by given platform. DEFINE FORMAT."
+ " GEOJSON?",
example="",
),
"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(
......@@ -239,7 +264,8 @@ region_schema = api.model(
{
"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": [
......@@ -284,7 +310,8 @@ squad_metadata_schema = api.model(
),
"squad_mission_type": fields.String(
required=True,
description="Mission of given squad: `tracking`, `survey`, `inspection`",
description="Mission of given squad: `tracking`, `survey`,"
+ " `inspection`",
example="survey",
),
"squad_state": fields.Boolean(
......@@ -334,7 +361,8 @@ gps_schema = api.model(
{
"gps_source": fields.Float( # TODO: TBD with partners
required=False,
description="Source of gps position. E.g. USBL (external), platform itself (internal)",
description="Source of gps position. E.g. USBL (external), "
+ "platform itself (internal)",
example="internal",
),
"latitude_type": fields.String(
......@@ -371,26 +399,6 @@ gps_schema = api.model(
},
)
sensor_schema = api.model(
"Sensor",
{
"sensor_name": fields.String(
required=False,
description="Name of sensor (e.g. MBES for AH1 and SideScan for Ecosub",
example="MBES",
),
"sensor_status": fields.Boolean(
required=False,
description="Sensor switched on (True) or off (False)",
example=True,
),
"additional_data": fields.Raw(
required=False,
description="Add any additional sensor-related data here.",
example={"sensor_loadtime_seconds": 30.0},
),
},
)
platform_status_message_schema = api.model(
"platformStatusMessage",
{
......@@ -399,7 +407,17 @@ platform_status_message_schema = api.model(
required=True,
description="Message header",
),
"platform": fields.Nested(platform_schema),
"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,
......@@ -409,7 +427,8 @@ platform_status_message_schema = api.model(
),
"autonomy_plan_ID": fields.Integer(
required=False,
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) executed by platform",
example=1,
),
"mission_track_ID": fields.Integer(
......@@ -452,9 +471,8 @@ platform_status_message_schema = api.model(
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
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",
),
......@@ -470,7 +488,8 @@ platform_status_message_schema = api.model(
),
"battery_remaining_capacity": fields.Float(
required=True,
description="Battery remaining capacity % provided by respective platform/C2.",
description="Battery remaining capacity % provided by respective"
+ " platform/C2.",
example=80.0,
),
"sensor_config": fields.Nested(
......@@ -495,14 +514,14 @@ acknowledgement_schema = api.model(
),
"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",
),
},
)
swagger_config = {
"headers": [],
"specs": [
......@@ -530,7 +549,11 @@ swagger_config = {
swagger = Swagger(app, template=swagger_template, config=swagger_config)
ns1 = api.namespace("message", description="Message Wrapper (Full Message Schema) Format")
ns1 = api.namespace(
"message", description="Message Wrapper (Full Message Schema) Format"
)
@ns1.route("/wrapper")
class MessageWrapper(Resource):
@ns1.response(200, "Success", full_message_schema)
......@@ -538,7 +561,12 @@ class MessageWrapper(Resource):
pass
ns2 = api.namespace("platform_status", description="platform Status Message Format")
ns2 = api.namespace(
"platform_status",
description="platform Status Message Format",
)
@ns2.route("")
class platformStatus(Resource):
@ns2.response(200, "Success", platform_status_message_schema)
......@@ -547,9 +575,12 @@ class platformStatus(Resource):
ns3 = api.namespace(
"planning_configuration", description="Planning Configuration Format. Do we want region of interest to be per squad, per platform or in the main schema?"
"planning_configuration",
description="Planning Configuration Format. Do we want region of "
+ "interest to be per squad, per platform or in the main schema?",
)
@ns3.route("")
class PlanningConfiguration(Resource):
@ns3.response(200, "Success", planning_configuration_schema)
......@@ -558,8 +589,13 @@ class PlanningConfiguration(Resource):
# @api.route('/mission-plan/<str:platform_type')
# @api.doc(params={"platform_type": "The type of platform of the mission plan to target."})
ns4 = api.namespace("mission_plan", description="Mission Plan Format Per platform")
# @api.doc(params={"platform_type": "The type of platform of the
# mission plan to target."})
ns4 = api.namespace(
"mission_plan",
description="Mission Plan Format Per platform",
)
@ns4.route("")
class MissionPlan(Resource):
......@@ -567,18 +603,29 @@ class MissionPlan(Resource):
def get(self):
pass
ns5 = api.namespace("observation", description="Observation Format --> Per platform or generic?")
ns5 = api.namespace(
"observation",
description="Observation Format --> Per platform or generic?",
)
@ns5.route("")
class Observation(Resource):
@ns5.response(200, "Success", observation_schema)
def get(self):
pass
ns6 = api.namespace("acknowledgement", description="Acknowledgment Format")
@ns6.route("")
class Acknowledgment(Resource):
@ns6.response(200, "Success", acknowledgement_schema)
def get(self):
pass
if __name__ == "__main__":
app.run()
{
"message_ID": "b427003c-7bc8-11ed-a1eb-0242ac120002",
"timestamp": "2022-11-16T00:00:00Z",
"version": 1,
"source": "hydrosurv_adapter",
"destination": "autonomy_engine",
"encoded": false,
"type": "platform_status",
"type": "acknowledgement",
"payload": {
"message_ID": 202,
"message_ID": "b427003c-7bc8-11ed-a1eb-0242ac999999",
"status": "executed"
}
}
\ No newline at end of file
{
"message_ID": "b427003c-7bc8-11ed-a1eb-0242ac120002",
"timestamp": "2022-11-16T00:00:00Z",
"source": "hydrosurv_adapter",
"destination": "autonomy_engine",
"version": 2,
"source": "autonomy_engine",
"destination": "ah-1",
"encoded": false,
"type": "platform_status",
"payload": {
......@@ -16,9 +18,7 @@
"altitude": 0,
"depth": 0,
"activate_payload": false,
"send_environmental_data": false,
"scanline": false,
"scanpoint": false
"send_environmental_data": false
}
]
}
......
{
"message_ID": "b427003c-7bc8-11ed-a1eb-0242ac120002",
"timestamp": "2022-11-16T00:00:00Z",
"source": "hydrosurv_adapter",
"version": 2,
"source": "ecosub_c2",
"destination": "autonomy_engine",
"encoded": false,
"type": "platform_status",
"payload": {
"platform_serial":"ecosub-3",
"points_of_interest": "",
"region_surveyed": "",
"points_of_interest": [],
"region_surveyed": [],
"quality_of_points": 0.98,
"additional_data": {
"sensor_x": false
......
{
"message_ID": "b427003c-7bc8-11ed-a1eb-0242ac120002",
"timestamp": "2022-11-16T00:00:00Z",
"source": "gui",
"destination": "autonomy_engine",
"version": 2,
"source": "autonomy_engine",
"destination": "ah-1",
"encoded": false,
"type": "platform_status",
"payload": {
......
{
"message_ID": "b427003c-7bc8-11ed-a1eb-0242ac120002",
"timestamp": "2022-11-16T00:00:00Z",
"version": 1,
"source": "hydrosurv_adapter",
"destination": "autonomy_engine",
"encoded": false,
"type": "platform_status",
"payload": {
"platform": {
"platform_ID": 2,
"serial": "ah-1",
"model": "ah-1",
"constraints": {
"min_altitude": 15.2,
"min_velocity": 0.1,
"max_velocity": 0.9
},
"active": true
},
"platform_state": "IDLE",
"platform_ID": 1,
"active": true,
"platform_state": "ORBIT",
"autonomy_plan_ID": 1,
"mission_track_ID": 4,
"mission_action_ID": 1,
"range_to_go": 124.3,
"speed_over_ground": 124.3,
"water_current_velocity": 124.3,
"thrust_applied": 124.3,
"range_to_go": 0.3,
"speed_over_ground": 0.3,
"water_current_velocity": 0.3,
"thrust_applied": 0.3,
"health_status": "Warning",
"gps_data": [
{
......@@ -36,16 +29,13 @@
"altitude": 0.0
}
],
"localisation_error": 0.008,
"usbl_fix_seconds_ago": 20.3,
"localisation_error": null,
"usbl_fix_seconds_ago": null,
"battery_remaining_capacity": 80,
"sensor_config": {
"sensor_name": "MBES",
"sensor_status": false,
"additional_data": {
"sensor_loadtime_seconds": 30
}
}
"sensor_name": null,
"sensor_status": false,
"additional_data": null
}
}
}
\ No newline at end of file
}
\ No newline at end of file
{
"timestamp": "2022-11-16T00:00:00Z",
"source": "gui",
"destination": "autonomy_engine",
"encoded": false,
"type": "platform_status",
"payload": {
"ID": 3,
"squads": {
"squad_ID": 23,
"no_of_platforms": 3,
"platforms": [
{
"platform_ID": 1,
"serial": "ah-1",
"model": "ah-1",
"constraints": {
"min_altitude": 15.2,
"min_velocity": 0.1,
"max_velocity": 0.9
},
"active": true
}
],
"squad_mission_type": "survey",
"squad_state": false,
"region_of_interest": [
{
"region": {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"coordinates": [
[
[
-4.187143188645706,
50.37072283932642
],
[
-4.202697005964865,
50.368816892405874
],
[
-4.203156724702808,
50.365640144076906
],
[
-4.19449868846155,
50.362267670845654
]
]
],
"type": "Polygon"
}
}
]
}
}
],
"exclusion_zones": [
{
"region": {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"coordinates": [
[
[
-4.187143188645706,
50.37072283932642
],
[
-4.202697005964865,
50.368816892405874
],
[
-4.203156724702808,
50.365640144076906
],
[
-4.19449868846155,
50.362267670845654
]
]
],
"type": "Polygon"
}
}
]
}
}
]
}
}
}
\ No newline at end of file
{
"message_ID": "b427003c-7bc8-11ed-a1eb-0242ac120002",
"timestamp": "2022-11-16T00:00:00Z",
"source": "hydrosurv_adapter",
"destination": "autonomy_engine",
"version": 2,
"source": "autonomy_engine",
"destination": "ecosub_c2",
"encoded": false,
"type": "platform_status",
"type": "mission_plan",
"payload": {
"plan_ID": 1,
"platform_serial": "reav-60",
"plan_ID": 3,
"platform_serial": "ecosub-4",
"plan": [
{
"action": "move",
"flight_style": "orbit",
"flight_style": "dive",
"latitude_waypoint": -4.187143188645706,
"longitude_waypoint": 50.37072283932642,
"altitude": 0,
"depth": 0,
"activate_payload": false,
"send_environmental_data": false,
"scanline": false,
"scanpoint": false
"altitude": 20,
"depth": null,
"activate_payload": true,
"send_environmental_data": false
}
]
}
......
{
"message_ID": "b427003c-7bc8-11ed-a1eb-0242ac120002",
"timestamp": "2022-11-16T00:00:00Z",
"source": "hydrosurv_adapter",
"version": 2,
"source": "ecosub_c2",
"destination": "autonomy_engine",
"encoded": false,
"type": "platform_status",
"payload": {
"platform_serial":"ecosub-3",
"points_of_interest": "",
"region_surveyed": "",
"points_of_interest": [],
"region_surveyed": [],
"quality_of_points": 0.98,
"additional_data": {
"sensor_x": false
......
{
"message_ID": "b427003c-7bc8-11ed-a1eb-0242ac120002",
"timestamp": "2022-11-16T00:00:00Z",
"source": "hydrosurv_adapter",
"version": 1,
"source": "hermes_ecosub",
"destination": "autonomy_engine",
"encoded": false,
"type": "platform_status",
"payload": {
"platform": {
"platform_ID": 2,
"serial": "ah-1",
"model": "ah-1",
"constraints": {
"min_altitude": 15.2,
"min_velocity": 0.1,
"max_velocity": 0.9
},
"active": true
},
"platform_ID": 2,
"active": true,
"platform_state": "IDLE",
"autonomy_plan_ID": 1,
"mission_track_ID": 4,
"mission_action_ID": 1,
"range_to_go": 124.3,
"speed_over_ground": 124.3,
"water_current_velocity": 124.3,
"thrust_applied": 124.3,
"range_to_go": 12.3,
"speed_over_ground": 10.3,
"water_current_velocity": 10.3,
"thrust_applied": 0.3,
"health_status": "Warning",
"gps_data": [
{
......@@ -32,20 +25,20 @@
"longitude_type": "",
"latitude": -7.432,
"longitude": 50.365,
"depth": 0.0,
"altitude": 0.0
"depth": 5.0,
"altitude": 20.0
}
],
"localisation_error": 0.008,
"usbl_fix_seconds_ago": 20.3,
"localisation_error": null,
"usbl_fix_seconds_ago": null,
"battery_remaining_capacity": 80,
"sensor_config": {
"sensor_name": "MBES",
"sensor_status": false,
"additional_data": {
"sensor_loadtime_seconds": 30
}
"sensor_ID": 22,
"serial": "sidescan-2x",
"sensor_status": true,
"additional_data": {
"whiskers_on": true
}
}
}
}
\ No newline at end of file
}
\ No newline at end of file
{
"message_ID": "b427003c-7bc8-11ed-a1eb-0242ac120002",
"timestamp": "2022-11-16T00:00:00Z",
"version": 1,
"source": "hydrosurv_adapter",
"destination": "autonomy_engine",
"encoded": false,
"type": "platform_status",
"type": "acknowledgement",
"payload": {
"message_ID": 202,
"message_ID": "b427003c-7bc8-11ed-a1eb-0242ac999999",
"status": "executed"
}
}
\ No newline at end of file
{
"message_ID": "b427003c-7bc8-11ed-a1eb-0242ac120002",
"timestamp": "2022-11-16T00:00:00Z",
"source": "hydrosurv_adapter",
"destination": "autonomy_engine",
"version": 2,
"source": "autonomy_engine",
"destination": "ah-1",
"encoded": false,
"type": "platform_status",
"payload": {
......@@ -16,9 +18,7 @@
"altitude": 0,
"depth": 0,
"activate_payload": false,
"send_environmental_data": false,
"scanline": false,
"scanpoint": false
"send_environmental_data": false
}
]
}
......
{
"message_ID": "b427003c-7bc8-11ed-a1eb-0242ac120002",
"timestamp": "2022-11-16T00:00:00Z",
"version": 1,
"source": "hydrosurv_adapter",
"destination": "autonomy_engine",
"encoded": false,
"type": "platform_status",
"payload": {
"platform": {
"platform_ID": 23,
"serial": "ah-1",
"model": "ah-1",
"constraints": {
"min_altitude": 15.2,
"min_velocity": 0.1,
"max_velocity": 0.9
},
"active": true
},
"platform_state": "IDLE",
"platform_ID": 1,
"active": true,
"platform_state": "ORBIT",
"autonomy_plan_ID": 1,
"mission_track_ID": 4,
"mission_action_ID": 1,
"range_to_go": 124.3,
"speed_over_ground": 124.3,
"water_current_velocity": 124.3,
"thrust_applied": 124.3,
"range_to_go": 0.3,
"speed_over_ground": 0.3,
"water_current_velocity": 0.3,
"thrust_applied": 0.3,
"health_status": "Warning",
"gps_data": [
{
......@@ -36,16 +29,13 @@
"altitude": 0.0
}
],
"localisation_error": 0.008,
"usbl_fix_seconds_ago": 20.3,
"localisation_error": null,
"usbl_fix_seconds_ago": null,
"battery_remaining_capacity": 80,
"sensor_config": {
"sensor_name": "MBES",
"sensor_status": false,
"additional_data": {
"sensor_loadtime_seconds": 30
}
}
"sensor_name": null,
"sensor_status": false,
"additional_data": null
}
}
}
\ No newline at end of file
}
\ No newline at end of file
......@@ -21,11 +21,21 @@ message_types = [
full_message_schema = api.model(
"FullMessageSchema",
{
"message_ID": fields.String(
required=True,
description="UUID assigned to this message",
example="b427003c-7bc8-11ed-a1eb-0242ac120002",
),
"timestamp": fields.DateTime(
required=True,
description="Timestamp of message",
example="2022-11-16T00:00:00Z",
),
"version": fields.Float(
required=True,
description="Version of comms bacbone messaging format protocol",
example=2.0,
),
"source": fields.String(
required=True,
description="Where is this message from",
......@@ -82,23 +92,18 @@ platform_schema = api.model(
"platform_ID": fields.Integer(
required=True,
description="unique identifier for platform",
example="ah-1",
example=1,
),
"serial": fields.Integer(
"serial": fields.String(
required=True,
description="platform serial number",
example="ah-1",
example="reav-60",
),
"model": fields.Integer(
"model": fields.String(
required=True,
description="platform serial number",
example="ah-1",
example="reav",
),
"constraints": fields.Nested(constraints_schema),
"active": fields.Boolean(
required=False,
description="When a platform is in deployment (executing a mission plan) this should be True",
example=True,
),
},
)
......@@ -22,8 +22,9 @@ acknowledgement_schema = api.model(
),
"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",
),
},
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment