Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion MAVSDK_SERVER_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v3.17.4
v4.0.5
103 changes: 102 additions & 1 deletion mavsdk/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ async def return_to_launch(self):
"""
Send command to return to the launch (takeoff) position and land.

This switches the drone into [Return mode](https://docs.px4.io/master/en/flight_modes/return.html) which
This switches the drone into [Return mode](https://docs.px4.io/main/en/flight_modes_mc/return.html) which
generally means it will rise up to a certain altitude to clear any obstacles before heading
back to the launch (takeoff) position and land there.

Expand Down Expand Up @@ -600,6 +600,60 @@ async def goto_location(
yaw_deg,
)

async def goto_location_fixedwing(
self, latitude_deg, longitude_deg, absolute_altitude_m, loiter_radius_m
):
"""
Send command to the drone to fly to a location for fixed-wing aircraft.

This sends a MAV_CMD_DO_REPOSITION command with a loiter radius.

The latitude and longitude are given in degrees (WGS84 frame) and the altitude
in meters AMSL (above mean sea level).

The loiter radius defines the radius of the loiter circle in meters, and its sign
controls the direction: positive is clockwise, negative is counter-clockwise.
A value of 0 is ignored by the autopilot.

Parameters
----------
latitude_deg : double
Latitude (in degrees)

longitude_deg : double
Longitude (in degrees)

absolute_altitude_m : float
Altitude AMSL (in meters)

loiter_radius_m : float
Loiter radius (in meters). Positive: clockwise, negative: counter-clockwise, 0: ignored.

Raises
------
ActionError
If the request fails. The error contains the reason for the failure.
"""

request = action_pb2.GotoLocationFixedwingRequest()
request.latitude_deg = latitude_deg
request.longitude_deg = longitude_deg
request.absolute_altitude_m = absolute_altitude_m
request.loiter_radius_m = loiter_radius_m
response = await self._stub.GotoLocationFixedwing(request)

result = self._extract_result(response)

if result.result != ActionResult.Result.SUCCESS:
raise ActionError(
result,
"goto_location_fixedwing()",
latitude_deg,
longitude_deg,
absolute_altitude_m,
loiter_radius_m,
)

async def do_orbit(
self,
radius_m,
Expand Down Expand Up @@ -964,3 +1018,50 @@ async def set_gps_global_origin(
longitude_deg,
absolute_altitude_m,
)

async def set_home(
self, use_current_location, latitude_deg, longitude_deg, absolute_altitude_m
):
"""
Set home.

Sets the home position.

Parameters
----------
use_current_location : bool
Use current location

latitude_deg : double
Latitude (in degrees)

longitude_deg : double
Longitude (in degrees)

absolute_altitude_m : float
Altitude AMSL (in meters)

Raises
------
ActionError
If the request fails. The error contains the reason for the failure.
"""

request = action_pb2.SetHomeRequest()
request.use_current_location = use_current_location
request.latitude_deg = latitude_deg
request.longitude_deg = longitude_deg
request.absolute_altitude_m = absolute_altitude_m
response = await self._stub.SetHome(request)

result = self._extract_result(response)

if result.result != ActionResult.Result.SUCCESS:
raise ActionError(
result,
"set_home()",
use_current_location,
latitude_deg,
longitude_deg,
absolute_altitude_m,
)
130 changes: 71 additions & 59 deletions mavsdk/action_pb2.py

Large diffs are not rendered by default.

111 changes: 110 additions & 1 deletion mavsdk/action_pb2_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ def __init__(self, channel):
response_deserializer=action_dot_action__pb2.GotoLocationResponse.FromString,
_registered_method=True,
)
self.GotoLocationFixedwing = channel.unary_unary(
"/mavsdk.rpc.action.ActionService/GotoLocationFixedwing",
request_serializer=action_dot_action__pb2.GotoLocationFixedwingRequest.SerializeToString,
response_deserializer=action_dot_action__pb2.GotoLocationFixedwingResponse.FromString,
_registered_method=True,
)
self.DoOrbit = channel.unary_unary(
"/mavsdk.rpc.action.ActionService/DoOrbit",
request_serializer=action_dot_action__pb2.DoOrbitRequest.SerializeToString,
Expand Down Expand Up @@ -176,6 +182,12 @@ def __init__(self, channel):
response_deserializer=action_dot_action__pb2.SetGpsGlobalOriginResponse.FromString,
_registered_method=True,
)
self.SetHome = channel.unary_unary(
"/mavsdk.rpc.action.ActionService/SetHome",
request_serializer=action_dot_action__pb2.SetHomeRequest.SerializeToString,
response_deserializer=action_dot_action__pb2.SetHomeResponse.FromString,
_registered_method=True,
)


class ActionServiceServicer(object):
Expand Down Expand Up @@ -286,7 +298,7 @@ def ReturnToLaunch(self, request, context):
"""
Send command to return to the launch (takeoff) position and land.

