Jetson Orin NX 开发指南(7): EGO-Swarm 的编译与运行

一、前言

EGO-Planner 浙江大学 FAST-LAB 实验室的开源轨迹规划算法是,受到 IEEE Spectrum 等知名科技媒体的报道,其理论技术较为前沿,是一种不依赖于ESDF,基于B样条的规划算法,并且规划成功率、算法消耗时间、代价数值等性能方面都要高于其他几种知名算法。

而 EGO-Swarm 是基于 EGO-Planner 拓展的去中心化的无人机集群算法,有助于智能小车或自主无人机集群的规划的学习与开发

由于 EGO-Planner 是 EGO-Swarm 的一部分,并且他们的安装其实差别不大,因此本文主要介绍 EGO-Swarm 的编译与运行,参考

https://github.com/ZJU-FAST-Lab/ego-planner-swarm

https://github.com/ZJU-FAST-Lab/ego-planner

GitHub - ZJU-FAST-Lab/Fast-Drone-250: hardware and software design of the 250mm autonomous drone

由于 Jetson 系列开发板常用于当作机载电脑,因此本文介绍如何在 Jetson Orin NX 开发板上编译和运行 EGO-Swarm,当然本文对 EGO-Planner 同样适用。

二、编译 EGO-Swarm

首先安装依赖

sudo apt-get install libarmadillo-dev

然后创建并进入工作空间

mkdir -p ~/catkin_ws/src/
cd ~/catkin_ws/src/

从 GitHub 上下载 EGO-Swarm 源码

git clone https://github.com/ZJU-FAST-Lab/ego-planner-swarm.git

进入 EGO-Swarm 工作空间并编译

cd ~/catkin_ws/src/ego-planner-swarm
catkin_make

编译完成显示如下结果

三、运行 EGO-Swarm

接下来我们运行 EGO-Swarm,主要分为仿真和实验两个部分

3.1 EGO-Swarm 仿真

首先通过快捷键 ctrl + alt + A 打开超级终端,如果没有安装则参考下文安装

Jetson Orin NX 开发指南(2): 基本环境配置_想要个小姑娘的博客-CSDN博客

将超级终端划分为两个终端,全选后 source 一下工作空间,终端输入

source ~/catkin_ws/src/ego-planner-swarm/devel/setup.bash

在第一个终端输入

roslaunch ego_planner rviz.launch

在第二个终端输入

roslaunch ego_planner swarm.launch

如下所示

依次执行可以得到如下结果

至此,EGO-Swarm 的仿真运行就实现了!

3.2 EGO-Swarm 实验

由于条件有限,我么在此仅仅只是将 EGO-Swarm 与 VINS-Fusion 进行连接,并且这里只涉及单个无人机(在这种情况下 EGO-Swarm 与 EGO-Planner 是等价的),其中 EGO-Swarm 单个无人机通过 VINS-Fusion 来获取里程计信息,同时通过深度相机数据来获取周围环境的情况。

3.2.1 xml 文件和 launch 文件配置

首先需要配置实验用的一些参数,对应于仿真中的 advanced_param.xml 文件,

其次需要配置调用 VINS-Fusion 里程计信息和 Realsense 深度相机信息的 launch 启动文件,对应于仿真中的 single_run_in_sim.launch 文件,

具体的配置可以参考 FAST-LAB 实验室的 fast-drone-250 中采用的 xml 和 launch 文件:

GitHub - ZJU-FAST-Lab/Fast-Drone-250: hardware and software design of the 250mm autonomous drone

主要是如下两个文件

但是为了订阅 VINS-Fusion 中里程计发布的话题是 /vins_estimator/imu_propagate,而上面订阅的话题是 /vins_fusion/imu_propagate,这是因为在 fast-drone-250 中,vins_estimator 节点被重命名为了 vins_fusion,从而产生了差异,只需修改以下订阅的话题即可,其余的可以不做修改,(当然如果标定了相机内外参以及 imu 的噪声,则可以将之后的数据修改上去,VINS-Fusion 或者 EGO-Swarm 上都要修改),具体操作如下

在 ~/catkin_ws/src/ego-planner-swarm/src/planner/plan_manage/launch/ 路径下创建两个文件

(1)advanced_param_exp.xml,其内容如下

