/ESP32-Robot-Controller

Repo for the library to run an FRC-style robot from an ESP32 microcontroller with a Bluetooth joystick and PWM control for motors.

Primary LanguageC++GNU General Public License v2.0GPL-2.0

ESP32-Robot-Controller

Repo for the library to run an FRC-style robot from an ESP32 microcontroller with a Bluetooth joystick and PWM control for motors.

General Information

Currently the only supported joystick is a PS3 Controller, although support for PS4 controllers may be a possibility in the future. The motor controller class uses the PWM timers and channels built into the ESP32, and you can control which the resolution, frequency, pin #, and channel used for the PWM. The values allowed to be passed to the set() method are limited by what resolution is specified, with the default being 8 bits, and the maximum being 16 bits. In other words, if in 8 bit mode, the maximum power value that can be specified is 127, and the minimum is -128, whereas in 16 bit mode, the maximum is 32767 and the minimum is -32768. 8 bit mode is the default since that is also the resolution of the joysticks on the PS3 controller, so it makes the translation extremely simple.

Installation and Setup

You will need a Windows computer (Linux may also work but you'll have to find another mirror for SixaxisPairTool or build an equivalent tool from source), an ESP32, a PS3 Controller, Micro-USB cable, and Mini-USB cable to connect to the ESP32 and PS3 Controller, respectively.

We used the Arduino IDE for our programming when developing this. Information on setting up the Arduino IDE for ESP32 development can be found here. After getting the board installed in your IDE, you will need to move the code in the src folder in this repo to a new folder under libraries in your Arduino installation. Then go to Sketch->Include Library and find whatever you named the new folder in the libraries list. It should show up under Contributed Libraries. This should include the required header files. You will also need to install this library as it is a required dependency for this software.

After setting up your IDE, you should download SixaxisPairTool from this link. This allows you to modify the saved MAC address inside your PS3 controller to connect it to the ESP32. Change it to an available MAC you would like to use. Then, when using the GameController class, simply pass the MAC address in the controller as a string in the constructor, separating each byte with a colon.

You should be good to go to begin your development with the motor controllers and the ESP32! Examples coming soon.

Limitations

This code will run a very minimalist robot, with only basic motor and controller support, in addition to crude encoder support. More features may be added in the future, but as of now more complicated features like PID control, gyroscopes, etc. are up to you to implement.