From 99f2d6a9cd24cc97a2c9dc8e258c516966141c85 Mon Sep 17 00:00:00 2001 From: Lucca Pirovano Date: Thu, 16 Jul 2026 14:03:39 -0400 Subject: [PATCH] added walk speed setting on [], refined walk posture --- ...files-and-code_2026-07-16T17-38-58+0000.md | 41 +++++++++++++++++++ naowalk.py | 39 +++++++++++++----- 2 files changed, 70 insertions(+), 10 deletions(-) create mode 100644 chat-history/claude_refactoring-python-project-files-and-code_2026-07-16T17-38-58+0000.md diff --git a/chat-history/claude_refactoring-python-project-files-and-code_2026-07-16T17-38-58+0000.md b/chat-history/claude_refactoring-python-project-files-and-code_2026-07-16T17-38-58+0000.md new file mode 100644 index 0000000..14693ab --- /dev/null +++ b/chat-history/claude_refactoring-python-project-files-and-code_2026-07-16T17-38-58+0000.md @@ -0,0 +1,41 @@ +--- +title: "Refactoring Python project files and code" +tags: [] +author: claude +count: 2 +exporter: 3.1.0 +date: 2026-07-16T17-38-58+0000 +url: https://claude.ai/chat/313cfd88-e6b9-4256-b155-0b389d2b86c4 +--- + +# Refactoring Python project files and code + +## Table of Contents + +- [1: make a requirements.txt, readme.md, and also remove the seek function…](#chat-1) +- [2: how much faster can i make it walk, can we make it adjustable during r…](#chat-2) + +## chat-1 + +> make a requirements.txt, readme.md, and also remove the seek function completely and reduce the lines of code without hurting stability + +Now the `pause()` method — simplify to a plain stop/restart toggle (no seek, no position math): + +Now let's add the `_safe` helper to `NaoTeleop` and use it to collapse the repeated try/except boilerplate: + +Now the shutdown block — this is where `_safe` pays off the most: + +Good — that's stable. Now let's view the final file once more end-to-end to make sure everything reads cleanly before shipping it. + +This looks clean and correct. Now let's write the `requirements.txt` and `README.md`. + +Good, all confirmed. Now the README: + +Now let's copy everything to outputs and present the files: + +___ +###### [top](#table-of-contents) +## chat-2 + +> how much faster can i make it walk, can we make it adjustable during runtime? we might need to change its posture so its less likely to fall and more balanced for carpet + diff --git a/naowalk.py b/naowalk.py index 32322e9..194d0b6 100644 --- a/naowalk.py +++ b/naowalk.py @@ -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: