apirrone commited on
Commit
5d493e2
·
1 Parent(s): 06b33b7
Files changed (2) hide show
  1. README.md +1 -1
  2. reachy_mini_simon/main.py +33 -6
README.md CHANGED
@@ -1,6 +1,6 @@
1
  ---
2
  title: Reachy Mini Simon
3
- emoji: 👋
4
  colorFrom: red
5
  colorTo: blue
6
  sdk: static
 
1
  ---
2
  title: Reachy Mini Simon
3
+ emoji: 🎮
4
  colorFrom: red
5
  colorTo: blue
6
  sdk: static
reachy_mini_simon/main.py CHANGED
@@ -282,6 +282,8 @@ class ReachyMiniSimon(ReachyMiniApp):
282
  # Game state
283
  state = GameState.IDLE
284
  player_input: List[Direction] = []
 
 
285
 
286
  # Welcome message
287
  print("=" * 50)
@@ -296,16 +298,29 @@ class ReachyMiniSimon(ReachyMiniApp):
296
  print(" - LEFT: Tilt head left")
297
  print(" - RIGHT: Tilt head right")
298
  print(" 4. Hold each tilt for 0.1 seconds - you'll hear the sound!")
299
- print("\nPull an antenna to start!")
300
  print("=" * 50)
301
  print("\nDEBUG MODE: Set detector.debug = True to see orientation values\n")
302
 
303
  # Move to neutral position
 
304
  reachy_mini.goto_target(head=NEUTRAL_POSE, antennas=[0, 0], duration=1.0)
 
 
 
305
 
306
  # Main game loop
307
  while not stop_event.is_set():
308
  if state == GameState.IDLE:
 
 
 
 
 
 
 
 
 
309
  # Wait for antenna pull to start
310
  antennas = reachy_mini.get_present_antenna_joint_positions()
311
  if abs(antennas[0]) > 0.4 or abs(antennas[1]) > 0.4:
@@ -317,6 +332,7 @@ class ReachyMiniSimon(ReachyMiniApp):
317
 
318
  game.reset()
319
  game.add_to_sequence()
 
320
  state = GameState.SHOWING_SEQUENCE
321
 
322
  elif state == GameState.SHOWING_SEQUENCE:
@@ -393,14 +409,19 @@ class ReachyMiniSimon(ReachyMiniApp):
393
  time.sleep(1.0)
394
 
395
  # After celebration, show game over screen
396
- reachy_mini.goto_target(antennas=[-0.5, -0.5], duration=0.5)
397
  print("=" * 50)
398
  print(f"Game Over! Final Score: Round {game.current_round}")
399
  print(f"Best Score: Round {game.best_round}")
400
  print("=" * 50)
401
- print("\nPull an antenna to play again!\n")
 
 
 
 
402
 
403
- time.sleep(3)
 
 
404
  state = GameState.IDLE
405
 
406
  elif state == GameState.GAME_OVER:
@@ -423,9 +444,15 @@ class ReachyMiniSimon(ReachyMiniApp):
423
  print(f"Game Over! Final Score: Round {game.current_round}")
424
  print(f"Best Score: Round {game.best_round}")
425
  print("=" * 50)
426
- print("\nPull an antenna to play again!\n")
 
 
 
 
427
 
428
- time.sleep(3)
 
 
429
  state = GameState.IDLE
430
 
431
  time.sleep(0.02)
 
282
  # Game state
283
  state = GameState.IDLE
284
  player_input: List[Direction] = []
285
+ last_antenna_twitch = 0.0 # Track antenna twitch timing
286
+ ready_for_game = False # Track if we've initialized
287
 
288
  # Welcome message
289
  print("=" * 50)
 
298
  print(" - LEFT: Tilt head left")
299
  print(" - RIGHT: Tilt head right")
300
  print(" 4. Hold each tilt for 0.1 seconds - you'll hear the sound!")
301
+ print("\nInitializing...")
302
  print("=" * 50)
303
  print("\nDEBUG MODE: Set detector.debug = True to see orientation values\n")
304
 
305
  # Move to neutral position
306
+ print("Moving to starting position...")
307
  reachy_mini.goto_target(head=NEUTRAL_POSE, antennas=[0, 0], duration=1.0)
308
+ time.sleep(1.0)
309
+ ready_for_game = True
310
+ print("Ready! Pull an antenna to start!\n")
311
 
312
  # Main game loop
313
  while not stop_event.is_set():
314
  if state == GameState.IDLE:
315
+ # Twitch antenna every 3 seconds to show ready state
316
+ current_time = time.time()
317
+ if ready_for_game and (current_time - last_antenna_twitch >= 3.0):
318
+ # Quick antenna twitch to indicate readiness
319
+ reachy_mini.goto_target(antennas=[0.3, 0], duration=0.15)
320
+ time.sleep(0.15)
321
+ reachy_mini.goto_target(antennas=[0, 0], duration=0.15)
322
+ last_antenna_twitch = current_time
323
+
324
  # Wait for antenna pull to start
325
  antennas = reachy_mini.get_present_antenna_joint_positions()
326
  if abs(antennas[0]) > 0.4 or abs(antennas[1]) > 0.4:
 
332
 
333
  game.reset()
334
  game.add_to_sequence()
335
+ ready_for_game = False # Don't twitch during game
336
  state = GameState.SHOWING_SEQUENCE
337
 
338
  elif state == GameState.SHOWING_SEQUENCE:
 
409
  time.sleep(1.0)
410
 
411
  # After celebration, show game over screen
 
412
  print("=" * 50)
413
  print(f"Game Over! Final Score: Round {game.current_round}")
414
  print(f"Best Score: Round {game.best_round}")
415
  print("=" * 50)
416
+ print("\nResetting to start position...")
417
+
418
+ # Reset to neutral position
419
+ reachy_mini.goto_target(head=NEUTRAL_POSE, antennas=[0, 0], duration=1.0)
420
+ time.sleep(1.0)
421
 
422
+ print("Ready! Pull an antenna to play again!\n")
423
+ ready_for_game = True
424
+ last_antenna_twitch = time.time()
425
  state = GameState.IDLE
426
 
427
  elif state == GameState.GAME_OVER:
 
444
  print(f"Game Over! Final Score: Round {game.current_round}")
445
  print(f"Best Score: Round {game.best_round}")
446
  print("=" * 50)
447
+ print("\nResetting to start position...")
448
+
449
+ # Reset to neutral position
450
+ reachy_mini.goto_target(head=NEUTRAL_POSE, antennas=[0, 0], duration=1.0)
451
+ time.sleep(1.0)
452
 
453
+ print("Ready! Pull an antenna to play again!\n")
454
+ ready_for_game = True
455
+ last_antenna_twitch = time.time()
456
  state = GameState.IDLE
457
 
458
  time.sleep(0.02)