Skip to content

Commit

Permalink
Fix animation record ui crash after a non numerical text input (#615)
Browse files Browse the repository at this point in the history
  • Loading branch information
Flova authored Nov 6, 2024
2 parents 59cae89 + 08913c2 commit 93f937a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
"throwin",
"timespec",
"tldr",
"torqueless",
"tqdm",
"unpenalize",
"unpenalized",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,17 @@ def q_joint_state_update(self, joint_states: JointState) -> None:
return
# Update working values of non stiff motors
for motor_name in self.motors:
if self._motor_controller_torque_checkbox[motor_name].checkState(0) != Qt.CheckState.Checked:
# Get the state from the UI checkboxes
motor_active = self._motor_switcher_active_checkbox[motor_name].checkState(0) == Qt.CheckState.Checked
motor_torqueless = self._motor_controller_torque_checkbox[motor_name].checkState(0) != Qt.CheckState.Checked
# Check if the we are currently positioning the motor and want to store the value
if motor_active and motor_torqueless:
# Update textfield
self._motor_controller_text_fields[motor_name].setText(
str(round(math.degrees(joint_states.position[joint_states.name.index(motor_name)]), 2))
)
# React to textfield changes
self.textfield_update()
# Update working values
self._working_angles[motor_name] = joint_states.position[joint_states.name.index(motor_name)]

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

0 comments on commit 93f937a

Please sign in to comment.