<launch>
  <arg name="map_size_x_"/>
  <arg name="map_size_y_"/>
  <arg name="map_size_z_"/>

  <arg name="odometry_topic"/>
  <arg name="camera_pose_topic"/>
  <arg name="depth_topic"/>
  <arg name="cloud_topic"/>

  <arg name="cx"/>
  <arg name="cy"/>
  <arg name="fx"/>
  <arg name="fy"/>

  <arg name="max_vel"/>
  <arg name="max_acc"/>
  <arg name="planning_horizon"/>

  <arg name="point_num"/>
  <arg name="point0_x"/>
  <arg name="point0_y"/>
  <arg name="point0_z"/>
  <arg name="point1_x"/>
  <arg name="point1_y"/>
  <arg name="point1_z"/>
  <arg name="point2_x"/>
  <arg name="point2_y"/>
  <arg name="point2_z"/>
  <arg name="point3_x"/>
  <arg name="point3_y"/>
  <arg name="point3_z"/>
  <arg name="point4_x"/>
  <arg name="point4_y"/>
  <arg name="point4_z"/>

  <arg name="flight_type"/>
  <arg name="use_distinctive_trajs"/>

  <arg name="obj_num_set"/>

  <arg name="drone_id"/>


  <!-- main node -->
  <!-- <node pkg="ego_planner" name="ego_planner_node" type="ego_planner_node" output="screen" launch-prefix="valgrind"> -->
  <node pkg="ego_planner" name="drone_$(arg drone_id)_ego_planner_node" type="ego_planner_node" output="screen">
  
    <remap from="~odom_world" to="$(arg odometry_topic)"/>
    <remap from="~planning/bspline" to = "/drone_$(arg drone_id)_planning/bspline"/>
    <remap from="~planning/data_display" to = "/drone_$(arg drone_id)_planning/data_display"/>
    <remap from="~planning/broadcast_bspline_from_planner" to = "/broadcast_bspline"/>
    <remap from="~planning/broadcast_bspline_to_planner" to = "/broadcast_bspline"/>

    <remap from="~grid_map/odom" to="$(arg odometry_topic)"/>
    <remap from="~grid_map/cloud" to="$(arg cloud_topic)"/>
    <remap from="~grid_map/pose"   to = "$(arg camera_pose_topic)"/> 
    <remap from="~grid_map/depth" to = "$(arg depth_topic)"/>
    

    <!-- planning fsm -->
    <param name="fsm/flight_type" value="$(arg flight_type)" type="int"/>
    <param name="fsm/thresh_replan_time" value="1.0" type="double"/>
    <param name="fsm/thresh_no_replan_meter" value="1.0" type="double"/>
    <param name="fsm/planning_horizon" value="$(arg planning_horizon)" type="double"/> <!--always set to 1.5 times grater than sensing horizen-->
    <param name="fsm/planning_horizen_time" value="3" type="double"/>
    <param name="fsm/emergency_time" value="1.0" type="double"/>
    <param name="fsm/realworld_experiment" value="true"/>
    <param name="fsm/fail_safe" value="true"/>

    <param name="fsm/waypoint_num" value="$(arg point_num)" type="int"/>
    <param name="fsm/waypoint0_x" value="$(arg point0_x)" type="double"/>
    <param name="fsm/waypoint0_y" value="$(arg point0_y)" type="double"/>
    <param name="fsm/waypoint0_z" value="$(arg point0_z)" type="double"/>
    <param name="fsm/waypoint1_x" value="$(arg point1_x)" type="double"/>
    <param name="fsm/waypoint1_y" value="$(arg point1_y)" type="double"/>
    <param name="fsm/waypoint1_z" value="$(arg point1_z)" type="double"/>
    <param name="fsm/waypoint2_x" value="$(arg point2_x)" type="double"/>
    <param name="fsm/waypoint2_y" value="$(arg point2_y)" type="double"/>
    <param name="fsm/waypoint2_z" value="$(arg point2_z)" type="double"/>
    <param name="fsm/waypoint3_x" value="$(arg point3_x)" type="double"/>
    <param name="fsm/waypoint3_y" value="$(arg point3_y)" type="double"/>
    <param name="fsm/waypoint3_z" value="$(arg point3_z)" type="double"/>
    <param name="fsm/waypoint4_x" value="$(arg point4_x)" type="double"/>
    <param name="fsm/waypoint4_y" value="$(arg point4_y)" type="double"/>
    <param name="fsm/waypoint4_z" value="$(arg point4_z)" type="double"/>

    <param name="grid_map/resolution"      value="0.15" /> 
    <param name="grid_map/map_size_x"   value="$(arg map_size_x_)" /> 
    <param name="grid_map/map_size_y"   value="$(arg map_size_y_)" /> 
    <param name="grid_map/map_size_z"   value="$(arg map_size_z_)" /> 
    <param name="grid_map/local_update_range_x"  value="5.5" /> 
    <param name="grid_map/local_update_range_y"  value="5.5" /> 
    <param name="grid_map/local_update_range_z"  value="4.5" /> 
    <param name="grid_map/obstacles_inflation"     value="0.299" /> 
    <param name="grid_map/local_map_margin" value="10"/>
    <param name="grid_map/ground_height"        value="-0.01"/>
    <!-- camera parameter -->
    <param name="grid_map/cx" value="$(arg cx)"/>
    <param name="grid_map/cy" value="$(arg cy)"/>
    <param name="grid_map/fx" value="$(arg fx)"/>
    <param name="grid_map/fy" value="$(arg fy)"/>
    <!-- depth filter -->
    <param name="grid_map/use_depth_filter" value="true"/>
    <param name="grid_map/depth_filter_tolerance" value="0.15"/>
    <param name="grid_map/depth_filter_maxdist"   value="5.0"/>
    <param name="grid_map/depth_filter_mindist"   value="0.2"/>
    <param name="grid_map/depth_filter_margin"    value="2"/>
    <param name="grid_map/k_depth_scaling_factor" value="1000.0"/>
    <param name="grid_map/skip_pixel" value="2"/>
    <!-- local fusion -->
    <param name="grid_map/p_hit"  value="0.65"/>
    <param name="grid_map/p_miss" value="0.35"/>
    <param name="grid_map/p_min"  value="0.12"/>
    <param name="grid_map/p_max"  value="0.90"/>
    <param name="grid_map/p_occ"  value="0.80"/>
    <param name="grid_map/min_ray_length" value="0.3"/>
    <param name="grid_map/max_ray_length" value="5.0"/>

    <param name="grid_map/visualization_truncate_height"   value="1.8"/>
    <param name="grid_map/show_occ_time"  value="false"/>
    <param name="grid_map/pose_type"     value="2"/>  
    <param name="grid_map/frame_id"      value="world"/>

  <!-- planner manager -->
    <param name="manager/max_vel" value="$(arg max_vel)" type="double"/>
    <param name="manager/max_acc" value="$(arg max_acc)" type="double"/>
    <param name="manager/max_jerk" value="4" type="double"/>
    <param name="manager/control_points_distance" value="0.4" type="double"/>
    <param name="manager/feasibility_tolerance" value="0.05" type="double"/>
    <param name="manager/planning_horizon" value="$(arg planning_horizon)" type="double"/>
    <param name="manager/use_distinctive_trajs" value="$(arg use_distinctive_trajs)" type="bool"/>
    <param name="manager/drone_id" value="$(arg drone_id)"/>

  <!-- trajectory optimization -->
    <param name="optimization/lambda_smooth" value="1.0" type="double"/>
    <param name="optimization/lambda_collision" value="0.5" type="double"/>
    <param name="optimization/lambda_feasibility" value="0.1" type="double"/>
    <param name="optimization/lambda_fitness" value="1.0" type="double"/>
    <param name="optimization/dist0" value="0.5" type="double"/>
    <param name="optimization/swarm_clearance" value="0.5" type="double"/>
    <param name="optimization/max_vel" value="$(arg max_vel)" type="double"/>
    <param name="optimization/max_acc" value="$(arg max_acc)" type="double"/>

    <param name="bspline/limit_vel" value="$(arg max_vel)" type="double"/>
    <param name="bspline/limit_acc" value="$(arg max_acc)" type="double"/>
    <param name="bspline/limit_ratio" value="1.1" type="double"/>

  <!-- objects prediction -->
    <param name="prediction/obj_num" value="$(arg obj_num_set)" type="int"/>
    <param name="prediction/lambda" value="1.0" type="double"/>
    <param name="prediction/predict_rate" value="1.0" type="double"/>
  
  


  </node>

