mag_dist_playground.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import sys
  2. import time
  3. #Test Git
  4. from robot_control.src.robot.mag_distributor import MagDistributor
  5. from robot_control.src.utils.config import ConfigParser
  6. from robot_control.src.api.gpio import GPIOInterface, MockGPIO, PiGPIO
  7. def main():
  8. # You may need to adjust these to your environment
  9. config = ConfigParser().config
  10. gpio_config = config.gpio
  11. gpio_config.mag_dist_rot_pin = 14
  12. if gpio_config.debug:
  13. gpio = MockGPIO()
  14. else:
  15. gpio = PiGPIO()
  16. mag_dist = MagDistributor(config, gpio)
  17. print("MagDistributor Playground")
  18. print("Commands:")
  19. print(" h - home")
  20. print(" m <pos_mm> <rot_deg> - move to position (mm, deg)")
  21. print(" q - quit")
  22. while True:
  23. cmd = input("Enter command: ").strip()
  24. if cmd == "q":
  25. print("Exiting.")
  26. break
  27. elif cmd == "h":
  28. print("Homing...")
  29. import asyncio
  30. asyncio.run(mag_dist.home())
  31. print("Homed.")
  32. elif cmd.startswith("m "):
  33. try:
  34. _, pos_mm, rot_deg = cmd.split()
  35. pos_mm = float(pos_mm)
  36. rot_deg = float(rot_deg)
  37. mag_dist.move_mag_distributor_at_pos(pos_mm, rot_deg)
  38. print(f"Moved to {pos_mm} mm, {rot_deg} deg.")
  39. except Exception as e:
  40. print(f"Invalid move command: {e}")
  41. else:
  42. print("Unknown command.")
  43. if __name__ == "__main__":
  44. main()