platform_status.py 10.8 KB
Newer Older
1
"""
2
    schema: platform-specific decoded status message
3
"""
4 5
# from . import full_message_schema, api
# from flask_restx import fields
6 7


8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
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,
        },
46
    },
47 48 49 50 51 52
    "required": [
        "gps_source",
        "latitude",
        "longitude",
    ],
}
53

54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
sensor_schema = {
    "type": "object",
    "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": {
            "type": "boolean",
            "description": "Sensor switched on (True) or off (False)",
            "example": True,
        },
        "additional_data": {
            "type": "null",
            "description": "Any addition fields/data to be added here",
            "example": {"payload": [1.2, 434]},
        },
    },
    "required": [],
}
76

77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
platform_status_message_schema = {
    "allOf": [{"$ref": "#/components/schemas/Message"}],
    "type": "object",
    "properties": {
        "platform_ID": {
            "type": "integer",
            "description": "Identifier for platform",
            "example": 1,
        },
        "platform_timestamp": {
            "type": "date-time",
            "decription": "Timestamp for onboard platform status message",
            "example": "2022-12-21T00:00:00Z",
        },
        "active": {
            "type": "boolean",
            "description": "When a platform is in deployment (executing a"
94
            + " mission plan) this should be True",
95 96 97
            "example": True,
        },
        "platform_state": {
98
            # TODO: Define dictionary with potential STATES of each platform
99 100
            "type": "string",
            "description": "Current state executed by platform. E.g. "
101
            + "STOP, IDLE, ABORT.",
102 103 104 105 106
            "example": "ABORT",
        },
        "autonomy_plan_ID": {
            "type": "integer",
            "description": "Last mission plan ID (according to Autonomy Engine's"
107
            + " mission plan number) executed by platform",
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
            "example": 1,
        },
        "mission_track_ID": {
            "type": "integer",
            "description": "Track number - stage in mission (e.g. "
            + "4 --> Waypoint 3 to Waypoint 4)",
            "example": 4,
        },
        "mission_action_ID": {
            "type": "integer",
            "description": "TODO: add description",
            "example": 1,
        },
        "range_to_go": {
            "type": "number",
            "description": "Estimated distance to reach next waypoint",
            "example": 124.3,
        },
        "speed_over_ground": {
            "type": "number",
            "description": "TODO: add description",
            "example": 124.3,
        },
        "water_current_velocity": {
            "type": "number",
            "description": "TODO: add description",
            "example": 124.3,
        },
        "thrust_applied": {
            "type": "number",
            "description": "TODO: Needs further consideration",
            "example": 124.3,
        },
        "health_status": {
            "type": "string",
            "description": "Health status extracted by respective platform "
            + "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.",
            "example": 0.000129,
        },
        "usbl_fix_seconds_ago": {
            "type": "number",
            "description": "USBL Fix received x second ago.",
            "example": 10.0,
        },
        "battery_remaining_capacity": {
            "type": "number",
            "description": "Battery remaining capacity % provided by respective",
            "example": 80.2,
        },
        "sensor_config": sensor_schema,
168
    },
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344
    "required": [
        "platform_ID",
        "platform_timestamp",
        "gps_data",
        "battery_remaining_capacity",
    ],
}

# gps_schema = api.model(
#     "GPS",
#     {
#         "gps_source": fields.Float(  # TODO: TBD with partners
#             required=False,
#             description=(
#                 "Source of gps position. E.g. USBL (external),"
#                 + "platform itself (internal)"
#             ),
#             example="internal",
#         ),
#         "latitude_type": fields.String(
#             required=False,
#             description="",
#             example="",
#         ),
#         "longitude_type": fields.String(
#             required=False,
#             description="",
#             example="",
#         ),
#         "latitude": fields.Float(
#             required=False,
#             description="Latitude in <DEFINE UNITS>",
#             example="",
#         ),
#         "longitude": fields.Float(
#             required=False,
#             description="Longitude in <DEFINE UNITS>",
#             example="",
#         ),
#         "depth": fields.Float(
#             required=False,
#             description="Depth in <DEFINE UNITS>",
#             example="",
#         ),
#         "altitude": fields.Float(
#             required=False,
#             description="Altitude in <DEFINE UNITS>",
#             example="",
#         ),
#         # "gps_fix_seconds_ago"
#     },
# )

# 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",
#         ),
#     },
# )

# platform_status_message_schema = api.model(
#     "platformStatusMessage",
#     {
#         "message": fields.Nested(
#             full_message_schema,
#             required=True,
#             description="Message header",
#         ),
#         "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,
#             description="Current state executed by platform. E.g. "
#             + "STOP, IDLE, ABORT.",
#             example="IDLE",
#         ),
#         "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,
#         ),
#         "mission_track_ID": fields.Integer(
#             required=False,
#             description=(
#                 "Track number - stage in mission (e.g. "
#                 + "4 --> Waypoint 3 to Waypoint 4)"
#             ),
#             example=4,
#         ),
#         "mission_action_ID": fields.Integer(
#             required=False,
#             description="to add description",
#             example=1,
#         ),
#         "range_to_go": fields.Float(
#             required=False,
#             description="Estimated distance to reach next waypoint",
#             example=124.3,
#         ),
#         "speed_over_ground": fields.Float(
#             required=False,
#             description="",
#             example=124.3,
#         ),
#         "water_current_velocity": fields.Float(
#             required=False,
#             description="",
#             example=124.3,
#         ),
#         "thrust_applied": fields.Float(
#             required=False,
#             description="TODO: Needs further consideration",
#             example=124.3,
#         ),
#         "health_status": fields.String(
#             required=False,
#             description="Health status extracted by respective platform "
#             + "if any diagnosis available checks on sensors",
#             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
#             required=True,
#             description="Metadata pf each platform",
#         ),
#         "localisation_error": fields.Float(
#             required=False,
#             description="Localisation error at last USBL update.",
#             example="",
#         ),
#         "usbl_fix_seconds_ago": fields.Float(
#             required=False,
#             description="",
#             example="",
#         ),
#         "battery_remaining_capacity": fields.Float(
#             required=True,
#             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
#     },
# )
345

346
# # TBD: Do we append beacon positions with platform positions?