DJI 无人机 Onboard SDK ROS 功能包demo运行
- demo功能
- 准备测试环境
- 运行 dji sdk 节点
- 运行 demo 节点
- 自动飞行任务
- 航点自动飞行
- 兴趣点环绕自动飞行
- 飞行控制
- 本地坐标位置控制
搭建好 Onboard SDK ROS 的开发环境后,功能包自身具备一些写好的demo功能案例
dji sdk 的节点在dji_sdk文件夹中
demo的功能案例则在dji_sdk_demo文件夹中
demo功能
具体的demo功能可以查看文件夹内的CMakeLists.txt文件
通过名称可以看出其功能,总结如下:
demo_mission 自动飞行任务
add_executable(demo_mission
src/demo_mission.cpp)
demo_camera_gimbal 相机云台控制
add_executable(demo_camera_gimbal
src/demo_camera_gimbal.cpp )
demo_mfio 多功能IO控制
add_executable(demo_mfio
src/demo_mfio.cpp)
demo_flight_control 飞行控制
add_executable(demo_flight_control
src/demo_flight_control.cpp)
demo_mobile_comm msdk通信
add_executable(demo_mobile_comm
src/demo_mobile_comm.cpp)
demo_payload_comm psdk通信
add_executable(demo_payload_comm
src/demo_payload_comm.cpp)
demo_local_position_control 本地坐标位置控制
add_executable(demo_local_position_control
src/demo_local_position_control.cpp)
demo_time_sync 时间硬件同步功能
add_executable(demo_time_sync
src/demo_time_sync.cpp)
demo_stereo_depth_perception 深度相机感知
add_executable(demo_stereo_depth_perception
src/demo_stereo_depth_perception.cpp
${STEREO_UTILITY_SRC_FILE} )
demo_stereo_object_depth_perception 深度相机目标感知
add_executable(demo_stereo_object_depth_perception
src/demo_stereo_object_depth_perception.cpp
${STEREO_UTILITY_SRC_FILE} )
在模拟器环境下,可以测试
- 自动飞行任务
- 飞行控制
- 本地坐标位置控制
准备测试环境
连接A3飞控usb口至电脑,打开 DJI Assistan2
开启模拟器
运行 dji sdk 节点
roslaunch dji_sdk sdk.launch
终端输出如下:
节点运行信息
NODES
/
dji_sdk (dji_sdk/dji_sdk_node)
auto-starting new master
process[master]: started with pid [5812]
ROS_MASTER_URI=http://localhost:11311
setting /run_id to 93cf1500-a697-11ed-bf42-df9474278202
process[rosout-1]: started with pid [5822]
started core service [/rosout]
process[dji_sdk-2]: started with pid [5825]
开启串口
STATUS/1 @ init, L55: Attempting to open device /dev/ttyUSB0 with baudrate 921600…
STATUS/1 @ init, L65: …Serial started successfully.
读取无人机设备信息
STATUS/1 @ parseDroneVersionInfo, L727: Device Serial No. = 0670169082
STATUS/1 @ parseDroneVersionInfo, L729: Hardware = A3
STATUS/1 @ parseDroneVersionInfo, L730: Firmware = 3.3.8.47
ERRORLOG/1 @ initVirtualRC, L1103: Virtual RC is not supported on this platform!
激活信息
STATUS/1 @ activate, L1313: version 0x303082F
STATUS/1 @ activate, L1326: Activation successful
检查订阅功能
STATUS/1 @ verify, L244: Verify subscription successful.
STATUS/1 @ initGimbal, L890: Checking if gimbal is connected …
STATUS/1 @ startPackage, L350: Start package 0 result: 0.
STATUS/1 @ startPackage, L352: Package 0 info: freq=50, nTopics=1.
STATUS/1 @ removePackage, L468: Remove package 0 successful.
STATUS/1 @ initGimbal, L934: Gimbal not mounted!
[ INFO] [1675740553.755751972]: drone activated
[ INFO] [1675740553.778064095]: Use data subscription to get telemetry data!
[ INFO] [1675740553.778079475]: align_time_with_FC set to false. We will use ros time to time stamp messages!
STATUS/1 @ verify, L244: Verify subscription successful.
订阅不同数据
STATUS/1 @ startPackage, L350: Start package 2 result: 0.
STATUS/1 @ startPackage, L352: Package 2 info: freq=100, nTopics=3.
STATUS/1 @ startPackage, L350: Start package 1 result: 0.
STATUS/1 @ startPackage, L352: Package 1 info: freq=50, nTopics=14.
STATUS/1 @ startPackage, L350: Start package 0 result: 0.
STATUS/1 @ startPackage, L352: Package 0 info: freq=5, nTopics=1.
STATUS/1 @ removePackage, L468: Remove package 0 successful.
STATUS/1 @ startPackage, L350: Start package 0 result: 0.
STATUS/1 @ startPackage, L352: Package 0 info: freq=5, nTopics=12.
STATUS/1 @ startPackage, L350: Start package 3 result: 0.
STATUS/1 @ startPackage, L352: Package 3 info: freq=400, nTopics=1.
运行 demo 节点
自动飞行任务
rosrun dji_sdk_demo demo_mission
直接运行终端出现如下, 激活成功并且成功获得SDK的控制权
需要输入命令,选择运行的任务,有效命令为a和b,
- a 为 航点任务,无人机会生成几个航点,然后完成自动飞行,结束后在最后一个航点处悬停
- b 为 兴趣点任务,无人机生成一个兴趣点,然后绕该点环绕飞行
[ INFO] [1675740815.554077620]: Activated successfully
[ INFO] [1675740815.566534458]: Obtain SDK control Authority successfully
| Available commands: |
| [a] Waypoint Mission |
| [b] Hotpoint Mission |
航点自动飞行
选择a后
会根据当前位置生成8个航点
a
[ INFO] [1675740828.523351999]: Creating Waypoints…
[ INFO] [1675740828.523385537]: Waypoint created at (LLA): 22.542813 113.958902 10.000000
[ INFO] [1675740828.523424518]: Uploading Waypoints…
[ INFO] [1675740828.523438455]: Waypoint created at (LLA): 22.542813 113.958902 10.000000
[ INFO] [1675740828.523454862]: Waypoint created at (LLA): 22.542842 113.958952 11.000000
[ INFO] [1675740828.523479041]: Waypoint created at (LLA): 22.542813 113.959001 12.000000
[ INFO] [1675740828.523494546]: Waypoint created at (LLA): 22.542756 113.959001 13.000000
[ INFO] [1675740828.523507912]: Waypoint created at (LLA): 22.542727 113.958952 14.000000
[ INFO] [1675740828.523520406]: Waypoint created at (LLA): 22.542756 113.958902 15.000000
[ INFO] [1675740828.523533197]: Waypoint created at (LLA): 22.542813 113.958902 10.000000
完成初始化航点任务
[ INFO] [1675740828.523546607]: Initializing Waypoint Mission…
航点上传成功
[ INFO] [1675740836.561940059]: Waypoint upload command sent successfully
开始自动航点飞行指令发送成功
[ INFO] [1675740836.566911899]: Mission start command sent successfully
模拟器上,无人机会自动解锁,然后起飞,并且完成设定航点的飞行任务,最终在最后一个航点悬停
兴趣点环绕自动飞行
选择b后,会执行兴趣点环绕自动飞行任务
b
自动起飞,无人机自动解锁,然后飞至1.2m
[ INFO] [1675742099.443036182]: Takeoff command sent successfully
无人机先升至环绕高度,以默认环绕角速度15deg/s 进行位置绕飞,绕飞5s
[ INFO] [1675742114.443178988]: Start with default rotation rate: 15 deg/s
[ INFO] [1675742114.448505426]: Mission start command sent successfully
[ INFO] [1675742139.448688192]: Pause for 5s
任务暂停与继续
[ INFO] [1675742139.451349922]: Mission pause command sent successfully
[ INFO] [1675742144.451458193]: Resume
[ INFO] [1675742144.456389352]: Mission resume command sent successfully
更新绕飞半径
[ INFO] [1675742154.456525822]: Update radius to 1.5x: new radius = 15.000000
[ INFO] [1675742164.457708017]: Hotpoint update radius command sent successfully
更新绕飞速度
[ INFO] [1675742174.457859734]: Update hotpoint rotation rate: new rate = 5 deg/s
[ INFO] [1675742184.459081801]: Hotpoint update yaw rate command sent successfully
绕飞停止
[ INFO] [1675742194.459170476]: Stop
[ INFO] [1675742194.462806962]: Mission stop command sent successfully
降落
[ INFO] [1675742194.462819562]: land
[ INFO] [1675742194.467372616]: Land command sent successfully
飞行控制
rosrun dji_sdk_demo demo_flight_control
无人机自动起飞,然后飞一个矩形
[ INFO] [1675743016.199742227]: A3/N3 taking off!
[ INFO] [1675743016.415844652]: Motor Spinning …
[ INFO] [1675743020.636488163]: Ascending…
[ INFO] [1675743022.278058330]: Successful takeoff!
飞行路线1, 仅截取开头一段
[ INFO] [1675743022.278089899]: ##### Start route 1 …
[ INFO] [1675743023.130819687]: -----x=-0.012091, y=0.096899, z=0.262428, yaw=1.040941 …
[ INFO] [1675743023.130845799]: +++++dx=0.012091, dy=19.903101, dz=2.737572, dyaw=-0.006256 …
[ INFO] [1675743023.950986554]: -----x=-0.034531, y=0.727045, z=0.875107, yaw=1.055536 …
[ INFO] [1675743023.951012451]: +++++dx=0.034531, dy=19.272955, dz=2.124893, dyaw=0.008338 …
[ INFO] [1675743024.770909261]: -----x=-0.017862, y=1.465063, z=1.378654, yaw=1.043764 …
[ INFO] [1675743024.770938054]: +++++dx=0.017862, dy=18.534937, dz=1.621346, dyaw=-0.003434 …
[ INFO] [1675743025.590800226]: -----x=-0.000521, y=2.222384, z=1.749954, yaw=1.045671 …
路线1,开始刹车
[ INFO] [1675743050.370302330]: ##### Route 1 start break…
[ INFO] [1675743050.570487046]: -----x=0.000151, y=19.593961, z=2.999557, yaw=1.047178 …
[ INFO] [1675743050.570512280]: +++++dx=-0.000151, dy=0.406039, dz=0.000443, dyaw=-0.000020 …
[ INFO] [1675743051.390515574]: -----x=0.000191, y=19.561036, z=2.999557, yaw=1.047188 …
[ INFO] [1675743051.390541700]: +++++dx=-0.000191, dy=0.438964, dz=0.000443, dyaw=-0.000009 …
路线1,结束
[ INFO] [1675743051.930245287]: ##### Route 1 finished…
后面重复路线2、路线3、路线4的打印信息
本地坐标位置控制
起飞,完成两个目标点的飞行
[ INFO] [1675743826.255594594]: A3/N3 taking off!
[ INFO] [1675743826.512051941]: Motor Spinning …
[ INFO] [1675743830.693925672]: Ascending…
[ INFO] [1675743832.325256741]: Successful takeoff!
[ INFO] [1675743858.244149614]: 1 of 2 target(s) complete
[ INFO] [1675743885.684112340]: 2 of 2 target(s) complete