</launch>

(2)single_run_in_exp.launch,其内容如下

<launch>
    <!-- number of moving objects -->
    <arg name="obj_num" value="10" />
    <arg name="drone_id" value="0"/>

    <arg name="map_size_x" value="100"/>
    <arg name="map_size_y" value="50"/>
    <arg name="map_size_z" value="3.0"/>
    <arg name="odom_topic" value="/vins_estimator/imu_propagate"/>
    
    <!-- main algorithm params -->
    <include file="$(find ego_planner)/launch/advanced_param_exp.xml">
        <arg name="drone_id" value="$(arg drone_id)"/>
        <arg name="map_size_x_" value="$(arg map_size_x)"/>
        <arg name="map_size_y_" value="$(arg map_size_y)"/>
        <arg name="map_size_z_" value="$(arg map_size_z)"/>
        <arg name="odometry_topic" value="$(arg odom_topic)"/>
        <arg name="obj_num_set" value="$(arg obj_num)" />
        <!-- camera pose: transform of camera frame in the world frame -->
        <!-- depth topic: depth image, 640x480 by default -->
        <!-- don't set cloud_topic if you already set these ones! -->
        <arg name="camera_pose_topic" value="nouse1"/>
        <arg name="depth_topic" value="/camera/depth/image_rect_raw"/>
        <!-- topic of point cloud measurement, such as from LIDAR  -->
        <!-- don't set camera pose and depth, if you already set this one! -->
        <arg name="cloud_topic" value="nouse2"/>
        <!-- intrinsic params of the depth camera -->
        <arg name="cx" value="323.3316345214844"/>
        <arg name="cy" value="234.95498657226562"/>
        <arg name="fx" value="384.39654541015625"/>
        <arg name="fy" value="384.39654541015625"/>
        <!-- maximum velocity and acceleration the drone will reach -->
        <arg name="max_vel" value="0.5" />
        <arg name="max_acc" value="6.0" />
        <!--always set to 1.5 times grater than sensing horizen-->
        <arg name="planning_horizon" value="6" />
        <arg name="use_distinctive_trajs" value="false" />
        <!-- 1: use 2D Nav Goal to select goal  -->
        <!-- 2: use global waypoints below  -->
        <arg name="flight_type" value="1" />
        <!-- global waypoints -->
        <!-- It generates a piecewise min-snap traj passing all waypoints -->
        <arg name="point_num" value="1" />
        <arg name="point0_x" value="15" />
        <arg name="point0_y" value="0" />
        <arg name="point0_z" value="1" />
        <arg name="point1_x" value="0.0" />
        <arg name="point1_y" value="0.0" />
        <arg name="point1_z" value="1.0" />
        <arg name="point2_x" value="15.0" />
        <arg name="point2_y" value="0.0" />
        <arg name="point2_z" value="1.0" />
        <arg name="point3_x" value="0.0" />
        <arg name="point3_y" value="0.0" />
        <arg name="point3_z" value="1.0" />
        <arg name="point4_x" value="15.0" />
        <arg name="point4_y" value="0.0" />
        <arg name="point4_z" value="1.0" />
    </include>
    <!-- trajectory server -->
    <node pkg="ego_planner" name="drone_$(arg drone_id)_traj_server" type="traj_server" output="screen">
        <!-- <remap from="position_cmd" to="/setpoints_cmd"/> -->
        <remap from="~planning/bspline" to="drone_$(arg drone_id)_planning/bspline"/>
        <param name="traj_server/time_forward" value="1.0" type="double"/>
    </node>
