added walk speed setting on [], refined walk posture
This commit is contained in:
+29
-10
@@ -325,6 +325,7 @@ class NaoTeleop:
|
||||
self.battery_level = 100
|
||||
self.last_batt_check = 0
|
||||
self.volume = 50
|
||||
self.walk_speed = 0.6 # Default walking speed
|
||||
|
||||
self.typing_mode = False
|
||||
self.chat_message = ""
|
||||
@@ -436,7 +437,7 @@ class NaoTeleop:
|
||||
|
||||
def update_title(self):
|
||||
mode = "[TYPING] " if self.typing_mode else ""
|
||||
pygame.display.set_caption(f"NAO Teleop | {mode}Battery: {self.battery_level}% | Vol: {self.volume}%")
|
||||
pygame.display.set_caption(f"NAO Teleop | {mode}Battery: {self.battery_level}% | Vol: {self.volume}% | Speed: {self.walk_speed:.2f}")
|
||||
|
||||
def change_volume(self, delta):
|
||||
self.volume = int(min(100, max(0, self.volume + delta)))
|
||||
@@ -465,9 +466,7 @@ class NaoTeleop:
|
||||
self._safe("moveInit", self.motion.moveInit)
|
||||
print("🦶 Walk engine ready")
|
||||
|
||||
carpet_config = [["StepHeight", 0.028], ["MaxStepFrequency", 0.6], ["TorsoWy", 0.05]]
|
||||
|
||||
print("\n🎮 Controls: WASD/Arrows=Walk | IJKL=Head | SPACE=Reset head | 1=Wave | M=Music search (↑↓ select, Enter confirm) | P=Pause | X=Stop | -/==Volume | T=TTS | ESC=Quit")
|
||||
print("\n🎮 Controls: WASD/Arrows=Walk | [/]=Speed | IJKL=Head | SPACE=Reset head | 1=Wave | M=Music search (↑↓ select, Enter confirm) | P=Pause | X=Stop | -/==Volume | T=TTS | ESC=Quit")
|
||||
|
||||
try:
|
||||
while self.running:
|
||||
@@ -565,15 +564,35 @@ class NaoTeleop:
|
||||
|
||||
if not self.typing_mode and not self.music_search_mode:
|
||||
keys = pygame.key.get_pressed()
|
||||
|
||||
# Speed Adjustment with Title Bar Update
|
||||
speed_changed = False
|
||||
if keys[pygame.K_LEFTBRACKET]:
|
||||
self.walk_speed = max(0.1, self.walk_speed - 0.01)
|
||||
speed_changed = True
|
||||
if keys[pygame.K_RIGHTBRACKET]:
|
||||
self.walk_speed = min(1.0, self.walk_speed + 0.01)
|
||||
speed_changed = True
|
||||
if speed_changed:
|
||||
self.update_title()
|
||||
|
||||
x = y = theta = 0.0
|
||||
if keys[pygame.K_w] or keys[pygame.K_UP]: x = 0.6
|
||||
if keys[pygame.K_s] or keys[pygame.K_DOWN]: x = -0.6
|
||||
if keys[pygame.K_a] or keys[pygame.K_LEFT]: theta = 0.5
|
||||
if keys[pygame.K_d] or keys[pygame.K_RIGHT]: theta = -0.5
|
||||
if keys[pygame.K_w] or keys[pygame.K_UP]: x = self.walk_speed
|
||||
if keys[pygame.K_s] or keys[pygame.K_DOWN]: x = -self.walk_speed
|
||||
if keys[pygame.K_a] or keys[pygame.K_LEFT]: theta = self.walk_speed * 0.8
|
||||
if keys[pygame.K_d] or keys[pygame.K_RIGHT]: theta = -self.walk_speed * 0.8
|
||||
|
||||
try:
|
||||
if abs(x) > 0.1 or abs(theta) > 0.1:
|
||||
self.motion.moveToward(x, y, theta, carpet_config)
|
||||
if abs(x) > 0.05 or abs(theta) > 0.05:
|
||||
# Fixed stable configuration mapping
|
||||
stable_config = [
|
||||
["StepHeight", 0.02],
|
||||
["MaxStepFrequency", 0.5],
|
||||
["TorsoWy", 0.08],
|
||||
["MaxStepX", 0.03] # Replaced MaxStepLength
|
||||
]
|
||||
# Removed the forced stiffness block here
|
||||
self.motion.moveToward(x, y, theta, stable_config)
|
||||
else:
|
||||
self.motion.stopMove()
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user