NOTE This article is Machine-Translated. If you have any questions about this article, please send an E-mail to DJI, we will correct it in time. DJI appreciates your support and attention.
After registering the account, please download the sample and supplement the application information, after compiling, debugging and burning, the developer could run the application, With the help of those samples, the developer would know how to develop the application.
NOTE DJI's sample are developed on Manifold 2 and STM3241G-EVAL using Linux and FreeRTOS. If you need to port the sample code to other operating systems or hardware platforms, please refer to Porting.
After registered as a developer, you can download the sample code provided by DJI. With the help of sample code, you can learn how to use OSDK and developed the application quickly.
After obtaining the sample code, please create an application in User Center and obtain the application ID and application key, as shown in Figure 1.
Figure 1. Fill in the application information
NOTE To improve your development efficiency, please fill in application name, ID, Key and user account in the sample code correctly, otherwise the compiled sample program Will not function properly.
It is recommended to use Ubuntu 16.04 and Manifold 2 to running the Linux sample code.
NOTE The Linux sample code uses Manifold 2-C and also could run on Manifold 2-G.
Fill the onboard-sdk/sample/platform/linux/common/UserConfig.txt
:
app_id: //Developer ID |
NOTE Developer need to configure
acm_port
when using OSDK 4.0, here default is/dev/ttyACM0
.
Before compiling the sample code, please use the ls -l/dev/xxx
command on the terminal to check the access rights of the serial port (UART) of the hardware platform. Otherwise, you can use the command sudo chmod 777 /dev/xxx
obtain the access permissions of the hardware.
NOTE xxx is the name of the serial port.
Enter the directory of the sample code: onboard-sdk
, and use the following command to compile the sample code into a sample program:
mkdir build && cd build
;cmake ..
orcmake .. -DADVANCED_SENSING=ON
(use visual function);make
;Copy the configuration file UserConfig.txt
to the bin file:
cp ../sample/platform/linux/common/UserConfig.txt bin/
The following is execute the "Flight Control":
./djiosdk-flightcontrol-sample UserConfig.txt UserConfig.txt
Enter B from the keyboard to run the sample program
Figure 2. Run The Sample(Linux)
mkdir catkin_ws |
After using the above command to create a workspace, please copy the OSDK sample code in the src
directory.
1. In the catkin_ws
directory, use thecatkin_make
command to compile the OSDK sample code.
2. Configure the current workspace source devel/setup.bash
Edit the configuration file XXXX.launch
and replace the ID, Key, and baud rate of the application.
$ rosed dji_osdk_ros dji_vehicle_node.launch
$ rosed dji_osdk_ros dji_sdk_node.launch
NOTE
- OSDK ROS 4.0 node configuration file path is
/path/to/catkin_ws/src/Onboard-SDK-ROS/launch/dji_vehicle_node.launch
- OSDK ROS 3.8 node configuration file path is
/path/to/catkin_ws/src/Onboard-SDK-ROS/launch/dji_sdk_node.launch
If you use the dji_sdk_node version 3.8.0, you need to place the UserConfig.txt
which in the OSDK package to the specified path:
- If you use the command
rosrun
, theUserConfig.txt
file needs to be placed to the current running directory;- If you use the command
roslaunch
, theUserConfig.txt
file needs to be placed to the/home/{user}/. Ros
.
roslaunch dji_osdk_ros dji_vehicle_node.launch
roslaunch dji_osdk_ros dji_sdk_node.launch
catkin_ws
directory, and use the following command to configure the workspace (take the Flight Control as an example)$ source devel/setup.bash |
NOTE To use advanced vision features, please run the advanced_sensing_node example program.
NOTE The RTOS‘s sample code uses STM32F407IGH6-EVAL to develop the application.
Use Keil to open the project file OnBoardSDK_STM32.uvprojx
located in thesample/platform/STM32/OnBoardSDK_STM32/Project/
.
Replace the ID and key of the application in the OnboardSDK_STM32/User/Activate.cpp
:
void |
OnBoardSDK_STM32.uvprojx
located in thesample/STM32/OnBoardSDK_STM32/Project/
directory.-DXXXX_XXXXX_XXXXX
.Figure 3. Run The Sample(STM32)
Project
tab, selectBuild Target
NOTE If you need to debug the sample program, please set the baud rate of the serial debugging tool. The default baud rate of USART3 port is 921600; the default baud rate of USART2 port is 115200.
When executing the application which develope based on OSDK on the first time, developer need log in the DJI Assistant 2 with developer’s account and obtain the authorization license from DJI's server to activate the application.