Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a20909b8ff | |||
| 457228b237 | |||
| 5f12b92f3d | |||
| 980bca205d |
+1973
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1 @@
|
|||||||
|
https://github.com/iikoshteruu/enhanced-grok-export
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import sys
|
||||||
|
import qi
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser(description="Get or set a NAO robot's volume.")
|
||||||
|
parser.add_argument("--ip", required=True, help="NAO IP address")
|
||||||
|
parser.add_argument("--port", type=int, default=9559, help="NAOqi port (default: 9559)")
|
||||||
|
parser.add_argument(
|
||||||
|
"--set",
|
||||||
|
type=int,
|
||||||
|
metavar="VOLUME",
|
||||||
|
help="Set volume (0-100)"
|
||||||
|
)
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
try:
|
||||||
|
session = qi.Session()
|
||||||
|
session.connect(f"tcp://{args.ip}:{args.port}")
|
||||||
|
except RuntimeError as e:
|
||||||
|
print(f"Failed to connect: {e}", file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
audio = session.service("ALAudioDevice")
|
||||||
|
|
||||||
|
if args.set is not None:
|
||||||
|
volume = max(0, min(100, args.set))
|
||||||
|
audio.setOutputVolume(volume)
|
||||||
|
print(f"Volume set to {volume}%")
|
||||||
|
|
||||||
|
print(f"Current volume: {audio.getOutputVolume()}%")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
+72
-31
@@ -18,40 +18,23 @@ class NaoTeleop:
|
|||||||
self.video_client = None
|
self.video_client = None
|
||||||
self.running = True
|
self.running = True
|
||||||
|
|
||||||
# Ultra-optimized video setup
|
self.head_yaw = 0.0
|
||||||
|
self.head_pitch = 0.0
|
||||||
|
|
||||||
self._init_video_maxfps()
|
self._init_video_maxfps()
|
||||||
|
|
||||||
pygame.init()
|
pygame.init()
|
||||||
self.screen = pygame.display.set_mode((320, 240)) # Smaller window = faster
|
self.screen = pygame.display.set_mode((320, 240))
|
||||||
pygame.display.set_caption("NAO Teleop - MAX FPS")
|
pygame.display.set_caption("NAO Teleop - Wave on 1")
|
||||||
self.clock = pygame.time.Clock()
|
self.clock = pygame.time.Clock()
|
||||||
|
|
||||||
def _init_video_maxfps(self):
|
def _init_video_maxfps(self):
|
||||||
try:
|
try:
|
||||||
self.video = self.session.service("ALVideoDevice")
|
self.video = self.session.service("ALVideoDevice")
|
||||||
print("✅ ALVideoDevice found")
|
self.video_client = self.video.subscribeCamera("TeleopCam", 0, 0, 11, 25)
|
||||||
|
print("✅ Camera ready")
|
||||||
except:
|
except:
|
||||||
print("❌ No video service")
|
print("Camera not available")
|
||||||
return
|
|
||||||
|
|
||||||
try:
|
|
||||||
# MAX SPEED SETTINGS:
|
|
||||||
self.video_client = self.video.subscribeCamera(
|
|
||||||
"MaxFpsCam",
|
|
||||||
0, # Top camera
|
|
||||||
0, # 0 = kQQVGA (80x60) → fastest
|
|
||||||
11, # RGB
|
|
||||||
30 # Ask for 30fps (realistic ~15-20)
|
|
||||||
)
|
|
||||||
print("🚀 Camera subscribed in MAX FPS mode (80x60)")
|
|
||||||
except Exception as e:
|
|
||||||
print(f"Subscription failed: {e}")
|
|
||||||
# Fallback
|
|
||||||
try:
|
|
||||||
self.video_client = self.video.subscribe("MaxFpsCam", 0, 11, 20)
|
|
||||||
print("✅ Fallback subscription used")
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def get_image(self):
|
def get_image(self):
|
||||||
if not self.video or not self.video_client:
|
if not self.video or not self.video_client:
|
||||||
@@ -62,23 +45,79 @@ class NaoTeleop:
|
|||||||
w, h = image[0], image[1]
|
w, h = image[0], image[1]
|
||||||
arr = np.frombuffer(bytearray(image[6]), dtype=np.uint8).reshape((h, w, 3))
|
arr = np.frombuffer(bytearray(image[6]), dtype=np.uint8).reshape((h, w, 3))
|
||||||
frame = cv2.cvtColor(arr, cv2.COLOR_RGB2BGR)
|
frame = cv2.cvtColor(arr, cv2.COLOR_RGB2BGR)
|
||||||
# Minimal processing
|
|
||||||
return cv2.resize(frame, (320, 240), interpolation=cv2.INTER_NEAREST)
|
return cv2.resize(frame, (320, 240), interpolation=cv2.INTER_NEAREST)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def wave_gesture(self):
|
||||||
|
print("🤚 Waving hello...")
|
||||||
|
try:
|
||||||
|
self.motion.setStiffnesses("RArm", 1.0)
|
||||||
|
|
||||||
|
# Friendly high wave
|
||||||
|
names = ["RShoulderPitch", "RShoulderRoll", "RElbowYaw", "RElbowRoll", "RWristYaw"]
|
||||||
|
|
||||||
|
# Better motion: arm raised higher + side-to-side wave
|
||||||
|
angles = [
|
||||||
|
[-1.0, -0.8, -1.0, -0.8, -1.0], # RShoulderPitch (raise arm high)
|
||||||
|
[ 0.2, -0.5, 0.2, -0.5, 0.2], # RShoulderRoll
|
||||||
|
[ 0.8, 1.2, 0.8, 1.2, 0.8], # RElbowYaw
|
||||||
|
[-1.0, -0.3, -1.0, -0.3, -1.0], # RElbowRoll
|
||||||
|
[ 0.0, 1.5, 0.0, -1.5, 0.0] # RWristYaw (hand wave)
|
||||||
|
]
|
||||||
|
|
||||||
|
times = [[0.5, 1.0, 1.5, 2.0, 2.5]] * 5
|
||||||
|
|
||||||
|
self.motion.angleInterpolation(names, angles, times, True)
|
||||||
|
|
||||||
|
# Strong return to neutral position
|
||||||
|
self.motion.setAngles("RArm", [0.0] * 5, 0.6)
|
||||||
|
time.sleep(0.8) # Give time to settle
|
||||||
|
|
||||||
|
print("✅ Better wave completed")
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Wave error: {e}")
|
||||||
|
|
||||||
|
def handle_head_movement(self):
|
||||||
|
keys = pygame.key.get_pressed()
|
||||||
|
speed = 0.3
|
||||||
|
changed = False
|
||||||
|
|
||||||
|
if keys[pygame.K_i]:
|
||||||
|
self.head_pitch = max(self.head_pitch - speed, -0.5); changed = True
|
||||||
|
if keys[pygame.K_k]:
|
||||||
|
self.head_pitch = min(self.head_pitch + speed, 0.5); changed = True
|
||||||
|
if keys[pygame.K_j]:
|
||||||
|
self.head_yaw = min(self.head_yaw + speed, 2.0); changed = True
|
||||||
|
if keys[pygame.K_l]:
|
||||||
|
self.head_yaw = max(self.head_yaw - speed, -2.0); changed = True
|
||||||
|
|
||||||
|
if changed:
|
||||||
|
self.motion.setAngles(["HeadYaw", "HeadPitch"], [self.head_yaw, self.head_pitch], 0.3)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.motion.wakeUp()
|
self.motion.wakeUp()
|
||||||
self.posture.goToPosture("StandInit", 0.5)
|
self.posture.goToPosture("StandInit", 0.5)
|
||||||
print("🚀 MAX FPS MODE ACTIVE - WASD/Arrows | ESC to quit")
|
|
||||||
|
print("🎮 Controls:")
|
||||||
|
print(" WASD / Arrows = Walk")
|
||||||
|
print(" I J K L = Head")
|
||||||
|
print(" 1 = Wave")
|
||||||
|
print(" ESC = Quit")
|
||||||
|
|
||||||
while self.running:
|
while self.running:
|
||||||
for event in pygame.event.get():
|
for event in pygame.event.get():
|
||||||
if event.type == pygame.QUIT or (event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE):
|
if event.type == pygame.QUIT:
|
||||||
self.running = False
|
self.running = False
|
||||||
|
elif event.type == pygame.KEYDOWN:
|
||||||
|
if event.key == pygame.K_ESCAPE:
|
||||||
|
self.running = False
|
||||||
|
elif event.key == pygame.K_1:
|
||||||
|
self.wave_gesture()
|
||||||
|
|
||||||
# Fast input handling
|
# Walking
|
||||||
keys = pygame.key.get_pressed()
|
keys = pygame.key.get_pressed()
|
||||||
x = y = theta = 0.0
|
x = y = theta = 0.0
|
||||||
if keys[pygame.K_w] or keys[pygame.K_UP]: x = 0.9
|
if keys[pygame.K_w] or keys[pygame.K_UP]: x = 0.9
|
||||||
@@ -91,6 +130,8 @@ class NaoTeleop:
|
|||||||
else:
|
else:
|
||||||
self.motion.stopMove()
|
self.motion.stopMove()
|
||||||
|
|
||||||
|
self.handle_head_movement()
|
||||||
|
|
||||||
# Camera
|
# Camera
|
||||||
frame = self.get_image()
|
frame = self.get_image()
|
||||||
if frame is not None:
|
if frame is not None:
|
||||||
@@ -101,9 +142,9 @@ class NaoTeleop:
|
|||||||
self.screen.fill((10, 10, 30))
|
self.screen.fill((10, 10, 30))
|
||||||
|
|
||||||
pygame.display.flip()
|
pygame.display.flip()
|
||||||
self.clock.tick(0) # MAX speed (no limit)
|
self.clock.tick(0)
|
||||||
|
|
||||||
# Clean shutdown
|
# Shutdown
|
||||||
print("Shutting down...")
|
print("Shutting down...")
|
||||||
self.motion.stopMove()
|
self.motion.stopMove()
|
||||||
self.motion.rest()
|
self.motion.rest()
|
||||||
|
|||||||
Reference in New Issue
Block a user