Getting started

Configuration

There are two main configuration files needed to correctly run the psdk_ros2 wrapper.

  1. link_config.json (default path: psdk_wrapper/cfg)
    A json file similar to the one used within the Payload-SDK samples which allows you to configure the type of connection/link you are using to connect to the DJI drone. This is related to the hardware you are using to connect to the drone.

  2. psdk_params.yaml (default path: psdk_wrapper/cfg)
    A yaml file which defines all ROS 2 parameters used by the wrapper. The information regarding the App configuration (e.g. app_id, app_ket, etc) can be configured here as a ROS 2 parameter. IMPORTANT! You need to select which modules you want to load in this file before launching the wrapper.

Hardware connection

Before launching the psdk_ros2 wrapper, you must ensure that you are using the proper hardware connection to the DJI drone you are using. Various methods exist for establishing connections between DJI drones and companion computers. The approach may vary depending on the drone model and the companion computer in use. Below is a summary table illustrating each device port name and the DJI development kit that can be used. For the most recent updates, please refer to the latest version of the table.

Aircraft

Port Name

Adapted Development Kit

Matrice 3D/3TD

E-Port

E-Port Development Kit

E-Port Lite

-

FlyCart 30

E-Port Lite

-

M350 RTK

E-Port

E-Port Development Kit / SDK Round Ribbon Cable

PSDK Port (Gimbal Port)

SkyPort V2 Development Kit / SkyPort V2 Production Suit / DJI X-Port

Mavic 3E/3T

E-Port

E-Port Development Kit

Matrice 30/30T

E-Port

E-Port Development Kit / SDK Round Ribbon Cable / PSDK Mounting Bracket

M300 RTK

OSDK Port

E-Port Development Kit / SDK Round Ribbon Cable / OSDK Expansion Module

PSDK Port (Gimbal Port)

SkyPort V1/V2 Development Kit / X-port / SkyPort V1/V2 Production Suit

Once you’ve established the hardware connection between your board and the DJI drone, you can configure the psdk_ros2 wrapper to utilize that setup through the psdk_wrapper/cfg/link_config.json file. One important parameter when filling in the link_config.json is to properly select what type of connection you are using. From all the possible configurations, the following have been (so far) tested and validated with the psdk_ros2 wrapper.

Aircraft

Port Name

Adapted Development Kit

psdk_ros2 link config

M350 RTK

E-Port

SDK Round Ribbon Cable

use_uart_and_network_device

Matrice 30/30T

E-Port

SDK Round Ribbon Cable

use_uart_and_network_device

M300 RTK

OSDK Port

OSDK Expansion Module

use_uart_and_usb_bulk_device

The link configurations represent the different channels DJI uses to send information from the drone to 3rd party development platforms. In very generic terms, these channels are used for:

  • UART serial: used to send commands to the drone and receive most of the information

  • USB Bulk / Network device : used to retrive and send different cameras stream (e.g. main camera, FPV, perception) and perform media file management

Usually the serial interface is supported out-of-the-box by most systems, thus the basic functionalities of the psdk_ros2 wrapper are guaranteed. However, to interact with the different cameras on-board the drone, the USB bulk or Network device interface needs to be enabled on your computer. DJI offers a series of instructions and scripts to set-up the E-Port connection and enable the USB Bulk function for the Jetson Nano and Raspberry Pi 4B boards:

  • Jetson Nano instructions - Jetson Nano scripts

    • If you want to enable the Ethernet interface, you can try to follow the instructions provided in the readme.txt file that comes within the scripts folder

  • Raspberry 4B instructions - Raspberry 4B scripts

For any other board, you must make sure to enable either the USB Bulk or the Network interface to be able to access the camera stream via the psdk_ros2 wrapper. Please check the Basic Concepts page to know more about this topic.

Example of DJI M300 - OKSD Port - OSDK Expansion Module connection

This connection is compatible exclusively with the M300 RTK drone. Upon establishing the connection, two devices will be recognized by the computer, usually /tty/USB0 and /tty/ACM0. To maintain consistent device naming across sessions, refer to the ‘Udev rules’ section, which provides guidance on preventing device name alterations each time the devices are connected.

