Compare commits

...

9 Commits

Author SHA1 Message Date
47fc81eab1 a 2024-12-28 20:17:25 +01:00
e7e2be6c6a a 2024-12-28 20:16:44 +01:00
573a15ffdc a 2024-12-28 20:15:35 +01:00
9defed0f3e a 2024-12-28 20:08:21 +01:00
5584b058db a 2024-12-28 20:04:42 +01:00
9efa31daf8 a 2024-12-28 20:03:55 +01:00
064fc6befa a 2024-12-28 19:55:12 +01:00
a1168528d5 a 2024-12-28 19:43:39 +01:00
e4769a434d a 2024-12-28 19:42:27 +01:00

View File

@@ -9,7 +9,7 @@ from adafruit_servokit import ServoKit # type: ignore
kit = ServoKit(channels=16)
# Constants for delay
DELAY = 0.25
DELAY = 0.15
# Servo angle configurations
FORWARD = {
@@ -27,34 +27,49 @@ FORWARD = {
11: (110, 10, 90),
}
ROTATE_RIGHT = { # Placeholder, update values later
0: (0, 100, 60),
1: (0, 100, 60),
2: (0, 100, 60),
3: (0, 100, 60),
4: (0, 100, 60),
5: (0, 100, 60),
6: (10, 100, 80),
7: (10, 110, 55),
8: (60, 160, 80),
9: (160, 60, 80),
10: (110, 10, 55),
11: (100, 10, 80),
BACK = {
0: (0, 110, 70),
1: (0, 110, 70),
2: (0, 110, 70),
3: (0, 110, 70),
4: (0, 110, 70),
5: (0, 110, 70),
6: (110, 10, 90),
7: (120, 10, 65),
8: (170, 70, 90),
9: (70, 170, 90),
10: (10, 120, 65),
11: (10, 110, 90),
}
ROTATE_LEFT = { # Placeholder, update values later
0: (0, 120, 80),
1: (0, 120, 80),
2: (0, 120, 80),
3: (0, 120, 80),
4: (0, 120, 80),
5: (0, 120, 80),
6: (10, 120, 100),
7: (10, 130, 75),
8: (80, 180, 100),
9: (180, 80, 100),
10: (130, 10, 75),
11: (120, 10, 100),
ROTATE_RIGHT = {
0: (0, 110, 70),
1: (0, 110, 70),
2: (0, 110, 70),
3: (0, 110, 70),
4: (0, 110, 70),
5: (0, 110, 70),
6: (10, 170, 90),
7: (10, 120, 65),
8: (10, 170, 90),
9: (10, 170, 90),
10: (10, 120, 65),
11: (10, 170, 90),
}
ROTATE_LEFT = {
0: (0, 110, 70),
1: (0, 110, 70),
2: (0, 110, 70),
3: (0, 110, 70),
4: (0, 110, 70),
5: (0, 110, 70),
6: (170, 10, 90),
7: (120, 10, 65),
8: (170, 10, 90),
9: (170, 10, 90),
10: (120, 10, 65),
11: (170, 10, 90),
}
# Movement functions
@@ -71,7 +86,7 @@ def move_leg(servo1, servo2, servo_angles):
time.sleep(DELAY)
kit.servo[servo2].angle = back
time.sleep(DELAY)
time.sleep(DELAY*2)
kit.servo[servo1].angle = up
time.sleep(DELAY)
@@ -129,7 +144,7 @@ def is_input_available():
# Main execution
if __name__ == "__main__":
print("Press 'w' for FORWARD, 'a' for LEFT, 'd' for RIGHT. Press 'q' to quit.")
print("Press 'w' for FORWARD, 'a' for LEFT, 'd' for RIGHT, 's' for BACK. Press 'q' to quit.")
command_queue = queue.Queue()
@@ -137,7 +152,7 @@ if __name__ == "__main__":
while True:
if is_input_available():
input_char = sys.stdin.read(1).strip()
if input_char in ['w', 'a', 'd']:
if input_char in ['w', 'a', 'd', 's']:
command_queue.put(input_char)
elif input_char == 'q':
print("Exiting...")
@@ -157,7 +172,11 @@ if __name__ == "__main__":
print("Executing RIGHT movement...")
group_1(ROTATE_RIGHT)
group_2(ROTATE_RIGHT)
elif command == 's':
print("Executing BACK movement...")
group_1(BACK)
group_2(BACK)
time.sleep(0.1) # Idle loop
except KeyboardInterrupt:
print("\nProgram terminated.")
print("\nProgram terminated.")