平台: UBUNTU16.04
ROS kinetic
DJI ASSISTANT 2
OSDK3.3.1
Onboard SDK ROS 3.3.1
DJI N3飞控(型号:3.2.36.8 固件:1.7.1.5)
DJI LightBridge II
一、OSDK安装
参考:http://developer.dji.com/onboard-sdk/documentation/sample-doc/sample-setup.html#ros-oes
Installing the OSDK
1-Clone (or download as zip) the DJI OSDK from Github here.
https://github.com/dji-sdk/Onboard-SDK/releases
2-Open a terminal inside the onboardsdk folder and follow these steps to build the core OSDK library:
mkdir build
cd build
cmake ..
make djiosdk-core
3-Now, install the osdk-core library to your system so that the dji_sdk ROS node may find it and link against it:
sudo make install djiosdk-core
Building the ROS Nodes
4-If you don’t have a catkin workspace, create one as follows:
mkdir catkin_ws
cd catkin_ws
mkdir src
cd src
catkin_init_workspace
5-Clone (or download as zip) the DJI OSDK-ROS from Github here in the src folder.
https://github.com/dji-sdk/Onboard-SDK-ROS/releases
6-Build the dji_sdk ROS package and the dji_sdk_demo ROS package.
cd ..
catkin_make
Configuration
7-Remember to source your setup.bash:
source devel/setup.bash
8-Edit the launch file and enter your App ID, Key, Baudrate and Port name in the designated places:
rosed dji_sdk sdk.launch
Running the Samples
9-Start up the dji_sdk ROS node:
roslaunch dji_sdk sdk.launch
10-Open up another terminal and cd to your catkin_ws location, and start up a sample (e.g. flight control sample):
source devel/setup.bash
rosrun dji_sdk_demo demo_flight_control
11-Follow the prompt on screen to choose an action for the drone to do.
二、注意事项
1- rosed dji_sdk sdk.launch配置文件;
"dji_sdk" type="dji_sdk_node" name="dji_sdk" output="screen">
"serial_name" type="string" value="/dev/ttyUSB1"/>
"baud_rate" type="int" value="230400"/>
"app_id" type="int" value="×××××××"/>
"app_version" type="int" value="1"/>
"align_time" type="bool" value="false"/>
"enc_key" type="string" value="a2870084××××××26726e5413×××××××2099fd652××××××fac53581c1c392"/>
"use_broadcast" type="bool" value="false"/>
其中:
"serial_name" type="string" value="/dev/ttyUSB1"/>
USB端口号可通过命令:
ls -l /dev | grep ttyUSB
查看。
2- DJI ASSISITANT2 中SDK项设置波特率与配置文件一致(实际均为230400),勾选“使能API”;
DJI ASSISITANT2 中重新设置波特率后需要断电再上电重启一次N3控制器。
3- 使用命令
sudo chmod 666 /dev/ttyUSB0
获取端口权限(USB端口号依据命令 ls -l /dev | grep ttyUSB查看)
4-使用命令 roslaunch dji_sdk sdk.launch 之前,DJI ASSISITANT 2 需连接N3,同时DJI LightBridge II 模式开关需拨到F档。连接成功后终端界面显示如下:
wang@wang:~/catkin_ws$ roslaunch dji_sdk sdk.launch
...logging to /home/wang/.ros/log/9834××××××××b-11××××××-701c××××××b6/roslaunch-wang-7623.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.
started roslaunch server http://wang:41730/
SUMMARY
PARAMETERS
* /dji_sdk/align_time: False
* /dji_sdk/app_id: 1×××××0
* /dji_sdk/app_version: 1
* /dji_sdk/baud_rate: 230400
* /dji_sdk/enc_key: a287××××××××××ec8626...
* /dji_sdk/serial_name: /dev/ttyUSB1
* /dji_sdk/use_broadcast: False
* /rosdistro: kinetic
* /rosversion: 1.12.7
NODES
/ dji_sdk (dji_sdk/dji_sdk_node)
ROS_MASTER_URI=http://localhost:11311
core service [/rosout] found
process[dji_sdk-1]: started with pid [7641]
STATUS/1 @ init, L37: Attempting to open device /dev/ttyUSB1 with baudrate 230400...
STATUS/1 @ init, L47: ...Serial started successfully.
[ INFO] [1502851643.785412888]: Succeeded to read from serial device
STATUS/1 @ init, L37: Attempting to open device /dev/ttyUSB1 with baudrate 230400...
STATUS/1 @ init, L47: ...Serial started successfully.
STATUS/1 @ parseDroneVersionInfo, L568: Device Serial No. = 0DBDE4T0020006
STATUS/1 @ parseDroneVersionInfo, L570: Hardware = N3
STATUS/1 @ parseDroneVersionInfo, L571: Firmware = 3.2.36.8
ERROR/1 @ initGimbal, L677: Failed to verify subscription!
ERROR/1 @ functionalSetUp, L157: Failed to initialize Gimbal!
ERROR/1 @ functionalSetUp, L187: Virtual RC not supported!
STATUS/1 @ getErrorCodeMessage, L590: removePackage
STATUS/1 @ getCMDSetSubscribeMSG, L672: SUBSCRIBER_ILLEGAL_INPUT
STATUS/1 @ getErrorCodeMessage, L590: removePackage
STATUS/1 @ getCMDSetSubscribeMSG, L672: SUBSCRIBER_ILLEGAL_INPUT
STATUS/1 @ getErrorCodeMessage, L590: removePackage
STATUS/1 @ getCMDSetSubscribeMSG, L672: SUBSCRIBER_ILLEGAL_INPUT
STATUS/1 @ getErrorCodeMessage, L590: removePackage
STATUS/1 @ getCMDSetSubscribeMSG, L672: SUBSCRIBER_ILLEGAL_INPUT
STATUS/1 @ getErrorCodeMessage, L590: removePackage
STATUS/1 @ getCMDSetSubscribeMSG, L672: SUBSCRIBER_ILLEGAL_INPUT
STATUS/1 @ activate, L951: version 0x3022408
STATUS/1 @ activate, L964: Activation successful
[ INFO] [1502851645.001466961]: drone activated
[ INFO] [1502851645.022345163]: Use data subscription to get telemetry data!
[ INFO] [1502851645.022363712]: align_time_with_FC set to false. We will use ros time to time stamp messages!
STATUS/1 @ startPackage, L314: Start package 2 result: 0.
STATUS/1 @ startPackage, L316: Package 2 info: freq=100, nTopics=3.
STATUS/1 @ startPackage, L314: Start package 1 result: 0.
STATUS/1 @ startPackage, L316: Package 1 info: freq=50, nTopics=9.
STATUS/1 @ startPackage, L314: Start package 0 result: 0.
STATUS/1 @ startPackage, L316: Package 0 info: freq=10, nTopics=6.
STATUS/1 @ startPackage, L314: Start package 3 result: 0.
5- ROS 节点启动成功后断开DJI ASSISITANT 2,然后新开终端并运行
source devel/setup.bash
rosrun dji_sdk_demo demo_flight_control
飞机运行,终端界面显示:
wang@wang:~/catkin_ws$ rosrun dji_sdk_demo demo_flight_control
[ INFO] [1502852234.628554866]: A3/N3 taking off!
[ INFO] [1502852234.784108884]: Motor Spinning ...