Skip to content

Commit

Permalink
Rework developer ui
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalzauberzeug committed Jan 22, 2025
1 parent 4ef0c3d commit fd32885
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions rosys/hardware/imu.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,31 @@ def _emit_measurement(self, rotation: Rotation, time: float) -> None:

def developer_ui(self) -> None:
ui.label('IMU').classes('text-center text-bold')
with ui.column().classes('gap-y-1'):
ui.label().bind_text_from(self, 'last_measurement',
lambda m: f'Roll: {np.rad2deg(m.roll):.2f}°' if m is not None else 'Roll: N/A')
ui.label().bind_text_from(self, 'last_measurement',
lambda m: f'Pitch: {np.rad2deg(m.pitch):.2f}°' if m is not None else 'Pitch: N/A')
ui.label().bind_text_from(self, 'last_measurement',
lambda m: f'Yaw: {np.rad2deg(m.yaw):.2f}°' if m is not None else 'Yaw: N/A')
with ui.row().classes('gap-0 w-56'):
with ui.column().classes('gap-y-0 w-1/3'):
ui.label('Roll:')
ui.label().bind_text_from(self, 'last_measurement',
lambda m: f'{np.rad2deg(m.rotation.roll):.2f}°' if m is not None else 'N/A')
ui.label().bind_text_from(self, 'last_measurement',
lambda m: f'{np.rad2deg(m.corrected_rotation.roll):.2f}°' if m is not None else 'N/A')
ui.label().bind_text_from(self, 'last_measurement',
lambda m: f'{np.rad2deg(m.roll_velocity):.2f}°/s' if m is not None and m.roll_velocity is not None else 'N/A')
with ui.column().classes('gap-y-0 w-1/3'):
ui.label('Pitch:')
ui.label().bind_text_from(self, 'last_measurement',
lambda m: f'{np.rad2deg(m.rotation.pitch):.2f}°' if m is not None else 'N/A')
ui.label().bind_text_from(self, 'last_measurement',
lambda m: f'{np.rad2deg(m.corrected_rotation.pitch):.2f}°' if m is not None else 'N/A')
ui.label().bind_text_from(self, 'last_measurement',
lambda m: f'{np.rad2deg(m.pitch_velocity):.2f}°/s' if m is not None and m.pitch_velocity is not None else 'N/A')
with ui.column().classes('gap-y-0 w-1/3'):
ui.label('Yaw:')
ui.label().bind_text_from(self, 'last_measurement',
lambda m: f'{np.rad2deg(m.rotation.yaw):.2f}°' if m is not None else 'N/A')
ui.label().bind_text_from(self, 'last_measurement',
lambda m: f'{np.rad2deg(m.corrected_rotation.yaw):.2f}°' if m is not None else 'N/A')
ui.label().bind_text_from(self, 'last_measurement',
lambda m: f'{np.rad2deg(m.yaw_velocity):.2f}°/s' if m is not None and m.yaw_velocity is not None else 'N/A')


class ImuHardware(Imu, ModuleHardware):
Expand Down Expand Up @@ -117,7 +135,7 @@ def simulate(self) -> None:

def developer_ui(self) -> None:
super().developer_ui()
with ui.column().classes('gap-y-1'):
with ui.column().classes('gap-y-0'):
ui.number(label='Roll Noise', format='%.3f', prefix='± ', suffix='°') \
.bind_value(self, '_roll_noise', forward=np.deg2rad, backward=np.rad2deg).classes('w-4/5')
ui.number(label='Pitch Noise', format='%.3f', prefix='± ', suffix='°') \
Expand Down

0 comments on commit fd32885

Please sign in to comment.