This library is the first step in creating a small robot using an API similar to the one used by Pioneers at Berkeley.
Make sure you have the following installed:
- Python 3
- Pygame
- PySerial
- Pynput
You can install the required Python packages using pip:
pip install pygame pyserial pynput
- Open Device Manager by right-clicking on the Windows Start menu and selecting Device Manager.
- In Device Manager, expand the Ports (COM & LPT) section.
- Look for a device labeled USB Serial Device. Note the COM port number (e.g., COM3).
This is the COM port you’ll need to use in your code.
-
Open settings and navigate to Security and Privacy
-
Open input monitoring
-
Enable the terminal for input monitoring
-
Re-open terminal (you may need to close it)
-
Change directory to /dev/ and list the "usbmodems"
ls /dev/cu.*
You should see similar output (you want the one that has "usbmodem"):
/dev/cu.Bluetooth-Incoming-Port /dev/cu.usbmodem14792 /dev/cu.SLAB_USBtoUART /dev/cu.SLAB_USBtoUART7
- Easy test is to run test_robot.py. This will auto-find your com ports.
- Run it:
python3 test_robot.py
-
More direct editing - in case you know one of the motor controller ports.
-
Open
test.py
in your code editor. -
Replace the COM port (or
/dev/tty***
on Linux/Mac) with the appropriate COM port for your device. -
Save
test.py
. -
Run the test script to verify communication with the motor controller:
python3 ./test.py
If everything is set up correctly, you should see messages coming back from the motor controller.
Each motor controller has a unique name. You can find out the name by sending the following serial command:
GET_NAME
This will return a string that identifies the motor controller, like: TLAWIEESYT
.
Make sure to enter these names in the code wherever necessary to identify and control each motor controller correctly.