add field for entering controller

This commit is contained in:
Brendan Haines 2020-04-08 13:45:34 -06:00
parent d75f064b6c
commit 4b9b46a5da

View File

@ -202,6 +202,11 @@ def stop_controller(attrname=None, old=None, new=None):
except: except:
pass pass
def update_models(attrname=None, old=None, new=None):
if new is not None:
stop_controller()
exec(new)
# GUI elements # GUI elements
vbat_text = Paragraph(text="Battery Voltage: ? V") vbat_text = Paragraph(text="Battery Voltage: ? V")
@ -216,6 +221,11 @@ start_button.on_click(start_controller)
stop_button = Button(label="Stop") stop_button = Button(label="Stop")
stop_button.on_click(stop_controller) stop_button.on_click(stop_controller)
# plant_model_text =
controller_model_text = TextInput(text="D = TransferFunction([1], [1], dt=0.01)")
update_models = Button(label="Update models")
update_models.on_click(update_models)
def update_battery_voltage(attrname=None, old=None, new=None): def update_battery_voltage(attrname=None, old=None, new=None):
global VBAT_THRESHOLD global VBAT_THRESHOLD
global vbat_text global vbat_text
@ -238,8 +248,9 @@ def update_battery_voltage(attrname=None, old=None, new=None):
# controller_iir_taps = TextInput(title="IIR taps", value=str(iir_taps)) # controller_iir_taps = TextInput(title="IIR taps", value=str(iir_taps))
controls = column(vbat_text, cal_white_button, cal_black_button, start_button, stop_button) controls = column(vbat_text, cal_white_button, cal_black_button, start_button, stop_button)
controller_model = row(controller_model_text, update_models)
# controller_settings = column(controller_sample_interval, controller_base_speed, controller_fir_taps, controller_iir_taps) # controller_settings = column(controller_sample_interval, controller_base_speed, controller_fir_taps, controller_iir_taps)
curdoc().add_root(column(row(controls, brightness_plot, width=800), time_plot))#, controller_settings)) curdoc().add_root(column(row(controls, brightness_plot, width=800), time_plot, controller_model))#, controller_settings))
curdoc().title = "TriangleBot Control Panel" curdoc().title = "TriangleBot Control Panel"
curdoc().add_periodic_callback(update_plots, 250) curdoc().add_periodic_callback(update_plots, 250)
curdoc().add_periodic_callback(update_battery_voltage, 1000) curdoc().add_periodic_callback(update_battery_voltage, 1000)