Skip to content

Commit ceafe35

Browse files
committed
mavflightview.py: correct plotting of GPS data
the "type" variable was being over-written to include the instance number before we dropped down through the code which specially-treats messages based on the type variable. So stop overwriting the variable before that switch statement, create a special string for when we need it. Visible difference with this PR is that the GPS plots on the map no longer have lines starting from 0,0 if the GPS starts with no fix.
1 parent c3c97f4 commit ceafe35

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

MAVProxy/tools/mavflightview.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ def mavflightview_mav(mlog, options=None, flightmode_selections=[]):
384384
# may only be present for colour-source expressions to work
385385
continue
386386

387+
type_with_instance = type
387388
try:
388389
# remember that "m" here might be a mavlink message.
389390
instance_field = m.fmt.instance_field
@@ -393,7 +394,7 @@ def mavflightview_mav(mlog, options=None, flightmode_selections=[]):
393394
):
394395
continue
395396

396-
type = '%s[%u]' % (type, m_instance_field_value)
397+
type_with_instance = '%s[%u]' % (type, m_instance_field_value)
397398
except Exception:
398399
pass
399400

@@ -473,11 +474,11 @@ def mavflightview_mav(mlog, options=None, flightmode_selections=[]):
473474
continue
474475

475476
# automatically add new types to instances
476-
if type not in instances:
477-
instances[type] = len(instances)
477+
if type_with_instance not in instances:
478+
instances[type_with_instance] = len(instances)
478479
while len(instances) >= len(path):
479480
path.append([])
480-
instance = instances[type]
481+
instance = instances[type_with_instance]
481482

482483
# only plot thing we have a valid-looking location for:
483484
if abs(lat)<=0.01 and abs(lng)<=0.01:
@@ -490,8 +491,8 @@ def mavflightview_mav(mlog, options=None, flightmode_selections=[]):
490491
tdays = grapher.timestamp_to_days(m._timestamp)
491492
point = (lat, lng, colour, tdays)
492493

493-
if options.rate == 0 or not type in last_timestamps or m._timestamp - last_timestamps[type] > 1.0/options.rate:
494-
last_timestamps[type] = m._timestamp
494+
if options.rate == 0 or not type_with_instance in last_timestamps or m._timestamp - last_timestamps[type_with_instance] > 1.0/options.rate:
495+
last_timestamps[type_with_instance] = m._timestamp
495496
path[instance].append(point)
496497
if len(path[0]) == 0:
497498
print("No points to plot")

0 commit comments

Comments
 (0)