在gmapping的launch文件中看到,type=“slam_gmapping”,这里的slam_gmapping是c++编译后的可执行文件。
如果想要修改gmapping算法,就需要找到slam_gmapping的c++源码。
但是这是用apt下载的包,是二进制类型的,没有下载出来源码。
如果想要找源码该怎么办?
<!-- Gmapping --><node pkg="gmapping" type="slam_gmapping" name="gmapping" output="screen"><param name="base_frame" value="$(arg set_base_frame)"/><param name="odom_frame" value="$(arg set_odom_frame)"/><param name="map_frame" value="$(arg set_map_frame)"/>
可以先通过下面的方法找到gmapping的xml文件
@ubuntu:~$ roscd gmapping
@ubuntu:/opt/ros/melodic/share/gmapping$ ls
cmake nodelet_plugins.xml package.xml
@ubuntu:/opt/ros/melodic/share/gmapping$ cat package.xml
<package><name>gmapping</name><version>1.4.1</version><description>This package contains a ROS wrapper for OpenSlam's Gmapping. The gmapping package provides laser-based SLAM (Simultaneous Localization and Mapping), as a ROS node called slam_gmapping. Using slam_gmapping, you can create a 2-D occupancygrid map (like a building floorplan) from laser and pose data collected by a mobile robot.</description><author>Brian Gerkey</author><maintainer email="ros-orphaned-packages@googlegroups.com">ROS Orphaned Package Maintainers</maintainer><license>BSD</license><license>Apache 2.0</license><url>http://ros.org/wiki/gmapping</url><buildtool_depend version_gte="0.5.68">catkin</buildtool_depend><build_depend>nav_msgs</build_depend><build_depend>openslam_gmapping</build_depend><build_depend>roscpp</build_depend><build_depend>rostest</build_depend><build_depend>tf</build_depend><build_depend>nodelet</build_depend><run_depend>nav_msgs</run_depend><run_depend>openslam_gmapping</run_depend><run_depend>roscpp</run_depend><run_depend>tf</run_depend><run_depend>nodelet</run_depend><export><nodelet plugin="${prefix}/nodelet_plugins.xml" /></export>
</package>
可以看到里面有一个url指向wiki地址。
<url>http://ros.org/wiki/gmapping</url>
打开链接选择melodic版本。
里面会有参数的说明。打开下面的github链接。
然后下载,就可以在src文件目录下找到c++源码,进行算法研究和修改。
二进制包和源码之间的切换:
之前改过一个opencv-apps的:过程如下。sudo apt remove ros-melodic-opencv-apps
把apt安装的包删了.
再通过roscd验证是否已删除
roscd opencv-apps/然后进到catkin_ws/src目录。
git clone https://github.com/ros-perception/opencv_apps.git然后清除之前编译的内容—删除工作空间下的build和devel文件。然后catkin_make限制编译的进程数:j几就是几线程
catkin_make -j1
单线程编译好处是占用较少资源,缺点是编译时间长。roscd opencv_apps/
ls