()
| 75 | |
| 76 | |
| 77 | def Main(): |
| 78 | |
| 79 | print(" _____ _____ _ _____ ____ ") |
| 80 | print(" / ____| | __ (_)/ ____| |___ \ ") |
| 81 | print(" | | __ ___ | |__) || | __ ___ __) |") |
| 82 | print(" | | |_ |/ _ \| ___/ | | |_ |/ _ \ |__ < ") |
| 83 | print(" | |__| | (_) | | | | |__| | (_) | ___) |") |
| 84 | print(" \_____|\___/|_| |_|\_____|\___/ |____/ ") |
| 85 | print(" ") |
| 86 | |
| 87 | print("To move the robot around using the mouse buttons press 1 and enter.") |
| 88 | print("To move the robot around using the movements of the mouse press 2 and enter.") |
| 89 | |
| 90 | # read data from the keyboard |
| 91 | # if it fails reading the right values, then the script exits |
| 92 | try: |
| 93 | choice = int(input("choice (1/2) = ")) |
| 94 | except ValueError: |
| 95 | print("Invalid number read") |
| 96 | sys.exit(1) |
| 97 | |
| 98 | if not (choice == 1 or choice == 2): |
| 99 | print("Invalid number entered") |
| 100 | sys.exit(1) |
| 101 | |
| 102 | # now the choice var can either be 1 or 2 |
| 103 | # show different menus depending on the choice var |
| 104 | print("\nWith this script you can control your GoPiGo3 robot with a wireless mouse.") |
| 105 | if choice == 1: |
| 106 | print("1. Left + Right buttons of the mouse - move the GoPiGo3 forward") |
| 107 | print("2. Left button of the mouse - move the GoPiGo3 to the left") |
| 108 | print("3. Right button of the mouse - move the GoPiGo3 to the right") |
| 109 | print("4. Middle button of the mouse - move the GoPiGo3 backward") |
| 110 | else: |
| 111 | print("1. Move the mouse forward - for moving the GoPiGo3 forward") |
| 112 | print("2. Move the mouse backward - for moving the GoPiGo3 backward") |
| 113 | print("3. Move the mouse to the left - for rotating the GoPiGo3 to the left") |
| 114 | print("4. Move the mouse to the right - for rotating the GoPiGo3 to the right") |
| 115 | |
| 116 | # Wait for an input to start |
| 117 | input("\nPress Enter to start") |
| 118 | |
| 119 | # create an instance of the EasyGoPiGo3 class |
| 120 | # if it fails instantiating the object, then the scripts exits |
| 121 | try: |
| 122 | robot = EasyGoPiGo3() |
| 123 | |
| 124 | except IOError: |
| 125 | print("GoPiGo3 not detected") |
| 126 | sys.exit(1) |
| 127 | |
| 128 | except gopigo3.FirmwareVersionError: |
| 129 | print("Please update your GoPiGo3 firmware") |
| 130 | sys.exit(1) |
| 131 | |
| 132 | except Exception: |
| 133 | print("Something went wrong") |
| 134 | sys.exit(1) |
no test coverage detected