Steps:

  1. Connect the FTDI adapter to the designated pins on the OSDK Exapansion module for serial communication

  2. Use a mini-USB A to USB A cable (this cable is different depending on the ftdi module you use) to connect the FTDI adapter to the computer’s USB 2.0 port

  3. Connect the USB A to USB A from the OSDK Expansion module to the USB port of the computer

  4. Connect the power cable from the OSDK Expansion module to supply power to the companion computer

  5. Use the default link_config.json file to run the psdk_ros2 wrapper

Caution: The OSDK expansion module outputs 24V. Ensure that your companion computer can tolerate this voltage level. If not, you must use an appropriate step-down module to reduce the voltage to a safe level for your device.

ROS 2 Parameter configuration

The following parameters can be configured in the psdk_wrapper/cfg/psdk_params.yaml file:

Parameter

Data Type

Default Value

Comments

app_name

String

-

Add your App name

app_id

String

-

Add your App id

app_key

String

-

Add your App key

app_license

String

-

Add your App license

developer_account

String

-

Add your developer account (not mandatory)

baudrate

String

921600

The value configured on the Dji assitant software 2 on the onboard sdk section, takes precedence. If the DA2 software is configured with an unsupported baud rate, it will then retrieve the baud rate configured in the PSDK. If that is also not compatible, the baud rate will be automatically selected.

num_of_initialization_retries

Int

1

Num of retries to init the PSDK app

tf_frame_prefix

String

TF frame prefix

Add prefix before the frame name

imu_frame

String

“psdk_imu_link”

-

body_frame

String

“psdk_base_link”

-

map_frame

String

“psdk_map_enu”

-

gimbal_frame

String

“psdk_gimbal_link”

-

gimbal_base_frame

String

“psdk_gimbal_base_link”

-

camera_frame

String

“psdk_camera_link”

-

file download path

String

“/logs/media”

-

mandatory_modules

- telemetry

Bool

True

Load module (Needs to be true for operation)

- flight_control

Bool

True

Load module (Needs to be true for operation)

- camera

Bool

True

Load module

- gimbal

Bool

True

Load module

- liveview

Bool

True

Load module

- hms

Bool

True

Load module

- perception

Bool

True

Load module

data_frequency

Object

-

Options are: 1, 5, 10, 50, 100, 200, 400 Hz

- imu

Integer

100

-

- attitude

Integer

100

-

- acceleration

Integer

50

-

- velocity

Integer

50

-

- angular_velocity

Integer

100

-

- position

Integer

50

-

- altitude

Integer

50

-

- gps_data

Integer

1

-

- rtk_data

Integer

1

-

- magnetometer

Integer

50

-

- rc_channels_data

Integer

1

-

- gimbal_data

Integer

1

-

- flight_status

Integer

1

-

- battery_level

Integer

1

-

- control_information

Integer

1

-

- esc_data_frequency

Integer

1

-

Set-up device permissions

To retrieve the information from the drone, DJI’s Payload-SDK requires read and write permissions for the devices it uses. To enable this, one can change the permissions of a certain device in isolation with:

# Example of permission change for device /dev/ttyUSB0
# Add user to the dialout group
sudo usermod -a -G dialout $USER
# Allow read and write access to owner and group members
sudo chmod 660 /dev/ttyUSB0
# (Alternatively - less safe) allow read-write-execution permissions to all 
sudo chmod 777 /dev/ttyUSB0

To make the changes persistent, one can define udev rules as explained in the following section.

Udev rules

To avoid changing the device name each time you run the psdk application and to make the permissions persistend, you can enable udev rules for the devices used by the Payload-SDK to connect to the drone. Below is an example of such udev rules for the devices used when connecting a DJI M300 via the OSKD Extension Module.

# DJI Serial Comm
SUBSYSTEM=="tty", SUBSYSTEMS=="usb", ATTRS{idVendor}=="YourVendor", ATTRS{idProduct}=="YourProduct", MODE="0666", SYMLINK+="dji_serial"
# DJI Advanced Sensing
SUBSYSTEM=="tty", SUBSYSTEMS=="usb", ATTRS{idVendor}=="YourVendor", ATTRS{idProduct}=="YourProduct", MODE="0666", SYMLINK+="dji_advanced_sensing"

Bear in mind that depending on your hardware set-up, the devices used for communicating with the drone will be different and thus you will need to make your own custom udev rules.