How to connect gamepads directly to RC phone without a DS phone
Tags: TipsPersonhours: 4
How to tweak ftc_app to allow you to drive robots without a Driver Station phone:
A lot of teams have been asking about how we were able to tweak our code to allow us to drive robots without a Driver Station. We posted about this earlier in the post titled Cart Hack, but now we are going to show you how to do this.
First, we have to add code to FtcRobotControllerActivity
to allow it to handle any joystick events. We do this by adding the following lines to the bottom of the class (still above the last closing bracket).
This lets us handle gamepad events in the activity. Then, we create the following class in the same folder as FtcRobotControllerActivity
. This lets us access the RC phone's gamepad in our OpModes.
Finally, in any of our OpModes where we wish to use the RC's gamepads, we add the following static import to the top of our code (under the other import statements).
Now, wherever we want to use the RC phone's gamepad, we use gamepadRC
wherever we would be using gamepad1
normally.
In order to actually connect a gamepad to the RC phone, along with the REV Hub (or Modern Robotics equivalent), we need to use a USB hub. You connect the USB hub into the OTG cable (which is then plugged into the phone), and plug both the gamepad and REV hub into the USB hub. You do not need to use a powered hub for this, any regular USB hub will work. This is the same type of USB hub that you would use if you wanted to plug two gamepads into the driver station.
That's all! We hope that this guide will help you replicate what we have done with our Robot Controller app to help make robot development easier!