From 158372e528ad81a39c007b575680620db84315bb Mon Sep 17 00:00:00 2001 From: Lucca Pirovano Date: Thu, 16 Jul 2026 14:21:29 -0400 Subject: [PATCH] working on cena gesture (2) --- naowalk.py | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/naowalk.py b/naowalk.py index 5daae3a..01cf9f9 100644 --- a/naowalk.py +++ b/naowalk.py @@ -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() -