Skip to content

Commit f8e9ba6

Browse files
committed
autotune: add presets for angular rate tuning
1 parent e155ba2 commit f8e9ba6

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

autotune/data_selection_window.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ def __init__(self, filename):
3232
top_group.addWidget(btn_browse)
3333

3434
in_out_group = QFormLayout()
35+
self.combo_preset = QComboBox()
36+
self.combo_preset.setEditable(False)
37+
self.presets = ['Rollrate', 'Pitchrate', 'Yawrate']
38+
self.combo_preset.addItems(self.presets)
39+
self.combo_preset.currentIndexChanged.connect(self.selectPreset)
40+
in_out_group.addRow(QLabel("Preset:"), self.combo_preset)
41+
3542
self.combo_u = QComboBox()
3643
self.combo_u.setEditable(True)
3744
self.combo_u.setInsertPolicy(QComboBox.NoInsert)
@@ -85,13 +92,48 @@ def openFile(self):
8592
self.combo_y.clear()
8693
self.combo_y.addItems(list_names)
8794

95+
# Trigger preset selection
96+
self.combo_preset.setCurrentIndex(0)
97+
self.selectPreset(0)
98+
8899
def printRangeError(self):
89100
msg = QMessageBox()
90101
msg.setIcon(QMessageBox.Critical)
91102
msg.setWindowTitle("Error")
92103
msg.setText("Range is invalid")
93104
msg.exec_()
94105

106+
def selectPreset(self, index):
107+
preset = self.presets[index]
108+
if preset == 'Rollrate':
109+
index_u = self.combo_u.findText("vehicle_torque_setpoint/xyz[0].0")
110+
index_y = self.combo_u.findText("vehicle_angular_velocity/xyz[0].0")
111+
112+
if index_u < 0:
113+
# Look for legacy topic
114+
index_u = self.combo_u.findText("actuator_controls_0/control[0].0")
115+
116+
elif preset == 'Pitchrate':
117+
index_u = self.combo_u.findText("vehicle_torque_setpoint/xyz[1].0")
118+
index_y = self.combo_u.findText("vehicle_angular_velocity/xyz[1].0")
119+
120+
if index_u < 0:
121+
# Look for legacy topic
122+
index_u = self.combo_u.findText("actuator_controls_0/control[1].0")
123+
124+
elif preset == 'Yawrate':
125+
index_u = self.combo_u.findText("vehicle_torque_setpoint/xyz[2].0")
126+
index_y = self.combo_u.findText("vehicle_angular_velocity/xyz[2].0")
127+
128+
if index_u < 0:
129+
# Look for legacy topic
130+
index_u = self.combo_u.findText("actuator_controls_0/control[2].0")
131+
132+
if index_u > -1:
133+
self.combo_u.setCurrentIndex(index_u)
134+
if index_y > -1:
135+
self.combo_y.setCurrentIndex(index_y)
136+
95137
def selectUData(self, index):
96138
self.index_u = index
97139
(self.t, self.u) = self.data_extractor.getPreview(self.topics[index])

0 commit comments

Comments
 (0)