This script turns your DJI RC-N1 controller into an Xbox 360 controller, so you can use it with your favorite drone simulator.
- Only for Mac users: first install the Xbox 360 Controller driver for your OS version (not tested yet).
- Download and install DJI Assistant 2 (Consumer Drones Series)
This is only needed to install the DJI drivers for the controller.
IMPORTANT: DO NOT run this script while DJI Assistant 2 is running! - Download and install Python 3.x.x.
- Install the required packages for this project:
pip3 install vgamepad pyserial python-dotenv colorama
.
- Connect your DJI RC-N1 controller to your computer via the USB-C port ON THE BOTTOM PORT (the port between the two joystick holders) of the controller.
- Power on the controller.
- Run
python dji.py
from the terminal to start the script.
terminal with SHOW_DEBUG=1 (animated gif)
terminal with SHOW_DEBUG=0, perhaps faster
From time to time there is bigger lag between measurements, to observe this phenomenon with SHOW_DEBUG=1 there is possibility to set SHOW_GT20=1 and programs shows such situations
Additionally after stopping program there is deatiles statistics of transfered data and some information about processed packets
- Click
Ctrl+C
on Windows orCmd+C
on Mac to stop the script.
TIP: test if the controller works with the Gamepad Tester.
Move the joysticks and the Camera Control Dial to see if the buttons are activated.
Besides the two joysticks, only the Camera Control Dial is accessible through the script.
By default, the Camera Dial is mapped to the A (dial all the way to the left) and B (dial all the way to the right) buttons of the Xbox controller.
In the .env
file you can change the Camera Dial mapping.
# possible values for BAUD_RATE are: 9600 (slowest), 19200, 38400, 57600, 115200 (fastest)
# BAUD_RATE is not used, nothing changes for different values, Windows sets everything
BAUD_RATE=921600
#ON/OFF runtime information, 1 show, 0 do not show (default)
SHOW_DEBUG=0
#ON/OFF show situations when time difference between measure packets is > 20 ms, 1 show, 0 do not show (default), works when SHOW_DEBUG = 1
SHOW_GT20=0
# possible values for Xbox controller are:
# A, B, X, Y, START, BACK, LB (left bumper), RB (right bumper), LT (left trigger), RT (right trigger)
CAMERA_RIGHT_BUTTON=B
CAMERA_LEFT_BUTTON=A
# how for to move the camera roller to the left/right before the button is triggered (min 0.1, max 1.0, default 0.2)
CAMERA_ROLL_SENSITIVITY=0.2
- You have installed the drivers for the controller with DJI Assistant 2 (Consumer Drones Series)?
- Your controller is connected to your computer via the USB-C port ON THE BOTTOM of the controller?
- Use a good quality USB-C cable (not all cables are capable of data transfer, some of them are from poor quality and maybe the cable is just to long).
Try different cables or lower the baud rate in the.env
file.
If all of the above is correct, you should see the controller as "DJI USB VCOM For Protocol (COMx)" in the device manager of Windows under "Ports (COM & LPT)"
This script is based on the Matsemann/mDjiController script with extra features to customize the mapping of the Camera Control Dial.
- Added sensitivity setting for Camera Control Dial
- Simpler and more stable and faster
- possibility to monitor measure times greater than 20 ms
- measure of serial speed
- statistic of transmitted data and distribution of time between measure packets
- More stable and with position status report.
- Fallback for Windows 11: port must be configured before it can be used.
- First release