New Features

How to Set Up an Xbox Controller for a Pixhawk Autopilot And Fly Using Botlink's XRD2

The purpose of this guide is to share how to set up using an Xbox controller with a Pixhawk controlled drone to the extent that it is nearly similar to using a DJI drone in practice. There is already a guide on ardupilot here, for easy setup if you already have the joystick they used in that tutorial and you don’t care for mimicking DJI drones. But here we will be focusing on if you do not have the usual joystick and are using a gamepad as well as some safety precautions as well when setting something like this up. Setting up the controller, overall, is easy to do and is intuitive if you are familiar with the Mission Planner software that needs to be used.

Let's start by starting up the drone itself by using a wired connection, if you are using a wireless connection make sure the propellers are OFF the drone prior to messing with controller settings. After connecting the drone you should use whatever connection you will be using to connect the controller to the laptop/ground control station that you’ll be using (I used a wired USB to USB-C). If you wanted to control it using Botlink’s XRD2 then all you would need to do is swap your connection type in Mission Planner to TCP at 57600 for the baud rate. When connecting after that the IP should be default to what Mission Planner asks and you’re connected! After this we go to Mission Planner and select the Actions menu just below the Primary Flight Display and then at the bottom of that menu select Joystick (Figure 1).

Figure 1

After selecting this menu a submenu within Mission Planner should pop up and give you a giant list of control inputs (Figure 2). Don’t get too concerned with all the info as realistically you should only need Channels 1-4 on the left and at minimum 3 buttons on the right to make sure everything is in order. One thing to keep in mind, the Enable button at the top should say that the whole time, if it ever says Disable then that means the drone is reading your inputs. But as we go through the flow for setting up channels is easy as:

  • Select the Auto Detect button for Channel 1 on the left half of the menu

  • Move the Pitch joystick to have it read it.

  • Continue this same process for Channels 2, 3, and 4 for Bank, Throttle, and Yaw respectively.

  • Keep in mind that the drop downs to the left can read different depending on the controller being used, don’t change them to what I have. The same goes for the Reverse checkmark for Pitch. Test fly it before checking that.

  • REVERSE THROTTLE USING THE CHECKMARK TO THE RIGHT OF THE CHANNEL.

Figure 2

After we get the channels for controlling the drone we will want to map buttons onto the drone, since this is for keeping a quadcopter as close to a DJI drone as possible we will use 4 buttons mapped as Arm, Disarm, RTL, and PosHold. This will allow us to obviously arm and disarm the drone but also let go of the sticks and the drone will keep its position in space without us needing to do anything else. For setting up buttons we go with this process (Figure 3 for reference):

  • Select Detect next to the button you want to use for Arm 

  • Press the button on the controller you want to use for this button (I used LB and RB for Arm/Disarm respectively).

  • On the right, select the drop down and then find Arm.

  • Repeat for Disarm (order does not matter, this could be button 16 and 7 on the list and it would work all the same).

  • Do the same for PosHold, but on the drop down select ChangeMode and then select the Settings button.

  • This will open a new window with a drop down, there is no “save” button, it will remember what you put in the drop down after closing the window.

  • Repeat for RTL.

Figure 3

Prior to exiting out of the Joystick window we need to hit Save at the top of the screen and then hit Enable (Note: MAKE SURE THE DRONE DOES NOT HAVE PROPELLERS ON PRIOR TO PRESSING ENABLE). Now we will go and see if the mapping was correct. Next we go to the top of Mission Planner and select the Set Up Tab and then go to the Mandatory Hardware drop down. Once here we select Radio Calibration and check to see if Pitch, Bank, Throttle and Yaw are all moving how we want. If your indicators in Figure 4 are not moving make sure the drone is powered with a battery, make sure your controller is connected correctly to the GCS, and go back to the Joystick menu and verify that the same settings are there and that at the top it reads Disable and not Enable

Figure 4

The last check we need to do is that Arm and Disarm work as intended as well as any mode swapping we decided to map onto the controller. The easiest way to check if the drone responds to mode changing is to check the bottom left of the Primary Flight Display (Figure 5) and check what mode it is currently in and then change it using the controller buttons you mapped. If it changes then there you go, that is working as intended. For checking if Arm and Disarm work I used this process:

Figure 5

MAKE SURE NO PROPELLERS ARE ON THE DRONE PRIOR TO DOING THESE STEPS.

  • If your drone has a controller/Transmitter you already use with a hard “Motor Cut off” switch, then enable it. If not and it has a safety switch on the drone, don’t switch it on.

  • Once one, or both, of those safety features are enabled go ahead and try to Arm. 

  • The drone arming buzzer should sound and it should try to arm but will be denied and then Mission Planner will give you the reason why.

  • To check if disarm works as intended, Arm and then immediately Disarm.

  • The drone should sound the buzzer and then stop immediately prior to getting the prearm checks and figuring out it can’t arm. 

Now the last thing that needs to be done is a quick test flight. All my test flying was done using Botlink’s XRD2 with an LTE connection, you can use your drone’s telemetry radio that comes with it as well. Some quick pointers for test flying this and for future use are as follows:

  • Always keep the drone in PosHold during the first flight to verify controls are working as intended

  • Reverse channels as needed (I needed to with my Pitch channel)

  • Every controller/joystick is different

  • You will need to select Enable in the Joystick submenu every time you start up the drone.

  • If you disconnect the controller during flight it has a hard time figuring out you reconnected, just hit Disable/Enable on the Joystick menu until it starts responding again.

  • Make sure you have a failsafe for what the drone will do incase your controller disconnects (RTL/Loiter/etc.)