【DJI OSDK ROS 中添加一个obstacle_info 话题发布DJI M300 RTK的六向视觉避障信息。】

本文介绍了如何在DJIOSDKROS环境中,通过创建一个节点订阅obstacle_info话题,获取并处理DJIM300RTK的六向(前后左右上下)视觉避障数据,频率为100Hz。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

DJI OSDK ROS 中添加一个obstacle_info 话题发布DJI M300 RTK的六向视觉避障信息。

// INCLUDE

#include <dji_osdk_ros/ObstacleInfo.h>

#include <ros/ros.h>
#include <dji_osdk_ros/dji_vehicle_node.h>
#include <dji_osdk_ros/vehicle_wrapper.h>

void obstacleDisCallback(const dji_osdk_ros::ObstacleInfo::ConstPtr& avoidData)
{
	if (avoidData->down_health == 1)
	{
		ROS_INFO("Current down distance is :%d m", avoidData->down);
	}
	
	if (avoidData->front_health == 1)
	{
		ROS_INFO("Current front distance is :%d m", avoidData->front);
	}

	if (avoidData->right_health == 1)
	{
		ROS_INFO("Current right distance is :%d m", avoidData->right);
	}

	if (avoidData->left_health == 1)
	{
		ROS_INFO("Current left distance is :%d m", avoidData->left);
	}

	if (avoidData->up_health == 1)
	{
		ROS_INFO("Current up distance is :%d m", avoidData->up);
	}
}

int main(int argc, char** argv) {
  ros::init(argc, argv, "vision_obstacle_data_node");
  
  ros:: NodeHandle hn;

  ros::Subscriber obstacel_dis_sub = hn.subscribe("dji_osdk_ros/obstacle_info", 10, obstacleDisCallback);

  ros::Rate loop_rate(5);
  
  while (ros::ok())
  {
  
  ros::spinOnce();
  loop_rate.sleep();

  }

  return 0;

}


Reference:

OSDK4.1 version supports M210 v2 and M300 models to obtain the obstacle distance by subscribing to TOPIC_AVOID_DATA:

publish TOPIC_AVOID_DATA as ros topic of type ObstacleInfo with 100 hz()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值