</launch>

修改完成后保存即可!

3.2.2 VINS-Fusion-gpu + EGO-Swarm 实验

接下来我们先运行 Realsense 和 VINS-Fusion-gpu,如果没有安装 Realsense 和 VINS-Fusion-gpu,参考以下两篇文章

Jetson Orin NX 开发指南(4): 安装 CUDA 和 Realsense_想要个小姑娘的博客-CSDN博客

Jetson Orin NX 开发指南(6): VINS-Fusion-gpu 的编译和运行_想要个小姑娘的博客-CSDN博客

相关推荐
knighthood20013 小时前
解决:ros进行gazebo仿真,rviz没有显示传感器数据
c++·ubuntu·ros
knighthood20012 天前
ros中仿真编写launch时robot_state_publisher,output参数
c++·ubuntu·ros
Mr.Winter`3 天前
路径规划 | ROS中多个路径规划算法可视化与性能对比分析
人工智能·算法·机器人·自动驾驶·ros·ros2·路径规划
辰风已久7 天前
ROS(快速初步入门)
ros
wait,what?9 天前
【ROS概述】C++运行hello world
机器人·ros
wait,what?10 天前
【ROS概述】解决主机和虚拟机共享剪贴板的问题
ros
kuan_li_lyg10 天前
SolidWorks 导出 URDF 中的惯性矩阵错误问题
开发语言·人工智能·机器人·ros·urdf·solidworks
Lusix194911 天前
Realsense相机驱动在使用imu数据时出现Qos问题
数码相机·slam·realsense
wait,what?11 天前
【ROS概述】概念及环境搭建
机器人·ros
leaf_leaves_leaf11 天前
【WSL2】Ubuntu20.04从零开搭PX4&Mavros&Gazebo环境并测试
机器人·ros·px4