Skip to content

Commit

Permalink
Fix device id's for temp cal script.
Browse files Browse the repository at this point in the history
  • Loading branch information
jgoppert committed Feb 1, 2017
1 parent 9596ca7 commit add9118
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
32 changes: 19 additions & 13 deletions Tools/process_sensor_caldata.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ def temperature_calibration(ulog_filename, do_plot):
# get data and fill in empty (NaN) values with forward fill, followed by
# backward fill
data = r[topic][multi_id].ffill().bfill()

x = data.temperature

try:
Expand All @@ -151,7 +150,7 @@ def temperature_calibration(ulog_filename, do_plot):
'T_min': config['min'](x),
'T_max': config['max'](x),
'T_ref': config['ref'](x),
'id': device_id
'device_id': device_id
}
name = '{:s}_{:d}'.format(topic, multi_id)

Expand All @@ -175,32 +174,39 @@ def temperature_calibration(ulog_filename, do_plot):

# print(json.dumps(coeffs, indent=2, sort_keys=True))

# create param dict from coeff dict
params = {}
for topic in coeffs.keys():
for mult_id in coeffs[topic].keys():
data = coeffs[topic][multi_id]
p = {}
if topic == 'sensor_gyro':
name = 'TC_G{:d}'.format(mult_id)
params[name + '_ID'] = qgc_param(mult_id, 'int')
elif topic == 'sensor_baro':
name = 'TC_B{:d}'.format(mult_id)
elif topic == 'sensor_accel':
name = 'TC_A{:d}'.format(mult_id)
p.update({
'ID': qgc_param(mult_id, 'int'),

# common params
p = {
'ID': qgc_param(data['device_id'], 'int'),
'TMIN': qgc_param(data['T_min'], 'float'),
'TMAX': qgc_param(data['T_max'], 'float'),
'TREF': qgc_param(data['T_ref'], 'float'),
'SCL_0': qgc_param(1.0, 'float'),
'SCL_1': qgc_param(1.0, 'float'),
'SCL_2': qgc_param(1.0, 'float'),
})
}

# poly coeffs
for i_field, field in enumerate(data['poly'].keys()):
for i_c, c in enumerate(data['poly'][field]):
p['X{:d}_{:d}'.format(i_c, i_field)] = \
qgc_param(data['poly'][field][i_c], 'float')

# naming
if topic == 'sensor_gyro':
name = 'TC_G{:d}'.format(mult_id)
params[name + '_ID'] = qgc_param(mult_id, 'int')
elif topic == 'sensor_baro':
name = 'TC_B{:d}'.format(mult_id)
elif topic == 'sensor_accel':
name = 'TC_A{:d}'.format(mult_id)

# prepend name to params and save in params dict
params.update({ '{:s}_{:s}'.format(name, key): val
for key, val in p.iteritems() })

Expand Down
4 changes: 2 additions & 2 deletions Tools/templates/temp_cal.params.jinja
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{# jinja syntax: http://jinja.pocoo.org/docs/2.9/templates/ #}
{#- jinja syntax: http://jinja.pocoo.org/docs/2.9/templates/ -#}
# Temperature calibration parameters
#
# Vehicle-Id Component-Id Name Value Type
{% for name, param in params.iteritems() | sort -%}
1 1 {{ name }} {{ param['value'] }} {{ param['type'] }}
{% endfor -%}
{# vim: set noet ft=jinja fenc=utf-8 ff=unix sts=4 sw=4 ts=4 : #}
{#- vim: set noet ft=jinja fenc=utf-8 ff=unix sts=4 sw=4 ts=4 : -#}

0 comments on commit add9118

Please sign in to comment.