working on cena gesture (2)
This commit is contained in:
+31
-4
@@ -158,7 +158,7 @@ class NaoTeleop:
|
||||
self.battery_level = 100
|
||||
self.last_batt_check = 0
|
||||
self.volume = 50
|
||||
self.walk_speed = 0.6 # Default walking speed
|
||||
self.walk_speed = 0.6
|
||||
|
||||
self.typing_mode = False
|
||||
self.chat_message = ""
|
||||
@@ -183,7 +183,6 @@ class NaoTeleop:
|
||||
self.update_title()
|
||||
|
||||
def _safe(self, label, fn):
|
||||
"""Run fn(), log+swallow any exception so one failure can't crash the loop."""
|
||||
try:
|
||||
return fn()
|
||||
except Exception as e:
|
||||
@@ -250,6 +249,33 @@ class NaoTeleop:
|
||||
except Exception as e:
|
||||
print(f"Wave error: {e}")
|
||||
|
||||
def cena_gesture(self):
|
||||
if self.typing_mode: return
|
||||
print("👋 YOU CAN'T SEE ME! (Backhand version)")
|
||||
try:
|
||||
self.motion.setStiffnesses("RArm", 1.0)
|
||||
names = ["RShoulderPitch", "RShoulderRoll", "RElbowYaw", "RElbowRoll", "RWristYaw", "RHand"]
|
||||
|
||||
# Adjusted RWristYaw to 1.5 to turn the hand backhand
|
||||
angles = [
|
||||
[-0.4]*5, # Pitch (raise arm)
|
||||
[-0.1, -0.6, -0.1, -0.6, -0.1], # Roll (wave across face)
|
||||
[0.0]*5, # Elbow Yaw
|
||||
[1.4]*5, # Elbow Roll (bent to face)
|
||||
[1.5]*5, # Wrist Yaw (Backhand flip)
|
||||
[1.0]*5 # Hand flat and open
|
||||
]
|
||||
times = [[0.4, 0.8, 1.2, 1.6, 2.0]] * 6
|
||||
|
||||
self.motion.angleInterpolation(names, angles, times, True)
|
||||
|
||||
# Return to neutral
|
||||
neutral = [1.5, -0.15, 1.2, 0.5, 0.0, 0.0]
|
||||
self.motion.angleInterpolationWithSpeed(names, neutral, 0.3)
|
||||
self.motion.setStiffnesses("RArm", 0.6)
|
||||
except Exception as e:
|
||||
print(f"Cena gesture error: {e}")
|
||||
|
||||
def handle_head_movement(self):
|
||||
if self.typing_mode or self.music_search_mode: return
|
||||
keys = pygame.key.get_pressed()
|
||||
@@ -299,7 +325,7 @@ class NaoTeleop:
|
||||
self._safe("moveInit", self.motion.moveInit)
|
||||
print("🦶 Walk engine ready")
|
||||
|
||||
print("\n🎮 Controls: WASD/Arrows=Walk | [/]=Speed | IJKL=Head | SPACE=Reset head | 1=Wave | M=Music search (↑↓ select, Enter confirm) | X=Stop | -/==Volume | T=TTS | ESC=Quit")
|
||||
print("\n🎮 Controls: WASD/Arrows=Walk | [/]=Speed | IJKL=Head | SPACE=Reset head | 1=Wave | 2=Cena | M=Music search | X=Stop | -/==Volume | T=TTS | ESC=Quit")
|
||||
|
||||
try:
|
||||
while self.running:
|
||||
@@ -377,6 +403,8 @@ class NaoTeleop:
|
||||
self.running = False
|
||||
elif event.key == pygame.K_1:
|
||||
self.wave_gesture()
|
||||
elif event.key == pygame.K_2:
|
||||
self.cena_gesture()
|
||||
elif event.key == pygame.K_SPACE:
|
||||
self.reset_head()
|
||||
elif event.key == pygame.K_m:
|
||||
@@ -535,4 +563,3 @@ if __name__ == "__main__":
|
||||
mic_channel=MIC_CHANNELS[args.mic_channel],
|
||||
mic_gain=args.mic_gain,
|
||||
video_scale=args.video_scale).run()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user