Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def translate_from_rpc(rpc_enum_value):
""" Parses a gRPC response """
return {
0: MissionResult.Result.UNKNOWN,
1: MissionResult.Result.SUCCESS,
2: MissionResult.Result.ERROR,
3: MissionResult.Result.TOO_MANY_MISSION_ITEMS,
4: MissionResult.Result.BUSY,
5: MissionResult.Result.TIMEOUT,
6: MissionResult.Result.INVALID_ARGUMENT,
7: MissionResult.Result.UNSUPPORTED,
8: MissionResult.Result.NO_MISSION_AVAILABLE,
9: MissionResult.Result.FAILED_TO_OPEN_QGC_PLAN,
10: MissionResult.Result.FAILED_TO_PARSE_QGC_PLAN,
11: MissionResult.Result.UNSUPPORTED_MISSION_CMD,
12: MissionResult.Result.TRANSFER_CANCELLED,
}.get(rpc_enum_value, None)
def translate_from_rpc(rpc_enum_value):
""" Parses a gRPC response """
return {
0: MissionResult.Result.UNKNOWN,
1: MissionResult.Result.SUCCESS,
2: MissionResult.Result.ERROR,
3: MissionResult.Result.TOO_MANY_MISSION_ITEMS,
4: MissionResult.Result.BUSY,
5: MissionResult.Result.TIMEOUT,
6: MissionResult.Result.INVALID_ARGUMENT,
7: MissionResult.Result.UNSUPPORTED,
8: MissionResult.Result.NO_MISSION_AVAILABLE,
9: MissionResult.Result.FAILED_TO_OPEN_QGC_PLAN,
10: MissionResult.Result.FAILED_TO_PARSE_QGC_PLAN,
11: MissionResult.Result.UNSUPPORTED_MISSION_CMD,
12: MissionResult.Result.TRANSFER_CANCELLED,
}.get(rpc_enum_value, None)
def translate_from_rpc(rpc_enum_value):
""" Parses a gRPC response """
return {
0: MissionResult.Result.UNKNOWN,
1: MissionResult.Result.SUCCESS,
2: MissionResult.Result.ERROR,
3: MissionResult.Result.TOO_MANY_MISSION_ITEMS,
4: MissionResult.Result.BUSY,
5: MissionResult.Result.TIMEOUT,
6: MissionResult.Result.INVALID_ARGUMENT,
7: MissionResult.Result.UNSUPPORTED,
8: MissionResult.Result.NO_MISSION_AVAILABLE,
9: MissionResult.Result.FAILED_TO_OPEN_QGC_PLAN,
10: MissionResult.Result.FAILED_TO_PARSE_QGC_PLAN,
11: MissionResult.Result.UNSUPPORTED_MISSION_CMD,
12: MissionResult.Result.TRANSFER_CANCELLED,
}.get(rpc_enum_value, None)
def translate_from_rpc(rpc_enum_value):
""" Parses a gRPC response """
return {
0: MissionResult.Result.UNKNOWN,
1: MissionResult.Result.SUCCESS,
2: MissionResult.Result.ERROR,
3: MissionResult.Result.TOO_MANY_MISSION_ITEMS,
4: MissionResult.Result.BUSY,
5: MissionResult.Result.TIMEOUT,
6: MissionResult.Result.INVALID_ARGUMENT,
7: MissionResult.Result.UNSUPPORTED,
8: MissionResult.Result.NO_MISSION_AVAILABLE,
9: MissionResult.Result.FAILED_TO_OPEN_QGC_PLAN,
10: MissionResult.Result.FAILED_TO_PARSE_QGC_PLAN,
11: MissionResult.Result.UNSUPPORTED_MISSION_CMD,
12: MissionResult.Result.TRANSFER_CANCELLED,
}.get(rpc_enum_value, None)
def translate_from_rpc(rpcMissionResult):
""" Translates a gRPC struct to the SDK equivalent """
return MissionResult(
MissionResult.Result.translate_from_rpc(rpcMissionResult.result),
rpcMissionResult.result_str
)
A multicopter should just hover at the spot while a fixedwing vehicle should loiter
around the location where it paused.
Raises
------
MissionError
If the request fails. The error contains the reason for the failure.
"""
request = mission_pb2.PauseMissionRequest()
response = await self._stub.PauseMission(request)
result = self._extract_result(response)
if result.result is not MissionResult.Result.SUCCESS:
raise MissionError(result, "pause_mission()")
def translate_from_rpc(rpc_enum_value):
""" Parses a gRPC response """
return {
0: MissionResult.Result.UNKNOWN,
1: MissionResult.Result.SUCCESS,
2: MissionResult.Result.ERROR,
3: MissionResult.Result.TOO_MANY_MISSION_ITEMS,
4: MissionResult.Result.BUSY,
5: MissionResult.Result.TIMEOUT,
6: MissionResult.Result.INVALID_ARGUMENT,
7: MissionResult.Result.UNSUPPORTED,
8: MissionResult.Result.NO_MISSION_AVAILABLE,
9: MissionResult.Result.FAILED_TO_OPEN_QGC_PLAN,
10: MissionResult.Result.FAILED_TO_PARSE_QGC_PLAN,
11: MissionResult.Result.UNSUPPORTED_MISSION_CMD,
12: MissionResult.Result.TRANSFER_CANCELLED,
}.get(rpc_enum_value, None)
def translate_from_rpc(rpc_enum_value):
""" Parses a gRPC response """
return {
0: MissionResult.Result.UNKNOWN,
1: MissionResult.Result.SUCCESS,
2: MissionResult.Result.ERROR,
3: MissionResult.Result.TOO_MANY_MISSION_ITEMS,
4: MissionResult.Result.BUSY,
5: MissionResult.Result.TIMEOUT,
6: MissionResult.Result.INVALID_ARGUMENT,
7: MissionResult.Result.UNSUPPORTED,
8: MissionResult.Result.NO_MISSION_AVAILABLE,
9: MissionResult.Result.FAILED_TO_OPEN_QGC_PLAN,
10: MissionResult.Result.FAILED_TO_PARSE_QGC_PLAN,
11: MissionResult.Result.UNSUPPORTED_MISSION_CMD,
12: MissionResult.Result.TRANSFER_CANCELLED,
}.get(rpc_enum_value, None)
def translate_from_rpc(rpc_enum_value):
""" Parses a gRPC response """
return {
0: MissionResult.Result.UNKNOWN,
1: MissionResult.Result.SUCCESS,
2: MissionResult.Result.ERROR,
3: MissionResult.Result.TOO_MANY_MISSION_ITEMS,
4: MissionResult.Result.BUSY,
5: MissionResult.Result.TIMEOUT,
6: MissionResult.Result.INVALID_ARGUMENT,
7: MissionResult.Result.UNSUPPORTED,
8: MissionResult.Result.NO_MISSION_AVAILABLE,
9: MissionResult.Result.FAILED_TO_OPEN_QGC_PLAN,
10: MissionResult.Result.FAILED_TO_PARSE_QGC_PLAN,
11: MissionResult.Result.UNSUPPORTED_MISSION_CMD,
12: MissionResult.Result.TRANSFER_CANCELLED,
}.get(rpc_enum_value, None)
def translate_from_rpc(rpc_enum_value):
""" Parses a gRPC response """
return {
0: MissionResult.Result.UNKNOWN,
1: MissionResult.Result.SUCCESS,
2: MissionResult.Result.ERROR,
3: MissionResult.Result.TOO_MANY_MISSION_ITEMS,
4: MissionResult.Result.BUSY,
5: MissionResult.Result.TIMEOUT,
6: MissionResult.Result.INVALID_ARGUMENT,
7: MissionResult.Result.UNSUPPORTED,
8: MissionResult.Result.NO_MISSION_AVAILABLE,
9: MissionResult.Result.FAILED_TO_OPEN_QGC_PLAN,
10: MissionResult.Result.FAILED_TO_PARSE_QGC_PLAN,
11: MissionResult.Result.UNSUPPORTED_MISSION_CMD,
12: MissionResult.Result.TRANSFER_CANCELLED,
}.get(rpc_enum_value, None)