DJI ROS - AnandaNN/M100_DTU_ROS GitHub Wiki
The DJI ROS package is a ROS wrapper for their DJI SDK api that is used to communicate with the DJI Drone. When using it with the M100 use version 3.8 or 3.9 as the later version >= 4 are for their other platforms (M210, M300, M600).
The package runs a node that sets up all the subscribers, publishers and services that are available to the user. To start it include it in the launch file where different parameters are configurable:
<node pkg="dji_sdk" type="dji_sdk_node" name="dji_sdk" output="screen">
<!-- node parameters -->
<param name="serial_name" type="string" value="/dev/ttyUSB0"/>
<param name="baud_rate" type="int" value="230400"/>
<param name="app_id" type="int" value="1082161"/>
<param name="app_version" type="int" value="1"/>
<param name="align_time" type="bool" value="false"/>
<param name="enc_key" type="string" value="aa7f4935a5c220dd2d7e1ca4f0fcc75d0b7e51b99aad7d44f74e7c468c639e8c"/>
<param name="use_broadcast" type="bool" value="false"/>
</node>
The important fields here is the serial_name that is used to select the port which the UART of the drone is connected to the computer. The app_id and enc_key fields are required to run and talk with the M100. These are found by creating a DJI Developer account and then creating a new "App" there. Once set they can be used indefinitely.
DJI has descriptions of the basic workings of the SDK on their websites and besides this understanding the workings is pretty straight forward from the code and looking through the package.
For basic use reading topics is standard. To control the drone, control signals are published on the /dji_sdk/fligth_control_setpoint_... topics depending on the control values (roll, pitch, x-vel, yaw-rate, thrust, z-vel, x-pos, etc.). For a list of the available topics look at dji_sdk/src/modules/dji_sdk_node.cpp. If you wish to add other combinations the topic is set up there and the code should be added to dji_sdk/src/modules/dji_sdk_control.cpp.
In case of poor GPS coverage and no Guidance module many of the control values are unusable and only roll, pitch, yawrate and z-vel is usable. You can change between 2 different topics instantaneously e.g. from GPS to roll/pitch when touching, but it has not been tested what happens if you publish on 2 flight control values simultaneously.
For the drone to react to the commands the computer must first get control authority. This is done through a DJI ROS service. Calling this can obtain or release control authority. For this to succeed the drone must be in F-mode.
A service for starting propellers is also available. To turn of the propellers from the computer use the DJI land function or continue sending z-vel commands downwards even after the drone touches the ground until the propellers turn off.