注明:最终在rivz中没有看到点云,原因未知。

  1. ROS中消息重映射需要在发布该话题的节点下进行,否则不成功。如果是针对mavros的消息进行重映射,则需要找到mavrso包下launch文件,px4.launch。然后由于px4.launch(如下图所示)中调用的是node.launch,故需要再次找到node.launch文件进行修改。
<launch>
	<!-- vim: set ft=xml noet : -->
	<!-- example launch script for PX4 based FCU's -->

	<arg name="fcu_url" default="/dev/ttyACM0:57600" />
	<arg name="gcs_url" default="" />
	<arg name="tgt_system" default="1" />
	<arg name="tgt_component" default="1" />
	<arg name="log_output" default="screen" />
	<arg name="fcu_protocol" default="v2.0" />
	<arg name="respawn_mavros" default="false" />

	<include file="$(find mavros)/launch/node.launch">
		<arg name="pluginlists_yaml" value="$(find mavros)/launch/px4_pluginlists.yaml" />
		<arg name="config_yaml" value="$(find mavros)/launch/px4_config.yaml" />

		<arg name="fcu_url" value="$(arg fcu_url)" />
		<arg name="gcs_url" value="$(arg gcs_url)" />
		<arg name="tgt_system" value="$(arg tgt_system)" />
		<arg name="tgt_component" value="$(arg tgt_component)" />
		<arg name="log_output" value="$(arg log_output)" />
		<arg name="fcu_protocol" value="$(arg fcu_protocol)" />
		<arg name="respawn_mavros" default="$(arg respawn_mavros)" />
	</include>
</launch>

node.launch文件如下图所示:

<launch>
	<!-- vim: set ft=xml noet : -->
	<!-- base node launch file-->

	<arg name="fcu_url" />
	<arg name="gcs_url" />
	<arg name="tgt_system" />
	<arg name="tgt_component" />
	<arg name="pluginlists_yaml" />
	<arg name="config_yaml" />
	<arg name="log_output" default="screen" />
	<arg name="fcu_protocol" default="v2.0" />
	<arg name="respawn_mavros" default="false" />

	<node pkg="mavros" type="mavros_node" name="mavros" required="$(eval not respawn_mavros)" clear_params="true" output="$(arg log_output)" respawn="$(arg respawn_mavros)">
		<remap from="mavros/imu/data" to="/imu/data" />
		<param name="fcu_url" value="$(arg fcu_url)" />
		<param name="gcs_url" value="$(arg gcs_url)" />
		<param name="target_system_id" value="$(arg tgt_system)" />
		<param name="target_component_id" value="$(arg tgt_component)" />
		<param name="fcu_protocol" value="$(arg fcu_protocol)" />

		<!-- load blacklist, config -->
		<rosparam command="load" file="$(arg pluginlists_yaml)" />
		<rosparam command="load" file="$(arg config_yaml)" />
	</node>
</launch>

其中,<remap … 表示重映射。

  1. rosbag play -l hdl_400.bag表示循环播放bag文件,其中 -l 表示 loop。

  2. rostopic info /topic 可以查看该话题的所属的消息。如下图所示,显示了话题所属的类型,订阅者,以及发布者。
    在这里插入图片描述

  3. 参考Loam的编译安装运行及可能遇到的问题,完成了PCL库的安装。其中遇到如下的错误

    在这里插入图片描述

    解决方法是:出现multiscanregistration错误,在loam_velodyne / CMakeLists.txt,下面删除第35行, add_definitions(-march = native),重新编译,即可正常运行,不需要重装pcl
  4. SLAM参考LOAM进行点云地图创建,不同之处我是新建了一个ROS工程,然后将代码拷贝到src目录下,进行编译。如下图所示,这样的好处是单独管理。
    在这里插入图片描述
  5. ROS节点发布消息/mavros/vision_pose/pose,作为fuse进入EKF2中,首先在QGC中进行修改,如下图,将EKF2_AID_MASK 修改如下,
    在这里插入图片描述
    若要融合高度信息,修改EKF2_HGT_MODE如下。
    在这里插入图片描述
  6. ROS中/mavros/vision_pose/pose需要加入时间戳信息:

    vision_pose.header.stamp = ros::Time::now();
    

    同时,发布给定坐标点让飞机起飞。

  7. 注意:飞机需要一个GPS信息作为绝对位置信息,这样飞机给定坐标点在OFFBOARD模式下起飞,而视觉信息是作为融合数据进入到反馈环路中的。