飞行机器人DJI平台OSDK ROS 编译及使用

Posted Techblog of HaoWANG

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了飞行机器人DJI平台OSDK ROS 编译及使用相关的知识,希望对你有一定的参考价值。

 系列文章目录

第一章 飞行机器人(一)DJI平台OSDK简介飞行机器人(一)DJI平台OSDK简介_Techblog of HaoWANG-CSDN博客DJI OSDK/OSDK-ROS for M600Pro技术文档 Version 2.1.1https://haowang.blog.csdn.net/article/details/122336345

第二章 飞行机器人(二)DJI平台软硬件连接

飞行机器人(二)DJI平台软硬件连接_Techblog of HaoWANG-CSDN博客系列文章目录第一章飞行机器人(一)DJI平台OSDK简介飞行机器人(一)DJI平台OSDK简介_Techblog of HaoWANG-CSDN博客DJI OSDK/OSDK-ROS for M600Pro技术文档 Version 2.1.1https://haowang.blog.csdn.net/article/details/122336345目录系列文章目录1. 机载设备USB2TTL串口接线方法2. OSDK 源码编译3. catkin_make编译osdk_ros3.https://haowang.blog.csdn.net/article/details/122336645

目录

 系列文章目录

1. 源码编译

2. Configuration配置文件

3. 测试dji_ros_osdk

4. 调参软件配置

5. DJI飞行仿真


1. 源码编译

https://github.com/dji-sdk/Onboard-SDK-ROShttps://github.com/dji-sdk/Onboard-SDK-ROS

注意:在4.1.0版本的osdk_ros中,仍然支持3.8.1版本的M100、M600、A3\\N3飞控,但是需要运行dji_sdk_node用于发布传感器数据,使用新版本的功能demo处理相应数据,完成功能任务。

2. Configuration配置文件

You will need to add an udev file to allow your system to obtain permission and to identify DJI USB port.

>$cd /etc/udev/rules.d/  

>$sudo vi DJIDevice.rules


Then add these content into DJIDevice.rules.

>SUBSYSTEM=="usb", ATTRSidVendor=="2ca3", MODE="0666"



Remember to add UserConfig.txt to correct path.(in the current work directory)  

>If you want to run dji_sdk_node.launch, you need to put UserConfig.txt into /home/user/.ros.

>dji_vehicle_node.launch does not need UserConfig.txt.

3. 测试dji_ros_osdk

USB2TTL端口权限

注意:节点无法启动时请检查是否USB2TTL线序接反,或者调参软件已经调整至API智能控制模式等。

4. 调参软件配置

20211231固件版本信息

飞控参数信息

DJI_OSDK_ROS 常用Topic

5. DJI飞行仿真

在配置好飞控参数后,上位机NX运行OSDK ROS示例程序,在地面站DJI Assistant软件中打开模拟器,设置模拟器参数并开始仿真试验。

大疆开发 DJI.SDK - 知乎

  1. 云台姿态读取
  • topic名称:/dji_osdk_ros/gimbal_angle
  • 类型:geometry_msgs/Vector3Stamped
  • 内容:
    • msg.vector.x # pitch,单位:度
      msg.vector.y # roll
      msg.vector.z # yaw
  1. 飞行状态读取
  • topic名称:/dji_osdk_ros/flight_status
  • 变量类型:std_msgs/Uint8
  • 内容:
    • data # 0,在地面上;1,电机解锁;2,在空中
  1. RTK经纬度读取
  • topic名称:/dji_osdk_ros/rtk_position
  • 变量类型:sensor_msgs/NavSatFix
  • 频率:有RTK信息时,10Hz;无RTK信息时,全为0
  • 内容:
    • float64 latitude
      float64 longitude
      float64 altitude // 海拔
      float64[9] position_covariance // 方差
      uint8 position_covariance_type
  1. RTK速度读取
  • topic名称:/dji_osdk_ros/rtk_velocity
  • 变量类型:geometry_msgs/Vector3Stamped
  • 频率:10Hz
  • 内容:
    • # 东北天全局坐标系
      msg.vector.x
      msg.vector.y
      msg.vector.z
  1. RTK偏航
  • topic名称:/dji_osdk_ros/rtk_yaw
  • 变量类型:std_msgs/Int16
  • 内容:
    • msg.data # 单位:度
  1. 超声波高度
  • topic名称:/dji_osdk_ros/height_above_takeoff
  • 变量类型:std_msgs/Float32
  • 要点:高于10米就超过测量范围,此值会变为0,10米以内的精度还算准确
  1. GPS位置
  • topic名称:/dji_osdk_ros/gps_position
  • 变量类型:sensor_msgs/NavSatFix
  • 要点:其中海拔的测量误差非常大,不建议使用此海拔数据;融合数据的高度会受到影响:湿度、温度、水平移动距离等
  1. 相机视频流
  • topic名称:dji_osdk_ros/main_camera_images
  • 类型:sensor_msgs/Image
  • 要点1:需要用cvbridge来做图像类型的转换
  • 要点2:经测试,图像传输时延在2秒钟左右,建议使用Ros image transport,可将时延控制在0.5秒左右
  1. 磁力计位置
  • topic名称:/dji_osdk_ros/vo_position
  • 内容:由磁力计得到的位置,非常不准,不建议使用

  1. ROS logging info

