Commit 42a832fe authored by Trishna Saeharaseelan's avatar Trishna Saeharaseelan
Browse files

refactor: add new example json messages

......@@ -23,47 +23,11 @@ swagger_template = dict(
},
host=LazyString(lambda: request.host),
)
message_header_schema = api.model(
"MessageHeader",
{
"timestamp": fields.DateTime(
required=True,
description="Timestamp of message",
example="2022-11-16T00:00:00Z",
),
"source": fields.String(
required=True,
description="Where is this message from",
example="autonomy_engine",
),
"destination": fields.String(
required=True,
description="What is the destination of this message",
example="ah-1",
),
"encoded": fields.Boolean(
required=True,
description="Indicate that message raw (encoded) or decoded. "
+ "Options: encoded=True, decoded=False",
example=False,
),
"type": fields.String(
required=True,
description="Type of message",
example="platform_status",
),
"payload": fields.Raw(required=True) # TODO: schema applicable changes according to "type"
},
)
full_message_schema = api.model(
"FullMessageSchema",
{
"uuid": fields.DateTime( # add this
required=True,
description="Timestamp of message",
example="2022-11-16T00:00:00Z",
),
"timestamp": fields.DateTime(
required=True,
description="Timestamp of message",
......@@ -95,10 +59,9 @@ full_message_schema = api.model(
description="Content of Message",
# example="{}",
),
}
},
)
constraints_schema = api.model(
"ConstraintsSchema",
{
......@@ -147,18 +110,172 @@ platform_schema = api.model(
},
)
action_schema = api.model(
"AutonomyEngineAction",
{
"action": fields.String(
required=True,
description="Autonomy Engine's action from `move`, `payload`,"
+ " `dive`, `send_hits`, `scanline`, `scanpoint`.",
example="move",
),
"flight_style": fields.String(
required=False,
description="Platform-specific modes/flight styles to perform next action",
example="orbit",
),
"latitude_waypoint": fields.Float(
required=True,
description="Next waypoint, x-coordinate",
example=-4.187143188645706,
),
"longitude_waypoint": fields.Float(
required=True,
description="Next waypoint, y-coordinate",
example=50.37072283932642,
),
"altitude": fields.Float(
required=False,
description="Altitude of next action",
example=15.0,
),
"depth": fields.Float(
required=False,
description="Depth of next action",
example=15.0,
),
"activate_payload": fields.Boolean(
required=False,
description="To activate/deactivate sensor for Autosub "
+ "Hover-1 --> `MBES` sensor and for EcoSUB --> `Sidescan`",
example=True,
),
"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",
example=False,
),
},
)
mission_plan_schema = api.model(
"MissionPlan",
{
"message": fields.Nested(
full_message_schema,
required=True,
description="Message header",
),
"plan_ID": fields.Integer(
required=True,
description="Identifier of given mission sequence planned",
example=1,
),
"platform_serial": fields.String(
required=True,
description="Serial of target platform to send mission to",
example="reav-60",
),
"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.",
),
},
)
observation_schema = api.model(
"Observation",
{
"message": fields.Nested(
full_message_schema,
required=True,
description="Message header",
),
"platform_serial": fields.String(
required=True,
description="Serial of platform to sendign observations",
example="ecosub-3",
),
# "observation_type" ==> payloads tied to different types maybe?
# 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.",
example="",
),
"region_surveyed": fields.Float(
required=False,
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.",
example=0.98,
),
"additional_data": fields.Raw(
required=False,
description="Placeholder field for any additional data",
example={"sensor_payload": False},
),
},
)
region_schema = api.model(
"RegionSchema",
{
"region": fields.Raw(
required=True,
description="Using GEOJSON, exact region of interest in rectangle format polygon",
example={
"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",
},
}
],
},
),
},
)
squad_metadata_schema = api.model(
"SquadMetadataSchema",
{
"squad_ID": fields.Integer(
required=True,
description="Identifier of given squad",
example="ah-1",
example=23,
),
"no_of_platforms": fields.Integer(
required=True,
description="number of platforms",
example="ah-1",
description="Number of platforms",
example=3,
),
"platforms": fields.List(
fields.Nested(platform_schema),
......@@ -175,9 +292,43 @@ squad_metadata_schema = api.model(
description="In execution, Waiting.. <define further>",
example=False,
),
"region_of_interest": fields.List(
fields.Nested(region_schema),
required=False,
description="Region of interest and exclusion zones per squad.",
),
"exclusion_zones": fields.List(
fields.Nested(region_schema),
required=True,
description="Exclusion zones exclusion zones per squad.",
),
},
)
planning_configuration_schema = api.model(
"PlanningConfigurationSchema",
{
"message": fields.Nested(
full_message_schema,
required=True,
description="Message header",
),
"ID": fields.Integer(
required=True,
description="Unique identifier tagged to version of this"
+ " configuration plan",
example=3,
),
"squads": fields.Nested(
squad_metadata_schema,
required=False,
description="Details of each squad",
),
},
)
gps_schema = api.model(
"GPS",
{
......@@ -216,52 +367,10 @@ gps_schema = api.model(
description="Altitude in <DEFINE UNITS>",
example="",
),
# "gps_fix_seconds_ago": fields.Float(
# required=False,
# description="",
# example="",
# ),
# "gps_fix_seconds_ago"
},
)
observation_schema = api.model(
"Observation",
{
"message": fields.Nested(
message_header_schema,
required=True,
description="Message header",
),
"platform": fields.Nested(platform_schema),
"time": fields.String(
required=True,
description="Timestamp of message",
example="2022-11-16T00:00:00Z",
),
# "observation_type" ==> payloads tied to different types maybe?
# 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.",
example="",
),
"region_surveyed": fields.Float(
required=False,
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.",
example=0.98,
),
"additional_data": fields.Raw(
required=False,
description="Placeholder field for any additional data",
example={"sensor_payload": False},
),
}
)
sensor_schema = api.model(
"Sensor",
{
......@@ -280,13 +389,13 @@ sensor_schema = api.model(
description="Add any additional sensor-related data here.",
example={"sensor_loadtime_seconds": 30.0},
),
}
},
)
platform_status_message_schema = api.model(
"platformStatusMessage",
{
"message": fields.Nested(
message_header_schema,
full_message_schema,
required=True,
description="Message header",
),
......@@ -298,7 +407,7 @@ platform_status_message_schema = api.model(
+ "STOP, IDLE, ABORT.",
example="IDLE",
),
"autonomy_mission_ID": fields.Integer(
"autonomy_plan_ID": fields.Integer(
required=False,
description="Last mission plan ID (according to Autonomy Engine's mission plan number) executed by platform",
example=1,
......@@ -343,9 +452,11 @@ 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="GPS of each platform",
description="Metadata pf each platform",
),
"localisation_error": fields.Float(
required=False,
......@@ -362,40 +473,36 @@ platform_status_message_schema = api.model(
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
"sensor_config": fields.Nested(
sensor_schema
), # TODO: TBD Do we want a list of sensors to allow > 1 sensor
},
)
mission_plan_schema = api.model(
"MissionPlan",
acknowledgement_schema = api.model(
"Acknowledgement",
{
"message": fields.Nested(
message_header_schema,
full_message_schema,
required=True,
description="Message header",
),
"ID": fields.Integer(
"message_ID": fields.Integer(
required=True,
description="Unique identifier tagged to version of this"
+ " configuration plan",
example=3,
description="Identifier of message received and executed with "
+ "success for mission plans sent by the Autonomy Engine.",
example=202,
),
"time": fields.String(
"status": fields.String(
required=True,
description="",
example="",
description="Highest level of acknowledgement. I.e. `c2_received`: Received by C2,"
+ " `c2_sent`: Sent from C2->Platform, `executed`: Executed by platform",
),
"platform_ID": fields.Integer(
required=False,
description="Details of each squad",
),
"payload": fields.Raw(
required=True,
)
},
)
swagger_config = {
"headers": [],
"specs": [
......@@ -420,94 +527,6 @@ swagger_config = {
"consumes": ["application/json"],
}
autonomy_configuration_schema = api.model(
"SquadConfigurationSchema",
{
"message": fields.Nested(
message_header_schema,
required=True,
description="Message header",
),
"ID": fields.Integer(
required=True,
description="Unique identifier tagged to version of this"
+ " configuration plan",
example=3,
),
"time": fields.String(
required=True,
description="",
example="",
),
"squads": fields.Nested(
squad_metadata_schema,
required=False,
description="Details of each squad",
),
"region_of_operation": fields.Raw(
required=True,
description="Using GEOJSON, exact region of interest EXCLUDING exclusion zone",
example={
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"coordinates": [
[
[
-4.187143188645706,
50.37072283932642
],
[
-4.202697005964865,
50.368816892405874
],
[
-4.203156724702808,
50.365640144076906
],
[
-4.19449868846155,
50.362267670845654
],
[
-4.187373048015246,
50.35933489062816
],
[
-4.1859938917992565,
50.36207215780212
],
[
-4.188598964651192,
50.36471151593676
],
[
-4.192506573927574,
50.367350727294706
],
[
-4.188675584440716,
50.36837704762925
],
[
-4.187143188645706,
50.37072283932642
]
]
],
"type": "Polygon"
# "projection": coordinate system used
}
}
]
}
),
},
)
swagger = Swagger(app, template=swagger_template, config=swagger_config)
......@@ -528,12 +547,12 @@ class platformStatus(Resource):
ns3 = api.namespace(
"autonomy_configuration", description="Autonomy 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 AutonomyConfiguration(Resource):
@ns3.response(200, "Success", autonomy_configuration_schema)
class PlanningConfiguration(Resource):
@ns3.response(200, "Success", planning_configuration_schema)
def get(self):
pass
......@@ -548,28 +567,18 @@ class MissionPlan(Resource):
def get(self):
pass
@ns4.route("/ecosub")
class MissionPlanEcosub(Resource):
@ns4.response(200, "Success", mission_plan_schema)
def get(self):
pass
@ns4.route("/reav")
class MissionPlanReav(Resource):
@ns4.response(200, "Success", mission_plan_schema)
def get(self):
pass
@ns4.route("/autosubhover")
class MissionPlanAutosubHover(Resource):
@ns4.response(200, "Success", mission_plan_schema)
def get(self):
pass
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()
{
"timestamp": "2022-11-16T00:00:00Z",
"source": "hydrosurv_adapter",
"destination": "autonomy_engine",
"encoded": false,
"type": "platform_status",
"payload": {
"message_ID": 202,
"status": "executed"
}
}
\ No newline at end of file
{
"timestamp": "2022-11-16T00:00:00Z",
"source": "hydrosurv_adapter",
"destination": "autonomy_engine",
"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,
"scanline": false,
"scanpoint": false
}
]
}
}
\ No newline at end of file
{
"timestamp": "2022-11-16T00:00:00Z",
"source": "hydrosurv_adapter",
"destination": "autonomy_engine",
"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
}
}
}
\ 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
{
"timestamp": "2022-11-16T00:00:00Z",
"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",
"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,
"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": 0.008,
"usbl_fix_seconds_ago": 20.3,
"battery_remaining_capacity": 80,
"sensor_config": {
"sensor_name": "MBES",
"sensor_status": false,
"additional_data": {
"sensor_loadtime_seconds": 30
}
}
}
}
}
\ No newline at end of file
{
"timestamp": "2022-11-16T00:00:00Z",
"source": "hydrosurv_adapter",
"destination": "autonomy_engine",
"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,
"scanline": false,
"scanpoint": false
}
]
}
}
\ No newline at end of file
{
"timestamp": "2022-11-16T00:00:00Z",
"source": "hydrosurv_adapter",
"destination": "autonomy_engine",
"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
}
}
}
\ 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
{
"timestamp": "2022-11-16T00:00:00Z",
"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",
"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,
"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": 0.008,
"usbl_fix_seconds_ago": 20.3,
"battery_remaining_capacity": 80,
"sensor_config": {
"sensor_name": "MBES",
"sensor_status": false,
"additional_data": {
"sensor_loadtime_seconds": 30
}
}
}
}
}
\ No newline at end of file
{
"timestamp": "2022-11-16T00:00:00Z",
"source": "hydrosurv_adapter",
"destination": "autonomy_engine",
"encoded": false,
"type": "platform_status",
"payload": {
"message_ID": 202,
"status": "executed"
}
}
\ No newline at end of file
{
"timestamp": "2022-11-16T00:00:00Z",
"source": "hydrosurv_adapter",
"destination": "autonomy_engine",
"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,
"scanline": false,
"scanpoint": false
}
]
}
}
\ No newline at end of file
{
"timestamp": "2022-11-16T00:00:00Z",
"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",
"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,
"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": 0.008,
"usbl_fix_seconds_ago": 20.3,
"battery_remaining_capacity": 80,
"sensor_config": {
"sensor_name": "MBES",
"sensor_status": false,
"additional_data": {
"sensor_loadtime_seconds": 30
}
}
}
}
}
\ No newline at end of file
......@@ -86,8 +86,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.",
),
},
)
"""
schema: platform-specific decoded status message (DRAFT)
"""
from . import message_header_schema, platform_schema, api
from . import full_message_schema, platform_schema, api
from flask_restx import fields
......@@ -9,15 +9,14 @@ observation_schema = api.model(
"Observation",
{
"message": fields.Nested(
message_header_schema,
full_message_schema,
required=True,
description="Message header",
),
"platform": fields.Nested(platform_schema),
"time": fields.String(
"platform_serial": fields.String(
required=True,
description="Timestamp of message",
example="2022-11-16T00:00:00Z",
description="Serial of platform to sendign observations",
example="ecosub-3",
),
# "observation_type" ==> payloads tied to different types maybe?
# properties of each observation?
......
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