Instructional Material: Fly with a Game Controller

So far we have written drone control programs that are autonomous in nature. That is, they do what they do without any input from us in the course of execution. Lets switch gears and explore writing programs that allow for direct user control of the drone. The Tello has a command called RC (remote control) that accepts input from a game controller. Using this command and a controller, you can operate the Tello remotely just like a Tetrix or RoboRio based robot.

The Tello-SDK includes support for X-Box style controllers. This lesson was developed using a Logitech F310 controller just like Tetrix robots use. When you plug your controller into a Windows PC the first time it will install a Windows driver for the controller.

With all this in place, we can write a program that controls drone movement with controller joysticks, and drone functions with controller  buttons. At the start of the example the code takes no flight action, but goes into a loop monitoring the controller buttons. Press the Start button to take off and press the Back button to land. Press the A button to take a picture and the Dpad.Up button to do a flip. Use the joysticks to control drone movement. The amount of joy stick deflection controls the speed at which the drone moves.

Examine the FlyController class to see how all this is done. Then modify the Main class to execute the FlyController class.

Modify the code to support starting and stopping video recording. Add more Dpad buttons to select the other flip directions.

 

Material Type: 
Lab Activity
Education Level: 
Middle School
High School
Focus Subject: 
Computing / Computer Science
Robotics Software
HW Platform: 
DJI Tello
SW Platform: 
Java
Interactivity Style: 
Mixed