roslaunch dji_sdk sdk.launch

... logging to /home/jetson/.ros/log/2a1e0ccc-6e05-11ec-9edf-48b02d3d7aa2/roslaunch-jetson-30162.log

Checking log directory for disk usage. This may take a while.

Press Ctrl-C to interrupt

Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://jetson.local:46117/

SUMMARY

========

PARAMETERS

 * /dji_sdk/align_time: False

 * /dji_sdk/app_id: 1112891

 * /dji_sdk/app_version: 1

 * /dji_sdk/baud_rate: 921600

 * /dji_sdk/enc_key: 69c6a84c0181505e1...

 * /dji_sdk/serial_name: /dev/ttyUSB1

 * /dji_sdk/use_broadcast: False

 * /rosdistro: melodic

 * /rosversion: 1.14.11

NODES

  /

    dji_sdk (dji_sdk/dji_sdk_node)

auto-starting new master

process[master]: started with pid [30585]

ROS_MASTER_URI=http://jetson.local:11311

setting /run_id to 2a1e0ccc-6e05-11ec-9edf-48b02d3d7aa2

process[rosout-1]: started with pid [30759]

started core service [/rosout]

process[dji_sdk-2]: started with pid [30784]

STATUS/1 @ init, L55: Attempting to open device /dev/ttyUSB1 with baudrate 921600...

STATUS/1 @ init, L65: ...Serial started successfully.

STATUS/1 @ parseDroneVersionInfo, L727: Device Serial No. = 0670167166

STATUS/1 @ parseDroneVersionInfo, L729: Hardware = PM820V3PRO

STATUS/1 @ parseDroneVersionInfo, L730: Firmware = 3.2.41.14

ERRORLOG/1 @ initVirtualRC, L1103: Virtual RC is not supported on this platform!

STATUS/1 @ activate, L1313: version 0x302290E

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] [1641372910.257464776]: drone activated

[ INFO] [1641372910.525424040]: Use data subscription to get telemetry data!

[ INFO] [1641372910.525575400]: 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=10.

[ INFO] [1641372910.621151240]: -----With DJI M600 Pro D-RTK STATE CHECK DEBUG----

[ INFO] [1641372910.621337000]: ------RTK STATE CHECK DEBUG----

[ INFO] [1641372910.621647656]: -----Flight Controller does not support RTK

STATUS/1 @ startPackage, L350: Start package 0 result: 0.

STATUS/1 @ startPackage, L352: Package 0 info: freq=5, nTopics=6.

STATUS/1 @ startPackage, L350: Start package 3 result: 0.

STATUS/1 @ startPackage, L352: Package 3 info: freq=400, nTopics=1.

  1. OSDK logging info

/djiosdk-telemetry-sample UserConfig.txt

Read App ID

User Configuration read successfully.

STATUS/1 @ init, L55: Attempting to open device /dev/ttyUSB1 with baudrate 921600...

STATUS/1 @ init, L65: ...Serial started successfully.

STATUS/1 @ parseDroneVersionInfo, L727: Device Serial No. = 0670167166

STATUS/1 @ parseDroneVersionInfo, L729: Hardware = PM820V3PRO

STATUS/1 @ parseDroneVersionInfo, L730: Firmware = 3.2.41.14

STATUS/1 @ removePackage, L468:

ERRORLOG/1 @ removeLeftOverPackages, L499: failed to remove package 0

STATUS/1 @ removePackage, L468: Remove package 1 successful.

ERRORLOG/1 @ removeLeftOverPackages, L499: failed to remove package 1

STATUS/1 @ removePackage, L468: Remove package 2 successful.

ERRORLOG/1 @ removeLeftOverPackages, L499: failed to remove package 2

STATUS/1 @ removePackage, L468: Remove package 3 successful.

ERRORLOG/1 @ removeLeftOverPackages, L499: failed to remove package 3

STATUS/1 @ removePackage, L468: Remove package 4 successful.

ERRORLOG/1 @ removeLeftOverPackages, L499: failed to remove package 4

ERRORLOG/1 @ initVirtualRC, L1103: Virtual RC is not supported on this platform!

STATUS/1 @ activate, L1313: version 0x302290E

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!

| Available commands:                                            |

| [a] Get telemetry data and print                               |

| [b] Select some subscription topics to print                   |

| [c] Get telemetry data and save to file                        |

a

STATUS/1 @ verify, L244: Verify subscription successful.

STATUS/1 @ startPackage, L350: Start package 0 result: 0.

STATUS/1 @ startPackage, L352: Package 0 info: freq=1, nTopics=1.

