diff --git a/examples/geofence.py b/examples/geofence.py index 4bcb8731..12054d70 100755 --- a/examples/geofence.py +++ b/examples/geofence.py @@ -2,7 +2,7 @@ import asyncio from mavsdk import System -from mavsdk.geofence import Point, Polygon +from mavsdk.geofence import Point, Polygon, FenceType, GeofenceData, Circle """ This example shows how to use the geofence plugin. @@ -10,6 +10,10 @@ Note: The behavior when your vehicle hits the geofence is NOT configured in this example. +FenceType: + INCLUSION: The vehicle will not go outside the fence area. + EXCLUSION: The vehicle will not come inside the fence area. + """ @@ -43,11 +47,19 @@ async def run(): p4 = Point(latitude - 0.0001, longitude + 0.0001) # Create a polygon object using your points - polygon = Polygon([p1, p2, p3, p4], Polygon.FenceType.INCLUSION) + polygon = Polygon([p1, p2, p3, p4], FenceType.INCLUSION) + + # circle = Circle(p1, 10.0, FenceType.INCLUSION) + + # Sending the circle object is necessary in the geofence data, + # so if you don't want to set the circular geofence, send it like this. + circle = Circle(Point(0, 0), 0, FenceType.INCLUSION) + + geofenceData = GeofenceData([polygon], [circle]) # Upload the geofence to your vehicle print("Uploading geofence...") - await drone.geofence.upload_geofence([polygon]) + await drone.geofence.upload_geofence(geofenceData) print("Geofence uploaded!")