Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

mavwp: support comments in waypoints

  • Loading branch information...
commit 3bc0537de6f3967fb789aea90bec9a08d04f2c7d 1 parent e0067c6
Andrew Tridgell tridge authored
Showing with 15 additions and 3 deletions.
  1. +15 −3 pymavlink/mavwp.py
18 pymavlink/mavwp.py
View
@@ -3,7 +3,7 @@
'''
import os
-import mavutil, time
+import mavutil, time, copy
class MAVWPError(Exception):
@@ -28,8 +28,11 @@ def wp(self, i):
'''return a waypoint'''
return self.wpoints[i]
- def add(self, w):
+ def add(self, w, comment=''):
'''add a waypoint'''
+ w = copy.copy(w)
+ if comment:
+ w.comment = comment
w.seq = self.count()
self.wpoints.append(w)
self.last_change = time.time()
@@ -151,6 +154,8 @@ def save(self, filename):
f = open(filename, mode='w')
f.write("QGC WPL 110\n")
for w in self.wpoints:
+ if getattr(w, 'comment', None):
+ f.write("# %s\n" % w.comment)
f.write("%u\t%u\t%u\t%u\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%u\n" % (
w.seq, w.current, w.frame, w.command,
w.param1, w.param2, w.param3, w.param4,
@@ -161,7 +166,14 @@ def polygon(self):
'''return a polygon for the waypoints'''
points = []
for w in self.wpoints:
- if w.command in [mavutil.mavlink.MAV_CMD_NAV_WAYPOINT]:
+ if w.x == 0 and w.y == 0:
+ continue
+ if w.command in [mavutil.mavlink.MAV_CMD_NAV_WAYPOINT,
+ mavutil.mavlink.MAV_CMD_NAV_LOITER_UNLIM,
+ mavutil.mavlink.MAV_CMD_NAV_LOITER_TURNS,
+ mavutil.mavlink.MAV_CMD_NAV_LOITER_TIME,
+ mavutil.mavlink.MAV_CMD_NAV_LAND,
+ mavutil.mavlink.MAV_CMD_NAV_TAKEOFF]:
points.append((w.x, w.y))
return points
Please sign in to comment.
Something went wrong with that request. Please try again.