STATUS/1 @ startPackage, L350: Start package 1 result: 0.

STATUS/1 @ startPackage, L352: Package 1 info: freq=10, nTopics=2.

STATUS/1 @ startPackage, L350: Start package 2 result: 0.

STATUS/1 @ startPackage, L352: Package 2 info: freq=50, nTopics=2.

STATUS/1 @ startPackage, L350: Start package 3 result: 0.

STATUS/1 @ startPackage, L352: Package 3 info: freq=200, nTopics=1.

STATUS/1 @ startPackage, L350: Start package 4 result: 0.

STATUS/1 @ startPackage, L352: Package 4 info: freq=5, nTopics=5.

Counter = 0:

-------

Flight Status                         = 0

Position              (LLA)           = 0.401793, 1.97631, -35.3228

RC Commands           (r/p/y/thr)     = 0, 0, 0, 0

Velocity              (vx,vy,vz)      = 3.49576e-05, -0.000171653, -0.000144877

Attitude Quaternion   (w,x,y,z)       = 0.407821, -0.0157919, 0.00243199, 0.912922

RTK if available   (lat/long/alt/velocity_x/velocity_y/velocity_z/yaw/yaw_info/pos_info) =23.0211,113.234,23.5765,1.19665,-0.785867,-3.88101,23,"2

-------

Counter = 5:

-------

Flight Status                         = 0

Position              (LLA)           = 0.401793, 1.97631, -35.3228

RC Commands           (r/p/y/thr)     = 0, 0, 0, 0

Velocity              (vx,vy,vz)      = 3.49576e-05, -0.000171653, -0.000144877

Attitude Quaternion   (w,x,y,z)       = 0.407821, -0.0157919, 0.00243199, 0.912922

RTK if available   (lat/long/alt/velocity_x/velocity_y/velocity_z/yaw/yaw_info/pos_info) =23.0211,113.234,23.5765,1.19665,-0.785867,-3.88101,23,"2

-------

Counter = 10:

-------

Flight Status                         = 0

Position              (LLA)           = 0.401793, 1.97631, -35.3228

RC Commands           (r/p/y/thr)     = 0, 0, 0, 0

Velocity              (vx,vy,vz)      = 7.44809e-05, -0.000332033, -0.000386053

Attitude Quaternion   (w,x,y,z)       = 0.407821, -0.0157947, 0.00244076, 0.912922

RTK if available   (lat/long/alt/velocity_x/velocity_y/velocity_z/yaw/yaw_info/pos_info) =23.0211,113.234,23.5737,-0.0331256,0.333299,0.640153,22,"2

-------

Counter = 15:

-------

Flight Status                         = 0

Position              (LLA)           = 0.401793, 1.97631, -35.3228

RC Commands           (r/p/y/thr)     = 0, 0, 0, 0

Velocity              (vx,vy,vz)      = 7.44809e-05, -0.000332033, -0.000386053

Attitude Quaternion   (w,x,y,z)       = 0.407821, -0.0157947, 0.00244076, 0.912922

RTK if available   (lat/long/alt/velocity_x/velocity_y/velocity_z/yaw/yaw_info/pos_info) =23.0211,113.234,23.5737,-0.0331256,0.333299,0.640153,22,"2

-------

Counter = 20:

-------

Flight Status                         = 0

Position              (LLA)           = 0.401793, 1.97631, -35.3228

RC Commands           (r/p/y/thr)     = 0, 0, 0, 0

Velocity              (vx,vy,vz)      = 7.44809e-05, -0.000332033, -0.000386053

Attitude Quaternion   (w,x,y,z)       = 0.407821, -0.0157947, 0.00244076, 0.912922

RTK if available   (lat/long/alt/velocity_x/velocity_y/velocity_z/yaw/yaw_info/pos_info) =23.0211,113.234,23.5737,-0.0331256,0.333299,0.640153,22,"2

-------

Counter = 25:

-------

Flight Status                         = 0

Position              (LLA)           = 0.401793, 1.97631, -35.3228

RC Commands           (r/p/y/thr)     = 0, 0, 0, 0

Velocity              (vx,vy,vz)      = 7.44809e-05, -0.000332033, -0.000386053

Attitude Quaternion   (w,x,y,z)       = 0.407821, -0.0157947, 0.00244076, 0.912922

RTK if available   (lat/long/alt/velocity_x/velocity_y/velocity_z/yaw/yaw_info/pos_info) =23.0211,113.234,23.5737,-0.0331256,0.333299,0.640153,22,"2

-------

以上是关于飞行机器人DJI平台OSDK ROS 编译及使用的主要内容,如果未能解决你的问题,请参考以下文章

飞行机器人DJI平台OSDK ROS 编译及使用

飞行机器人DJI平台OSDK简介

飞行机器人DJI平台OSDK简介

飞行机器人DJI平台OSDK简介

飞行机器人DJI OSDK Mission Plan 和 航迹规划

飞行机器人DJI OSDK Mission Plan 和 航迹规划