platform_status.py 6.01 KB
Newer Older
1
"""
2
    schema: platform-specific decoded status message
3
"""
4 5
from formats import abstract_schema

6 7
sensor_schema = {
    "type": "object",
8 9
    "description": "Scanning sensor on platform available"
    + " to be controlled by  the Autonomy Engine",
10 11 12 13 14 15
    "properties": {
        "sensor_serial": {
            "type": "string",
            "description": "serial number of sensor",
            "example": "mbes-002a",
        },
16
        "sensor_on": {
17 18 19 20 21 22 23 24 25 26 27 28
            "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": [],
}
29

30 31 32 33 34 35 36 37
platform_status_message_schema = {
    "type": "object",
    "properties": {
        "platform_ID": {
            "type": "integer",
            "description": "Identifier for platform",
            "example": 1,
        },
38 39 40 41 42 43 44
        "status_source": {
            "type": "string",
            "enum": ["usbl", "onboard_platform"],
            "description": "Indicate if this status message is from the"
            + " platform or USBL",
            "example": "usbl",
        },
45 46 47 48 49 50 51 52
        "transmission_mode": {
            "type": "string",
            "enum": ["acoustics", "iridium", "wifi", "starlink"],
            "description": "Mode in which status message was transmitted"
            + " when on the surface (i.e. iridium/wifi) or underwater"
            + " (i.e. acoustics)",
            "example": "wifi",
        },
53
        "platform_timestamp": {
54 55
            "type": "string",
            "format": "date-time",
56 57 58 59 60 61
            "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"
62
            + " mission plan) this should be True",
63 64 65
            "example": True,
        },
        "platform_state": {
66
            # TODO: Define enum with potential STATES of each platform
67 68
            "type": "string",
            "description": "Current state executed by platform. E.g. "
69
            + "STOP, IDLE, ABORT.",
70 71
            "example": "ABORT",
        },
72
        "autonomy_engine_plan_ID": {
73
            "type": "integer",
74 75
            "description": "Last mission plan ID (according to Autonomy"
            + " Engine's mission plan number sent) executed by platform",
76 77
            "example": 1,
        },
78 79
        "latitude": {
            "type": "number",
80
            "format": "float",
81 82 83 84 85
            "description": "Latitude in decimal degrees.",
            "example": 178.2,
        },
        "longitude": {
            "type": "number",
86
            "format": "float",
87 88 89 90 91
            "description": "Longitude in decimal degrees.",
            "example": -10.122,
        },
        "depth": {
            "type": "number",
92
            "format": "float",
93 94 95 96 97 98
            "description": "Target depth in metres",
            "example": 50,
            "default": 0,
        },
        "altitude": {
            "type": "number",
99
            "format": "float",
100 101 102
            "description": "Target altitude in metres",
            "example": 20,
        },
103 104 105 106 107 108 109 110
        "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",
111
            "description": "",  # TODO: Add description
112 113 114 115
            "example": 1,
        },
        "range_to_go": {
            "type": "number",
116
            "format": "float",
117 118 119 120 121
            "description": "Estimated distance to reach next waypoint",
            "example": 124.3,
        },
        "speed_over_ground": {
            "type": "number",
122 123
            "format": "float",
            "description": "",  # TODO: Add description
124 125 126 127
            "example": 124.3,
        },
        "water_current_velocity": {
            "type": "number",
128 129
            "format": "float",
            "description": "",  # TODO: Add description
130 131 132 133
            "example": 124.3,
        },
        "thrust_applied": {
            "type": "number",
134 135
            "format": "float",
            "description": "",  # TODO: Add description
136 137
            "example": 124.3,
        },
138 139
        "heading": {
            "type": "number",
140
            "format": "float",
141 142 143 144
            "description": "Angular distance relative to north, usually 000°"
            + " at north, clockwise through 359°, in degrees",
            "example": 124.3,
        },
145 146 147 148 149 150 151 152
        "health_status": {
            "type": "string",
            "description": "Health status extracted by respective platform "
            + "if any diagnosis is available to check sensors",
            "example": "Warning",
        },
        "localisation_error": {
            "type": "number",
153
            "format": "float",
154 155 156 157 158
            "description": "Localisation error at last USBL update.",
            "example": 0.000129,
        },
        "usbl_fix_seconds_ago": {
            "type": "number",
159
            "format": "float",
160 161 162 163 164
            "description": "USBL Fix received x second ago.",
            "example": 10.0,
        },
        "battery_remaining_capacity": {
            "type": "number",
165
            "format": "float",
166
            "description": "Battery remaining % provided by respective C2",
167 168
            "example": 80.2,
        },
169 170
        "current_pitch": {
            "type": "number",
171
            "format": "float",
172 173 174
            "description": "Current pitch of platform",
            "example": -4.0,
        },
175
        "sensor_config": sensor_schema,
176
    },
177 178
    "required": [
        "platform_ID",
179
        "status_source",
180
        "platform_timestamp",
181 182
        "latitude",
        "longitude",
183 184
    ],
}
185 186 187 188

full_platform_status_message_schema = abstract_schema
full_platform_status_message_schema["properties"]["payload"] = platform_status_message_schema