From fd74c76b0c394fe539b2eed3e77a4bb521d3ce7a Mon Sep 17 00:00:00 2001 From: Muhammad Bilal Date: Sun, 24 Mar 2024 19:23:53 +0500 Subject: [PATCH 1/3] Geofence mechanism is updated according to V2.1.0. The process of setting the geofence in V1 was different than V2, so this change updated the geofence process according to the need of V2. Geofence class is changed. --- examples/geofence.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/examples/geofence.py b/examples/geofence.py index 4bcb8731..d1938fee 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!") From cc3df3a07388235ef208e855f1efb37d26aabd5a Mon Sep 17 00:00:00 2001 From: Muhammad Bilal Date: Sun, 24 Mar 2024 20:27:56 +0500 Subject: [PATCH 2/3] Geofence mechanism is updated according to V2.1.0. Added space after the "," in the parameters to fix the checks of style. The process of setting the geofence in V1 was different than V2, so this change updated the geofence process according to the need of V2. Geofence class is changed. --- examples/geofence.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/geofence.py b/examples/geofence.py index d1938fee..ba27f587 100755 --- a/examples/geofence.py +++ b/examples/geofence.py @@ -53,7 +53,7 @@ async def run(): # 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) + circle = Circle(Point(0, 0), 0, FenceType.INCLUSION) geofenceData = GeofenceData([polygon], [circle]) From 9e0f9471e4abfc33db37d0d4f1327da522ee95d7 Mon Sep 17 00:00:00 2001 From: Muhammad Bilal Date: Sun, 24 Mar 2024 20:33:56 +0500 Subject: [PATCH 3/3] Geofence mechanism is updated according to V2.1.0. Removed the trailing space as suggested by the style check. The process of setting the geofence in V1 was different than V2, so this change updated the geofence process according to the need of V2. Geofence class is changed. --- examples/geofence.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/geofence.py b/examples/geofence.py index ba27f587..12054d70 100755 --- a/examples/geofence.py +++ b/examples/geofence.py @@ -51,7 +51,7 @@ async def run(): # circle = Circle(p1, 10.0, FenceType.INCLUSION) - # Sending the circle object is necessary in the geofence data, + # 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)