Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Communications Backbone System
backbone-message-format
Commits
7b0f6f5e
Commit
7b0f6f5e
authored
2 years ago
by
Trishna Saeharaseelan
Browse files
Options
Download
Email Patches
Plain Diff
refactor: added message schemas autonomy config, vehicle, status
parent
242b186f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
293 additions
and
0 deletions
+293
-0
__init__.py
__init__.py
+69
-0
autonomy_configuration.py
autonomy_configuration.py
+100
-0
vehicle_status.py
vehicle_status.py
+124
-0
No files found.
__init__.py
View file @
7b0f6f5e
from
flask_restx
import
Api
,
fields
from
flask
import
Flask
import
os
...
...
@@ -6,3 +8,70 @@ __all__ = [
for
x
in
os
.
listdir
(
os
.
path
.
dirname
(
__file__
))
if
x
.
endswith
(
".py"
)
and
x
!=
"__init__.py"
]
app
=
Flask
(
__name__
)
api
=
Api
(
app
)
message_types
=
[
"vehicle_status"
]
# TODO: Add full range of message types once scoped out
message_header_schema
=
api
.
model
(
"MessageHeader"
,
{
"timestamp"
:
fields
.
String
(
# TODO: Update to Datetime UTC format
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
=
"vehicle_status"
,
),
},
)
vehicle_schema
=
api
.
model
(
"VehicleSchema"
,
{
"vehicle_ID"
:
fields
.
Integer
(
required
=
True
,
description
=
"vehicle serial number"
,
example
=
"ah-1"
,
),
"serial"
:
fields
.
Integer
(
required
=
True
,
description
=
"vehicle serial number"
,
example
=
"ah-1"
,
),
"model"
:
fields
.
Integer
(
required
=
True
,
description
=
"vehicle serial number"
,
example
=
"ah-1"
,
),
"active"
:
fields
.
Boolean
(
required
=
False
,
description
=
"Vehicle in mission"
,
example
=
True
,
),
},
)
# TODO: Add generic positions schema
# TODO: Define units for all schemas
This diff is collapsed.
Click to expand it.
autonomy_configuration.py
View file @
7b0f6f5e
"""
schemas: configuration sent to Autonomy Engine (i.e. during an emergency,
if a vehicle needs to be removed from the mission planning)
"""
from
.
import
api
,
message_header_schema
,
vehicle_schema
from
flask_restx
import
fields
squad_metadata_schema
=
api
.
model
(
"SquadMetadataSchema"
,
{
"squad_ID"
:
fields
.
Integer
(
required
=
True
,
description
=
"vehicle serial number"
,
example
=
"ah-1"
,
),
"no_of_vehicles"
:
fields
.
Integer
(
required
=
True
,
description
=
"number of vehicle serial number"
,
example
=
"ah-1"
,
),
"vehicles"
:
fields
.
List
(
fields
.
Nested
(
vehicle_schema
),
required
=
True
,
description
=
"Metadata pf each vehicle"
,
),
"squad_mission_type"
:
fields
.
String
(
required
=
True
,
description
=
"Survey or Detail"
,
example
=
"survey"
,
),
"squad_execution"
:
fields
.
Boolean
(
required
=
True
,
description
=
"True if Squad of survey executed by Autonomy Engine"
,
example
=
False
,
),
},
)
constraints_schema
=
api
.
model
(
"ConstraintsSchema"
,
# TODO: Should this be per vehicle instead of squad?
{
"min_altitude"
:
fields
.
Float
(
required
=
True
,
description
=
"Minimum altitude set for squad."
,
example
=
15.2
,
),
"min_velocity"
:
fields
.
Float
(
required
=
True
,
description
=
"Minimum velocity set for squad."
,
example
=
0.1
,
),
"max_velocity"
:
fields
.
Float
(
required
=
True
,
description
=
"Maximum altitude set for squad."
,
example
=
0.9
,
),
},
)
environment_config_schema
=
api
.
model
(
# TODO: Discuss how regions are defined
"EnvironmentConfig"
,
{
"region_of_interest"
:
fields
.
String
(),
"exclusion_zone"
:
fields
.
String
(),
},
)
# Main Autonomy Configuration Schema
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"
,
),
"environment"
:
fields
.
Nested
(
environment_config_schema
,
required
=
False
,
description
=
"Region of interest and exclusion zone"
,
),
},
)
This diff is collapsed.
Click to expand it.
vehicle_status
_schema
.py
→
vehicle_status.py
View file @
7b0f6f5e
"""
schema
s
: vehicle-specific decoded status message (DRAFT
ONLY
)
schema: vehicle-specific decoded status message (DRAFT)
"""
from
flask_restx
import
Api
,
fields
from
flask
import
Flask
from
.
import
message_header_schema
,
api
from
flask
_restx
import
fields
app
=
Flask
(
__name__
)
api
=
Api
(
app
)
vehicle_status_message_schema
=
api
.
model
(
"VehicleStatusMessage"
,
{
"message_source"
:
fields
.
String
(
"message"
:
fields
.
Nested
(
message_header_schema
,
required
=
True
,
description
=
"Where is this message from"
,
example
=
"autonomy_engine"
,
),
"message_destination"
:
fields
.
String
(
required
=
True
,
description
=
"What is the destination of this message"
,
example
=
"ah-1"
,
),
"encoded"
:
fields
.
Boolean
(
required
=
True
,
description
=
"Is this message encoded (encoded=True, decoded=False)"
,
example
=
False
,
description
=
"Message header"
,
),
"serial_number"
:
fields
.
String
(
required
=
True
,
...
...
@@ -36,8 +24,8 @@ vehicle_status_message_schema = api.model(
example
=
"2022-11-16T00:00:00Z"
,
),
"version"
:
fields
.
Integer
(
required
=
Tru
e
,
description
=
""
,
# we can track the version of the AE plan?
required
=
Fals
e
,
description
=
""
,
# we can track the version of the AE plan?
example
=
""
,
),
"platform_ID"
:
fields
.
Integer
(
...
...
@@ -55,22 +43,47 @@ vehicle_status_message_schema = api.model(
description
=
""
,
example
=
"SAFETY_STOP"
,
),
"
current_mission_state
"
:
fields
.
String
(
"
mission_track_number
"
:
fields
.
Integer
(
required
=
True
,
description
=
""
,
example
=
""
,
description
=
(
"Track number - stage in mission (e.g. "
+
"4 --> Waypoint 3 to Waypoint 4)"
),
example
=
4
,
),
"range_to_go"
:
fields
.
Float
(
required
=
False
,
description
=
"Estimated distance to reach next waypoint"
,
example
=
124.3
,
),
"vehicle_state"
:
fields
.
String
(
required
=
True
,
description
=
"Current state executed by vehicle. E.g. "
+
"STOP, IDLE, ABORT."
,
example
=
"IDLE"
,
),
"c2_health_status"
:
fields
.
String
(
required
=
True
,
description
=
"Health status determined by vehicle's C2 "
+
"checks on sensors"
,
example
=
"Warning"
,
),
"gps_source"
:
fields
.
Float
(
required
=
True
,
description
=
""
,
description
=
"Source of gps position. E.g. Beacon"
,
example
=
"internal"
,
),
"latitude"
:
fields
.
Float
(
required
=
True
,
description
=
"Latitude in <insert units>"
,
example
=
""
,
),
"
gps_lat
"
:
fields
.
Float
(
"
longitude
"
:
fields
.
Float
(
required
=
True
,
description
=
""
,
description
=
"
Longitude in <insert units>
"
,
example
=
""
,
),
"
gps_lon
"
:
fields
.
Float
(
"
depth
"
:
fields
.
Float
(
required
=
True
,
description
=
""
,
example
=
""
,
...
...
@@ -80,5 +93,32 @@ vehicle_status_message_schema = api.model(
description
=
""
,
example
=
""
,
),
"battery_voltage"
:
fields
.
Float
(
required
=
True
,
description
=
"Volts"
,
example
=
23.0
,
),
"battery_current"
:
fields
.
Float
(
required
=
False
,
description
=
"Amps"
,
example
=
1.2
,
),
"battery_current_per_hour"
:
fields
.
Float
(
required
=
False
,
description
=
"Amp-Hours"
,
example
=
1.2
,
),
"battery_wattage"
:
fields
.
Float
(
required
=
False
,
description
=
"Watts"
,
example
=
23.0
,
),
"battery_wattage_per_hour"
:
fields
.
Float
(
required
=
False
,
description
=
"Watt-Hours"
,
example
=
23.0
,
),
},
)
# TBD: Do we append beacon positions with vehicle positions?
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment