Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QGC Parameters #265

Merged
merged 6 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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: 2 additions & 0 deletions app/plot_app/templates/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ <h1>
<div class="dropdown-menu">
<a class="dropdown-item" href="download?log={{ log_id }}">Log File</a>
<a class="dropdown-item" href="download?log={{ log_id }}&type=1" target="_blank">Parameters</a>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove this option (but keep the implementation), and just offer the QGC versions.

<a class="dropdown-item" href="download?log={{ log_id }}&type=4" target="_blank">Parameters (QGC)</a>
<a class="dropdown-item" href="download?log={{ log_id }}&type=3" target="_blank">Parameters (non-default)</a>
<a class="dropdown-item" href="download?log={{ log_id }}&type=5" target="_blank">Parameters (non-default - QGC)</a>
{% if has_position_data %}
<a class="dropdown-item" href="download?log={{ log_id }}&type=2" target="_blank">KML Track</a>
{% endif %}
Expand Down
70 changes: 69 additions & 1 deletion app/tornado_handlers/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ def get_original_filename(default_value, new_file_suffix):
print("DB access failed:", sys.exc_info()[0], sys.exc_info()[1])
return default_value


if download_type == '1': # download the parameters
ulog = load_ulog_file(log_file_name)
param_keys = sorted(ulog.initial_parameters.keys())
Expand Down Expand Up @@ -155,6 +154,75 @@ def kml_colors(flight_mode):
except:
pass

elif download_type == '4': # download QGC parameters
ulog = load_ulog_file(log_file_name)
param_keys = sorted(ulog.initial_parameters.keys())

self.set_header("Content-Type", "text/plain")
self.set_header('Content-Disposition', 'inline; filename=vehicle.params')

delimiter = ' '
for param_key in param_keys:
self.write("1")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment that this is the sysid (and compid below)?

self.write(delimiter)
self.write("1")
self.write(delimiter)
self.write(param_key)
self.write(delimiter)
self.write(str(ulog.initial_parameters[param_key]))

#if the value is an int write a 6, if not write a 9
if(type(ulog.initial_parameters[param_key]) == int):
self.write(delimiter)
self.write("6")
else:
self.write(delimiter)
self.write("9")

self.write('\n')

elif download_type == '5': # download non-default parameters for QGC
ulog = load_ulog_file(log_file_name)
param_keys = sorted(ulog.initial_parameters.keys())

self.set_header("Content-Type", "text/plain")
self.set_header('Content-Disposition', 'inline; filename=vehicle-nondefault.params')
delimiter = ' '

# Use defaults from log if available
if ulog.has_default_parameters:
system_defaults = ulog.get_default_parameters(0)
airframe_defaults = ulog.get_default_parameters(1)
for param_key in param_keys:
try:
param_value = ulog.initial_parameters[param_key]
is_default = True
if param_key in airframe_defaults:
is_default = param_value == airframe_defaults[param_key]
elif param_key in system_defaults:
is_default = param_value == system_defaults[param_key]

if not is_default:
self.write("1")
self.write(delimiter)
self.write("1")
self.write(delimiter)
self.write(param_key)
self.write(delimiter)
self.write(str(param_value))

#if the value is an int write a 6, if not write a 9
if(type(param_value) == int):
self.write(delimiter)
self.write("6")
else:
self.write(delimiter)
self.write("9")

self.write('\n')
except:
pass

else:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This else case was part of the elif download_type == '3': # download the non-default parameters case above and needs to be copied up to that case again, and here it needs to be adjusted for the QGC format.

default_params = get_default_parameters()

Expand Down
Loading