This switches the drone into [Return mode](https://docs.px4.io/master/en/flight_modes/return.html) which
This switches the drone into [Return mode](https://docs.px4.io/main/en/flight_modes_mc/return.html) which
generally means it will rise up to a certain altitude to clear any obstacles before heading
back to the launch (takeoff) position and land there.
"""
Expand All @@ -307,6 +319,23 @@ def GotoLocation(self, request, context):
context.set_details("Method not implemented!")
raise NotImplementedError("Method not implemented!")

def GotoLocationFixedwing(self, request, context):
"""
Send command to the drone to fly to a location for fixed-wing aircraft.

This sends a MAV_CMD_DO_REPOSITION command with a loiter radius.

The latitude and longitude are given in degrees (WGS84 frame) and the altitude
in meters AMSL (above mean sea level).

The loiter radius defines the radius of the loiter circle in meters, and its sign
controls the direction: positive is clockwise, negative is counter-clockwise.
A value of 0 is ignored by the autopilot.
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details("Method not implemented!")
raise NotImplementedError("Method not implemented!")

def DoOrbit(self, request, context):
"""
Send command do orbit to the drone.
Expand Down Expand Up @@ -429,6 +458,16 @@ def SetGpsGlobalOrigin(self, request, context):
context.set_details("Method not implemented!")
raise NotImplementedError("Method not implemented!")

def SetHome(self, request, context):
"""
Set home.

Sets the home position.
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details("Method not implemented!")
raise NotImplementedError("Method not implemented!")


def add_ActionServiceServicer_to_server(servicer, server):
rpc_method_handlers = {
Expand Down Expand Up @@ -487,6 +526,11 @@ def add_ActionServiceServicer_to_server(servicer, server):
request_deserializer=action_dot_action__pb2.GotoLocationRequest.FromString,
response_serializer=action_dot_action__pb2.GotoLocationResponse.SerializeToString,
),
"GotoLocationFixedwing": grpc.unary_unary_rpc_method_handler(
servicer.GotoLocationFixedwing,
request_deserializer=action_dot_action__pb2.GotoLocationFixedwingRequest.FromString,
response_serializer=action_dot_action__pb2.GotoLocationFixedwingResponse.SerializeToString,
),
"DoOrbit": grpc.unary_unary_rpc_method_handler(
servicer.DoOrbit,
request_deserializer=action_dot_action__pb2.DoOrbitRequest.FromString,
Expand Down Expand Up @@ -547,6 +591,11 @@ def add_ActionServiceServicer_to_server(servicer, server):
request_deserializer=action_dot_action__pb2.SetGpsGlobalOriginRequest.FromString,
response_serializer=action_dot_action__pb2.SetGpsGlobalOriginResponse.SerializeToString,
),
"SetHome": grpc.unary_unary_rpc_method_handler(
servicer.SetHome,
request_deserializer=action_dot_action__pb2.SetHomeRequest.FromString,
response_serializer=action_dot_action__pb2.SetHomeResponse.SerializeToString,
),
}
generic_handler = grpc.method_handlers_generic_handler(
"mavsdk.rpc.action.ActionService", rpc_method_handlers
Expand Down Expand Up @@ -891,6 +940,36 @@ def GotoLocation(
_registered_method=True,
)

@staticmethod
def GotoLocationFixedwing(
request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None,
):
return grpc.experimental.unary_unary(
request,
target,
"/mavsdk.rpc.action.ActionService/GotoLocationFixedwing",
action_dot_action__pb2.GotoLocationFixedwingRequest.SerializeToString,
action_dot_action__pb2.GotoLocationFixedwingResponse.FromString,
options,
channel_credentials,
insecure,
call_credentials,
compression,
wait_for_ready,
timeout,
metadata,
_registered_method=True,
)

@staticmethod
def DoOrbit(
request,
Expand Down Expand Up @@ -1250,3 +1329,33 @@ def SetGpsGlobalOrigin(
metadata,
_registered_method=True,
)

@staticmethod
def SetHome(
request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None,
):
return grpc.experimental.unary_unary(
request,
target,
"/mavsdk.rpc.action.ActionService/SetHome",
action_dot_action__pb2.SetHomeRequest.SerializeToString,
action_dot_action__pb2.SetHomeResponse.FromString,
options,
channel_credentials,
insecure,
call_credentials,
compression,
wait_for_ready,
timeout,
metadata,
_registered_method=True,
)
Loading
Loading