注:按照这个弄出来的仿真其tf tree还有问题
参考连接
https://mp.weixin.qq.com/s/GlX1C9ldpuRMIFH1uOETOQ
https://blog.csdn.net/weixin_40599145/article/details/89788543
https://www.yuque.com/xtdrone/manual_cn/basic_config_1.9
注:可能这几个链接包括我的写的内容也不一定对你有用,就像我参考上面这几个链接,我完全弄不出来,还是在师兄的帮助下才搞定,这里要感谢财富哥。参考我写的内容的自己也要思考,我使用的计算机是intel NUC
git clone https://github.com/PX4/Firmware.git --recursive
确保你的固件能该命令make px4_sitl gazebo
编译通过,并打开gazebo仿真环境,如下图所示:
同时需要在.bashrc添加如下内容:
source ~/PX4_Files/Firmware/Tools/setup_gazebo.bash ~/PX4_Files/Firmware ~/PX4_Files/Firmware/build/px4_sitl_default
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:~/PX4_Files/Firmware
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:~/PX4_Files/Firmware/Tools/sitl_gazebo
source /usr/share/gazebo-9/setup.sh
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/lib/x86_64-linux-gnu/gazebo-9/plugins/
<!--修改之前的配置-->
<!--arg name="vehicle" default="iris"/-->
<!--arg name="world" default="$(find mavlink_sitl_gazebo)/worlds/empty.world"/-->
<!--修改之后的配置-->
<arg name="vehicle" default="iris_rplidar"/>
<arg name="world" default="$(find mavlink_sitl_gazebo)/worlds/iris_rplidar.world"/>
<!-- MAVROS configs -->
<!--修改之前的配置-->
<!--arg name="fcu_url" default="udp://:14540@localhost:14557"/-->
<!--修改之后的配置-->
<arg name="fcu_url" default="udp://:[email protected]:14557"/>
<!--修改前的配置-->
<!--sensor name="laser" type="gpu_ray"-->
<!--修改后的配置-->
<sensor name="laser" type="ray">
<!--修改前的配置-->
<!--plugin name="laser" filename="libGpuRayPlugin.so" />
<plugin name="gazebo_ros_head_rplidar_controller" filename="libgazebo_ros_gpu_laser.so">
<topicName>laser/scan</topicName>
<frameName>rplidar_link</frameName-->
<!--修改后的配置-->
<plugin name="laser" filename="libRayPlugin.so" />
<plugin name="gazebo_ros_head_rplidar_controller" filename="libgazebo_ros_laser.so">
<topicName>/scan</topicName>
<frameName>laser</frameName>
复制一份demo_revo_lds.launch并重新命名为rplidar.launch,如下所示:
修改rplidar.launch的内容,修改后的rplidar.launch文件内容如下:
<launch>
<param name="/use_sim_time" value="true" />
<node name="cartographer_node" pkg="cartographer_ros"
type="cartographer_node" args="
-configuration_directory $(find cartographer_ros)/configuration_files
-configuration_basename rplidar.lua"
output="screen">
<remap from="/scan" to="/scan" />
</node>
<node name="cartographer_occupancy_grid_node" pkg="cartographer_ros"
type="cartographer_occupancy_grid_node" args="-resolution 0.05" />
<node name="rviz" pkg="rviz" type="rviz" required="true"
args="-d $(find cartographer_ros)/configuration_files/demo_2d.rviz" />
</launch>
复制一份revo_lds.lua并重新命名为rplidar.lua,如下所示:
修改rplidar.lua的内容,只需要改两处内容即可:
tracking_frame = "laser",
published_frame = "laser",
注:别忘了source环境变量
dependent_ervironment.sh是我这一篇here的内容。所有工作已经完成,修改后的cartographer不仅对rplidar A2仿真适用,还对真实rplidar A2建图适用。
运行PX4roslaunch px4 mavros_posix_sitl.launch
运行gartographer
建图成功