新增x,y,yaw速度清0功能,数字键4,5,6分别对应x,y,yaw速度清零

This commit is contained in:
meiqi
2026-03-30 12:21:33 +08:00
parent 4788c0885a
commit 2988d4174b
2 changed files with 25 additions and 4 deletions

View File

@@ -64,6 +64,9 @@ class KeyboardController:
print(" w/a/s/d - Movement controls")
print(" q/e - Rotation controls (turn left/right)")
print(" r - Reset all movement commands to zero")
print(" 4 - Clear x speed command")
print(" 5 - Clear y speed command")
print(" 6 - Clear yaw speed command")
print(" x - Quit")
print(" Ctrl+C - Emergency stop")
@@ -181,19 +184,19 @@ class KeyboardController:
self._on_c_key()
elif key == 'm':
self._on_m_key()
elif key == 'h':
elif key == '5':
self._on_h_key()
elif key == 'r':
self._on_r_key()
elif key == 'x':
self._on_x_key()
elif key == 'g':
elif key == '4':
self._on_g_key()
elif key == 'p':
self._on_p_key()
elif key == 'n':
self._on_n_key()
elif key == 'o':
elif key == '6':
self._on_o_key()
elif key == 'v':
self._on_v_key()
@@ -315,6 +318,24 @@ class KeyboardController:
self.keyboard_flag.yaw_speed_command = 0.0
print("All movement commands reset to zero")
def _on_g_key(self):
"""处理g键 - 清除前后速度"""
with self.data_mutex:
self.keyboard_flag.x_speed_command = 0.0
print("X speed command reset to zero")
def _on_h_key(self):
"""处理h键 - 清除横移速度"""
with self.data_mutex:
self.keyboard_flag.y_speed_command = 0.0
print("Y speed command reset to zero")
def _on_o_key(self):
"""处理o键 - 清除偏航速度"""
with self.data_mutex:
self.keyboard_flag.yaw_speed_command = 0.0
print("Yaw speed command reset to zero")
def _on_x_key(self):
"""处理x键 - 退出"""
with self.data_mutex:

View File

@@ -6,7 +6,7 @@ sim: false
debug: false
control_tool: udp_loopback # joystick, xbox, keyboard, udp_loopback
control_tool: keyboard # joystick, xbox, keyboard, udp_loopback
joystick:
initial_height: 0.957