Skip to content

Commit 08913c2

Browse files
committed
Fix issue where the animation record ui crashed after a non numerical value is entered.
Normally this is handled, but a race condition happened, because the text field might be updated by the routine that is responsible for entering the live joint states from the robot if it is in the torqueless mode regardless if the joint is in this mode or not. This somehow prevented the exception from being catched properly and then resulted in a stack overflow of QT. This commit fixes this by not calling the textfield_update every time a joint state is received. Instead we manually update the working values dict if the joint is in the recoding / torqueless mode.
1 parent 59cae89 commit 08913c2

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@
112112
"throwin",
113113
"timespec",
114114
"tldr",
115+
"torqueless",
115116
"tqdm",
116117
"unpenalize",
117118
"unpenalized",

bitbots_motion/bitbots_animation_rqt/bitbots_animation_rqt/record_ui.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,13 +194,17 @@ def q_joint_state_update(self, joint_states: JointState) -> None:
194194
return
195195
# Update working values of non stiff motors
196196
for motor_name in self.motors:
197-
if self._motor_controller_torque_checkbox[motor_name].checkState(0) != Qt.CheckState.Checked:
197+
# Get the state from the UI checkboxes
198+
motor_active = self._motor_switcher_active_checkbox[motor_name].checkState(0) == Qt.CheckState.Checked
199+
motor_torqueless = self._motor_controller_torque_checkbox[motor_name].checkState(0) != Qt.CheckState.Checked
200+
# Check if the we are currently positioning the motor and want to store the value
201+
if motor_active and motor_torqueless:
198202
# Update textfield
199203
self._motor_controller_text_fields[motor_name].setText(
200204
str(round(math.degrees(joint_states.position[joint_states.name.index(motor_name)]), 2))
201205
)
202-
# React to textfield changes
203-
self.textfield_update()
206+
# Update working values
207+
self._working_angles[motor_name] = joint_states.position[joint_states.name.index(motor_name)]
204208

205209
def create_motor_controller(self) -> None:
206210
"""
@@ -681,7 +685,7 @@ def textfield_update(self):
681685
"Warning",
682686
f"Please enter a valid number.\n '{text_field.text()}' is not a valid number.",
683687
)
684-
return
688+
continue
685689
# Clip the angle to the maximum and minimum, we do this in degrees,
686690
# because we do not want introduce rounding errors in the textfield
687691
angle = round(max(-180.0, min(angle, 180.0)), 2)

0 commit comments

Comments
 (0)