{"id":157,"date":"2021-11-21T12:46:03","date_gmt":"2021-11-21T12:46:03","guid":{"rendered":"http:\/\/47.103.123.166\/?p=157"},"modified":"2021-11-21T12:46:03","modified_gmt":"2021-11-21T12:46:03","slug":"ros2_foxy%e5%ad%a6%e4%b9%a09-%e5%a4%9a%e6%9c%ba%e6%bf%80%e5%85%89slam%e5%85%88%e5%af%bc%e7%af%87","status":"publish","type":"post","link":"http:\/\/47.103.123.166\/?p=157","title":{"rendered":"ROS2_Foxy\u5b66\u4e609\u2014\u2014\u591a\u673a\u6fc0\u5149SLAM\u5148\u5bfc\u7bc7"},"content":{"rendered":"<p>&emsp;&emsp;\u8fd9\u7bc7\u6587\u7ae0\u7684\u6574\u4f53\u76ee\u7684\u662f\u5728\u591a\u4e2a\u8f66\u4e0a\u8dd1slam\uff0c\u901a\u8fc7ROS2_Foxy\u5c06\u5730\u56fe\u96c6\u4e2d\u5230\u4e00\u4e2a\u7535\u8111\u4e0b\uff0c\u7136\u540e\u62fc\u63a5\u6210\u4e00\u5f20\u5730\u56fe\u3002<br \/>\n&emsp;&emsp;\u4e00\u5f00\u59cb\u7684\u60f3\u6cd5\u662f\u8f66\u4e0a\u7528ROS2\u8dd1SLAM\uff0c\u7531\u4e8e\u5404\u5927\u5f00\u6e90SLAM\u7b97\u6cd5\u5bf9ROS2\u4e0d\u652f\u6301\u6216\u8005\u652f\u6301\u4e0d\u5b8c\u5584\uff08\u53c8\u56e0\u4e3a<del>\u61d2<\/del> \u80fd\u529b\u4e0d\u591f\uff0c\u4e0d\u80fd\u628a\u4ee3\u7801\u4eceROS1\u79fb\u690d\u5230ROS2\uff09\uff0c\u56e0\u800c\uff0c\u4f7f\u7528ROS1\u8dd1SLAM\uff0c\u7136\u540e\u901a\u8fc7ROS2\u7684\u5305ros1_bridge\u5728\u5404\u8f66\u4e0e\u7535\u8111\u4e4b\u95f4\u4f20\u9012\u6570\u636e\uff0c\u4ece\u800c\u5b9e\u73b0\u6b64\u9879\u76ee\u3002<br \/>\n&emsp;&emsp;\u5728\u5f15\u5165ros1_bridge\u4e4b\u524d\uff0c\u5148\u5199\u4e00\u5199\u5728ROS1\u4e0a\u8dd1\u5f00\u6e90SLAM\uff0c\u4ee5\u53ca\u5728ROS2\u4e0a\u8dd1\u5f00\u6e90SLAM\u7684\u4e00\u4e9b\u8fc7\u7a0b\u3002<br \/>\n&emsp;&emsp;\u56e0\u4e3a<del>\u6ca1\u505a\u5b8c<\/del> \u5185\u5bb9\u8f83\u591a\uff0c\u6240\u4ee5\u5206\u4e86\u51e0\u4e2a\u90e8\u5206\u6765\u5199\uff0c\u8fd9\u4e00\u7bc7\u662f\u63a2\u7d22\u53ef\u884c\u6027\u7684\u3002<\/p>\n<h2>1 \u73af\u5883\u51c6\u5907<\/h2>\n<table>\n<thead>\n<tr>\n<th>\u8bbe\u5907<\/th>\n<th>\u5904\u7406\u5668<\/th>\n<th>\u7cfb\u7edf<\/th>\n<th>ROS1\u7248\u672c<\/th>\n<th>ROS2\u7248\u672c<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\u7535\u8111<\/td>\n<td>amd64_\u9177\u777fi7 5500U_\u5185\u5b588GB<\/td>\n<td>Ubuntu 20.04 LTS<\/td>\n<td>Noetic<\/td>\n<td>Foxy<\/td>\n<\/tr>\n<tr>\n<td>\u8f66<\/td>\n<td>arm64_\u6811\u8393\u6d3e4B_\u5185\u5b584GB<\/td>\n<td>Ubuntu mate 20.04 LTS<\/td>\n<td>&#8211;<\/td>\n<td>Foxy<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&emsp;&emsp;\u6fc0\u5149\u96f7\u8fbe\u4f7f\u7528\u601d\u5c9aRPLidarA1\uff0c\u7531\u4e8e\u8fd9\u4e2a\u96f7\u8fbe\u9891\u7387\u8f83\u4f4e\uff0c\u56e0\u6b64\u5f00\u6e90SLAM\u9009\u62e9cartographer\u3002\u6ca1\u6709\u9009\u62e9Hector\u7684\u539f\u56e0\u9664\u4e86RPLidarA1\u626b\u63cf\u9891\u7387\u592a\u4f4e\uff0c\u7528Hector\u6548\u679c\u4e0d\u7406\u60f3\u5916\uff0cHector\u5b98\u65b9\u6ca1\u6709\u7ed9ROS2\u7684\u7248\u672c\uff0c\u81ea\u5df1\u79fb\u690d\u592a\u8d39\u65f6\u95f4\u3002<\/p>\n<h2>2 ROS1\u4e0b\u6d4b\u8bd5SLAM<\/h2>\n<h3>2.1 cartographer \u6e90\u7801\u6d4b\u8bd5<\/h3>\n<p>&emsp;&emsp;\u53c2\u8003\u5b98\u65b9\u6587\u6863\uff1a<a href=\"https:\/\/google-cartographer-ros.readthedocs.io\/en\/latest\/compilation.html\"><a href=\"https:\/\/google-cartographer-ros.readthedocs.io\/en\/latest\/compilation.html\">https:\/\/google-cartographer-ros.readthedocs.io\/en\/latest\/compilation.html<\/a><\/a> \u3002 <\/p>\n<pre><code class=\"language-powershell\"># \u5b89\u88c5\u5de5\u5177\n    sudo apt-get update\n    sudo apt-get install -y python3-wstool python3-rosdep ninja-build stow\n\n# \u4e0b\u8f7d\u6e90\u7801\n    mkdir catkin_ws\n    cd catkin_ws\n    wstool init src\n    wstool merge -t src https:\/\/raw.githubusercontent.com\/cartographer-project\/cartographer_ros\/master\/cartographer_ros.rosinstall\n    wstool update -t src\n\n# \u5b89\u88c5\u4f9d\u8d56\n    sudo rosdep init\n    rosdep update\n    rosdep install --from-paths src --ignore-src --rosdistro=${ROS_DISTRO} -y\n\n# \u624b\u52a8\u5b89\u88c5abseil-cpp\u5e93\n    src\/cartographer\/scripts\/install_abseil.sh\n\n# \u7f16\u8bd1\u5b89\u88c5\n    . \/opt\/ros\/noetic\/setup.bash    #\uff08\u8bb0\u5f97source ros1\u7684\u5b89\u88c5\u4f4d\u7f6e\uff09\n    catkin_make_isolated --install --use-ninja\n\n# \u8dd1\u4e2a\u5305\n    . install_isolated\/setup.bash       #\uff08\u8bb0\u5f97source cartographer\u7684\u5b89\u88c5\u4f4d\u7f6e\uff09\n    wget -P ~\/Downloads https:\/\/storage.googleapis.com\/cartographer-public-data\/bags\/backpack_2d\/cartographer_paper_deutsches_museum.bag\n    roslaunch cartographer_ros demo_backpack_2d.launch bag_filename:=${HOME}\/Downloads\/cartographer_paper_deutsches_museum.bag<\/code><\/pre>\n<p>&emsp;&emsp;\u8dd1\u7684bag\u5927\u6982\u662f\u8fd9\u6837\u5b50\uff1a<br \/>\n<img src=\"http:\/\/47.103.123.166\/wp-content\/uploads\/2021\/11\/post-157-619a3f8c301c7.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h3>2.2 rplidar_ros \u6e90\u7801\u6d4b\u8bd5<\/h3>\n<p>&emsp;&emsp;\u53c2\u8003\u5b98\u65b9\u6587\u6863\uff1a<a href=\"https:\/\/github.com\/Slamtec\/rplidar_ros\"><a href=\"https:\/\/github.com\/Slamtec\/rplidar_ros\">https:\/\/github.com\/Slamtec\/rplidar_ros<\/a><\/a> \u3002<\/p>\n<pre><code class=\"language-powershell\"># \u4e0b\u8f7d\u6e90\u7801\n    mkdir -p catkin_ws\/src\n    cd catkin_ws\/src\n    git clone https:\/\/github.com\/Slamtec\/rplidar_ros.git\n\n# \u7f16\u8bd1\n    . \/opt\/ros\/noetic\/setup.bash    #\uff08\u8bb0\u5f97source ros1\u7684\u5b89\u88c5\u4f4d\u7f6e\uff09\n    catkin_make\n\n# \u8fde\u63a5\u96f7\u8fbe\uff0c\u5e76\u8d4b\u4e88\u8bbe\u5907\u6743\u9650\uff08\u6839\u636e\u5b9e\u9645\u60c5\u51b5\uff0c\u9009\u62e9\u8bbe\u5907\u540d\u79f0\uff09\n    sudo chmod 777 \/dev\/ttyUSB0\n\n# \u8dd1\u4e2ademo\uff08\u8bb0\u5f97source rplidar_ros\u7684\u5b89\u88c5\u4f4d\u7f6e\uff09\n    . devel\/setup.bash      # \u56e0\u4e3a\u53ea\u7f16\u8bd1\uff0c\u6ca1\u6709\u5b89\u88c5\uff0c\u6240\u4ee5\u6ca1\u6709install\u6587\u4ef6\u5939\n    roslaunch rplidar_ros test_rplidar.launch<\/code><\/pre>\n<p>&emsp;&emsp;\u8dd1\u7684\u662f\u8fd9\u6837\u5b50\uff1a<br \/>\n<img src=\"http:\/\/47.103.123.166\/wp-content\/uploads\/2021\/11\/post-157-619a3f8c8e4fa.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/>&emsp;&emsp;\u518d\u8dd1\u4e2arviz\u7684demo<\/p>\n<pre><code class=\"language-powershell\">    roslaunch rplidar_ros view_rplidar.launch<\/code><\/pre>\n<p>&emsp;&emsp;\u8dd1\u7684\u662f\u8fd9\u6837\u5b50\uff1a<br \/>\n<img src=\"http:\/\/47.103.123.166\/wp-content\/uploads\/2021\/11\/post-157-619a3f8ce3caf.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h3>2.3 rplidar_ros + cartographer<\/h3>\n<p>1\u3001\u51c6\u5907\u6e90\u7801<br \/>\n&emsp;&emsp;\u65b0\u5efa\u5de5\u4f5c\u7a7a\u95f4\uff0c\u5e76\u628a<strong>cartographer<\/strong>\u548c<strong>rplidar_ros<\/strong>\u7684\u6e90\u7801\u5305\u653e\u5230\/src\u6587\u4ef6\u5939\u4e0b\u3002<br \/>\n2\u3001\u7f16\u5199cartographer\u7684launch\u6587\u4ef6\u548clua\u914d\u7f6e\u6587\u4ef6<br \/>\n&emsp;&emsp;\u76f4\u63a5\u53c2\u8003\u6e90\u7801\u7ed9\u7684demo\u6765\u6539\uff0c\u4e3b\u8981\u53c2\u8003\u4e86cartographer_ros\u5305\u4e0b\u7684launch\/<strong>demo_revo_lds.launch<\/strong>\u53ca\u5176\u5bf9\u5e94\u7684<strong>configuration_files\/revo_lds.lua<\/strong>\uff0c\u6539\u52a8\u7684\u6587\u4ef6\u5185\u5bb9\u5982\u4e0b\uff0c\u8fd9\u91cc\u662f\u91cd\u65b0\u7f16\u5199\u4e86\u4e24\u4e2a\u6587\u4ef6\uff0c\u5e76\u5c06\u8fd9\u4e24\u4e2a\u65b0\u6587\u4ef6\u653e\u5728\u4e86\u8ddf\u53c2\u8003\u6587\u4ef6\u540c\u4e00\u4e2a\u6587\u4ef6\u5939\u5185\uff1a<\/p>\n<p><strong>launch\u6587\u4ef6<\/strong>\uff1acartoForRplidar.launch &lt;\u2014\u2014 demo_revo_lds.launch<\/p>\n<pre><code class=\"language-xml\">&lt;launch&gt;  \n  &lt;--\uff01false \u662f\u56e0\u4e3a\u8981\u4f7f\u7528\u771f\u5b9e\u96f7\u8fbe\u6570\u636e\uff0c\u4e0d\u7528\u4eff\u771f\u65f6\u95f4 \/--&gt;\n  &lt;param name=\"\/use_sim_time\" value=\"false\" \/&gt;  \n\n  &lt;--\uff01\u6ce8\u610fconfiguration_basename \u540e\u9762\u7684\u914d\u7f6e\u6587\u4ef6\u540d\uff0c\u8981\u4e0e\u5b9e\u9645\u7684lua\u6587\u4ef6\u540d\u4e00\u81f4 \/--&gt;\n  &lt;node name=\"cartographer_node\" pkg=\"cartographer_ros\"  \n        type=\"cartographer_node\" args=\"  \n            -configuration_directory $(find cartographer_ros)\/configuration_files  \n            -configuration_basename rplidar.lua\"  \n        output=\"screen\"&gt;  \n    &lt;--\uff01\u8fd9\u53e5\u5b9e\u9645\u4e0a\uff0c\u53ef\u4ee5\u5220\u6389 \/--&gt;\n    &lt;remap from=\"scan\" to=\"scan\" \/&gt;  \n  &lt;\/node&gt;  \n  &lt;node name=\"rviz\" pkg=\"rviz\" type=\"rviz\" required=\"true\"  \n        args=\"-d $(find cartographer_ros)\/configuration_files\/demo_2d.rviz\" \/&gt;  \n&lt;\/launch&gt;<\/code><\/pre>\n<p><strong>lua\u6587\u4ef6<\/strong>\uff1arplidar.lua &lt;\u2014\u2014 revo_lds.lua<br \/>\n&emsp;&emsp;\u8fd9\u4e2a\u6587\u4ef6\u53ea\u6539\u4e86tracking_frame\u548cpublished_frame\uff0c\u8fd9\u4e24\u4e2aframe\uff0c\u4e00\u822c\u662flaser\uff0c\u9700\u8981\u6839\u636e\u96f7\u8fberos\u9a71\u52a8\u7684\u5b9e\u9645\u60c5\u51b5\u914d\u7f6e\u3002<\/p>\n<pre><code class=\"language-xml\">include \"map_builder.lua\"\ninclude \"trajectory_builder.lua\"\n\noptions = {\n  map_builder = MAP_BUILDER,\n  trajectory_builder = TRAJECTORY_BUILDER,\n  map_frame = \"map\",\n  tracking_frame = \"laser\",\n  published_frame = \"laser\",\n  odom_frame = \"odom\",\n  provide_odom_frame = true,\n  publish_frame_projected_to_2d = false,\n  use_pose_extrapolator = true,\n  use_odometry = false,\n  use_nav_sat = false,\n  use_landmarks = false,\n  num_laser_scans = 1,\n  num_multi_echo_laser_scans = 0,\n  num_subdivisions_per_laser_scan = 1,\n  num_point_clouds = 0,\n  lookup_transform_timeout_sec = 0.2,\n  submap_publish_period_sec = 0.3,\n  pose_publish_period_sec = 5e-3,\n  trajectory_publish_period_sec = 30e-3,\n  rangefinder_sampling_ratio = 1.,\n  odometry_sampling_ratio = 1.,\n  fixed_frame_pose_sampling_ratio = 1.,\n  imu_sampling_ratio = 1.,\n  landmarks_sampling_ratio = 1.,\n}\n\nMAP_BUILDER.use_trajectory_builder_2d = true\n\nTRAJECTORY_BUILDER_2D.submaps.num_range_data = 35\nTRAJECTORY_BUILDER_2D.min_range = 0.3\nTRAJECTORY_BUILDER_2D.max_range = 8.\nTRAJECTORY_BUILDER_2D.missing_data_ray_length = 1.\nTRAJECTORY_BUILDER_2D.use_imu_data = false\nTRAJECTORY_BUILDER_2D.use_online_correlative_scan_matching = true\nTRAJECTORY_BUILDER_2D.real_time_correlative_scan_matcher.linear_search_window = 0.1\nTRAJECTORY_BUILDER_2D.real_time_correlative_scan_matcher.translation_delta_cost_weight = 10.\nTRAJECTORY_BUILDER_2D.real_time_correlative_scan_matcher.rotation_delta_cost_weight = 1e-1\n\nPOSE_GRAPH.optimization_problem.huber_scale = 1e2\nPOSE_GRAPH.optimize_every_n_nodes = 35\nPOSE_GRAPH.constraint_builder.min_score = 0.65\n\nreturn options<\/code><\/pre>\n<p>3\u3001\u7f16\u8bd1<br \/>\n&emsp;&emsp;catkin_make\u548ccatkin_make_isolated\u90fd\u53ef\u4ee5\uff0c\u533a\u522b\u662f\u540e\u8005\u4f7f\u7528\u4e00\u4e2a\u9694\u79bb\u7684\u6784\u5efa\u8fc7\u7a0b\uff0c\u5176\u4e2d\u6bcf\u4e2a\u5305\u90fd\u662f\u72ec\u7acb\u914d\u7f6e\u3001\u6784\u5efa\u548c\u52a0\u8f7d\u5230\u73af\u5883\u4e2d\u7684\uff0c\u89e3\u51b3\u4e86\u76ee\u6807\u51b2\u7a81\u3001\u76ee\u6807\u4f9d\u8d56\u9879\u7ba1\u7406\u548c\u9879\u76ee\u4e4b\u95f4\u5176\u4ed6\u4e0d\u5e0c\u671b\u7684\u4ea4\u53c9\u5bf9\u8bdd\u7684\u95ee\u9898\uff0c\u7f3a\u70b9\u662f\u6bd4\u8f83\u6162\uff0c\u5177\u4f53\u53c2\u8003<a href=\"https:\/\/blog.csdn.net\/qq_23225073\/article\/details\/102825545\">\u8fd9\u7bc7\u535a\u5ba2<\/a>\u3002<br \/>\n&emsp;&emsp;tips\uff1a\u7f16\u8bd1\u540e\u518d\u4fee\u6539launch\u6216lua\u6587\u4ef6\uff0c\u53ea\u7f16\u8bd1\u5355\u72ec\u7684\u5305\u5373\u53ef <\/p>\n<pre><code class=\"language-powershell\">    catkin_make_isolated --pkg cartographer_ros<\/code><\/pre>\n<p>4\u3001\u8dd1\u4e00\u8dd1<br \/>\n&emsp;&emsp;\u5148\u8dd1cartographer\u518d\u8dd1rplidar_ros\uff0c\u5982\u679c\u53cd\u4e86\uff0c\u4f3c\u4e4e\u4e0d\u592a\u884c\uff0c\u539f\u56e0\u8fd8\u6ca1\u6709\u6df1\u7a76\u3002<\/p>\n<pre><code class=\"language-powershell\"># \u9996\u5148\u7684\u9996\u5148\uff0c\u914d\u7f6e\u73af\u5883\u53d8\u91cf\n    . \/opt\/ros\/noetic\/setup.bash\n    . devel_isolated\/setup.bash     # \u56e0\u4e3a\u53ea\u7f16\u8bd1\uff0c\u6ca1\u6709\u5b89\u88c5\uff0c\u6240\u4ee5\u6ca1\u6709install\u6587\u4ef6\u5939\n\n# \u9996\u5148\u8fd0\u884c cartographer\n    roslaunch cartographer_ros cartoForRplidar.launch\n\n# \u7136\u540e\u8fd0\u884c rplidar_ros\n    roslaunch rplidar_ros test_rplidar.launch<\/code><\/pre>\n<p>&emsp;&emsp;\u51fa\u56fe\uff1a<br \/>\n<img src=\"http:\/\/47.103.123.166\/wp-content\/uploads\/2021\/11\/post-157-619a3f8d87158.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h2>3 ROS2\u4e0b\u6d4b\u8bd5SLAM<\/h2>\n<h3>3.1 cartographer \u5b89\u88c5\u6d4b\u8bd5\uff08\u5931\u8d25\uff09<\/h3>\n<p>&emsp;&emsp;ROS2_Foxy\u4e0a\u4f7f\u7528cartographer\u6709\u4e24\u79cd\u65b9\u5f0f\uff1a\u547d\u4ee4\u884c\u5b89\u88c5\u548c\u6e90\u7801\u7f16\u8bd1\u5b89\u88c5\u3002<\/p>\n<pre><code class=\"language-powershell\"># \u547d\u4ee4\u884c\n    sudo apt install ros-foxy-cartographer\n#\u6e90\u7801\n    https:\/\/github.com\/cartographer-project\/cartographer_ros\/tree\/ros2-dashing<\/code><\/pre>\n<p>&emsp;&emsp;cartographer\u4f3c\u4e4e\u6b63\u5728\u5f00\u53d1\u4e00\u4e2a\u65b0\u7248\u672c\uff08<a href=\"https:\/\/github.com\/cartographer-project\/cartographer_ros\/issues\/1536\">\u70b9\u51fb\u4e86\u89e3\u8be6\u60c5<\/a>\uff09\uff0c\u76f4\u5230\u53bb\u5e7411\u6708\u8fd8\u5728\u5f00\u53d1\u4e2d&#8230;<\/p>\n<h3>3.2 rplidar_ros \u79fb\u690d\u5230 ROS2<\/h3>\n<p>&emsp;&emsp;\u53c2\u8003\u8fd9\u91cc\uff1a<a href=\"https:\/\/blog.csdn.net\/qq825255961\/article\/details\/104761194\/\">ros2\u6fc0\u5149\u96f7\u8fbe\u529f\u80fd\u5305\u79fb\u690d\uff08\u601d\u5c9arplidar A1\uff09<\/a> \u3002<br \/>\n1\u3001<a href=\"https:\/\/github.com\/DylanLN\/oryxbot_ws-ros2.git\">\u4e0b\u8f7d\u4ee3\u7801<\/a>\uff0c\u7136\u540e\u627e\u5230rplidar_ros\u7684\u5305\uff0c\u5e76\u62f7\u8d1d\u5230\u81ea\u5df1\u7684\u5de5\u4f5c\u7a7a\u95f4\u7684src\u76ee\u5f55\u4e0b<\/p>\n<pre><code class=\"language-powershell\">    git clone https:\/\/github.com\/DylanLN\/oryxbot_ws-ros2.git<\/code><\/pre>\n<p>2\u3001\u7f16\u8bd1\u3001\u6d4b\u8bd5<\/p>\n<pre><code class=\"language-powershell\"># \u7f16\u8bd1\n    . \/opt\/ros\/foxy\/setup.bash\n    colcon build\n\n# \u8dd1\u4e00\u8dd1\n    . install\/setup.bash\n    sudo chmod 777 \/dev\/ttyUSB0 \n    ros2 launch rplidar_ros rplidar_A1.launch.py    <\/code><\/pre>\n<p>&emsp;&emsp;\u53e6\u5f00\u4e00\u4e2a\u7ec8\u7aef\uff0c\u8dd1rviz2<\/p>\n<pre><code class=\"language-powershell\">    . \/opt\/ros\/foxy\/setup.bash\n    . install\/setup.bash\n    rviz2<\/code><\/pre>\n<p>&emsp;&emsp;\u51fa\u56fe\uff1a<br \/>\n<img src=\"http:\/\/47.103.123.166\/wp-content\/uploads\/2021\/11\/post-157-619a3f8dcac75.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/>\u56e0\u4e3acartographer\u8fd8\u6ca1\u6709\u6210\u529f\u5728ROS2\u4e0a\u8dd1\uff0c\u6240\u4ee5\u8fd9\u91cc\u6ca1\u6709\u8dd1slam\uff0c\u7b49\u540e\u9762\u5b98\u65b9\u79fb\u690d\u5b8c\u5584\u4e86\uff0c\u518d\u770b\u770b\u3002<\/p>\n<h2>4 ROS1 &amp; ROS2\u4e0b\u6d4b\u8bd5SLAM<\/h2>\n<p>&emsp;&emsp;\u597d\u4e86\uff0c\u73b0\u5728\u5230\u4e86\u5148\u5bfc\u7bc7\uff0c\u6700\u5947\u602a\u7684\u4e00\u90e8\u5206\u4e86\uff1a\u5728ROS2\u4e0a\u8dd1rplidar_ros\uff0c\u7136\u540e\u901a\u8fc7ros1_bridge\u628a\u6fc0\u5149\u6570\u636e\u4f20\u5230ROS1\uff0c\u7136\u540e\u5728ROS1\u4e2d\u8fd0\u884ccartographer\u8fdb\u884c\u5efa\u56fe\u3002<br \/>\n&emsp;&emsp;\u6309\u7167\u524d\u8a00\u4e2d\u8bb2\u8ff0\u7684\u5185\u5bb9\uff0c\u6fc0\u5149\u96f7\u8fbe\u4e0ecartographer\u90fd\u5728ROS1\u73af\u5883\u4e0b\uff0c\u8f66\u8f86\u4e0e\u7535\u8111\u4e4b\u95f4\u5e94\u8be5\u4f20\u9012\u7684\u662f\u5355\u8f66slam\u5efa\u56fe\u7684\u7ed3\u679c\uff0c\u90a3\u4e48\u8fd9\u91cc\u4e3a\u4ec0\u4e48\u628a\u6fc0\u5149\u96f7\u8fbe\u653e\u5230ROS2\u4e0b\uff0c\u7136\u540e\u5728ROS1\u4e2d\u63a5\u6536ROS2\u7684\u6fc0\u5149\u6570\u636e\u8fdb\u884c\u5efa\u56fe\u5462\uff1f\u56e0\u4e3a\u4e0d\u60f3\u5728\u6811\u8393\u6d3e\u4e0a\uff0c\u88c5\u5b8cROS2\uff0c\u518d\u88c5ROS1\uff0c\u6240\u4ee5\u8f66\u5b50\u7684\u4f5c\u7528\u53d8\u6210\u4e86\u53ea\u91c7\u96c6\u6fc0\u5149\u6570\u636e\uff0c\u7136\u540e\u901a\u8fc7ROS2\u4f20\u5230\u7535\u8111\uff0c\u7535\u8111\u7aef\u5728ROS1\u4e2d\u8fdb\u884cSLAM\u3002<br \/>\n&emsp;&emsp;\u4e5f\u8bb8\uff0c\u540e\u9762\u4f1a\u5c1d\u8bd5\u5728\u6811\u8393\u6d3e\u4e0a\u518d\u88c5\u4e2aROS1\uff1f<\/p>\n<h3>4.1  ros1_bridge<\/h3>\n<p>1\u3001\u5c0f\u524d\u8a00<br \/>\n&emsp;&emsp;ros1_bridge\u662fROS2\u4e3a\u4e86\u517c\u5bb9ROS1\u800c\u5f00\u53d1\u7684\u5305\uff0c\u8fd9\u91cc\u4ecb\u7ecd\u4e0b\u57fa\u672c\u7684\u4f7f\u7528\u65b9\u6cd5\uff0c\u7136\u540e\u5c06\u5176\u5e94\u7528\u5230\u9879\u76ee\u4e2d\u3002\u5b66\u4e60\u5c31\u662f\u770b\u770b<a href=\"https:\/\/github.com\/ros2\/ros1_bridge\/blob\/master\/README.md\">\u5b98\u7f51\u6559\u7a0b<\/a>\uff0c\u8fd9\u4e2a\u5305\u7684\u5b89\u88c5\u8fc7\u7a0b\u53ef\u4ee5\u547d\u4ee4\u884c\u76f4\u63a5\u5b89\u88c5\u3002<\/p>\n<pre><code class=\"language-powershell\">    sudo apt install ros-foxy-ros1-bridge<\/code><\/pre>\n<p>2\u3001\u8dd1\u4e00\u8dd1\uff08\u8981\u5f00\u56db\u4e2a\u7ec8\u7aef\uff09<\/p>\n<pre><code class=\"language-powershell\"># Shell A (ROS 1 only):\n. \/opt\/ros\/noetic\/setup.bash\nroscore\n\n# Shell B (ROS 1 + ROS 2):\n# Source ROS 1 first:\n. \/opt\/ros\/noetic\/setup.bash\n# Source ROS 2 next:\n. \/opt\/ros\/foxy\/setup.bash\nexport ROS_MASTER_URI=http:\/\/localhost:11311    # \u8fd9\u91cc\u6839\u636e Shell A \u5b9e\u9645\u60c5\u51b5\u6539\nros2 run ros1_bridge dynamic_bridge\n\n# Shell C:\n. \/opt\/ros\/noetic\/setup.bash\nrosrun rospy_tutorials talker\n\n# Shell D:\n. \/opt\/ros\/foxy\/setup.bash\nros2 run demo_nodes_cpp listener<\/code><\/pre>\n<p>&emsp;&emsp;\u51fa\u56fe\uff1a<br \/>\n<img src=\"http:\/\/47.103.123.166\/wp-content\/uploads\/2021\/11\/post-157-619a3f8e2c49c.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h3>4.2  ROS1 &amp; ROS2 &amp; cartographer<\/h3>\n<p>1\u3001ROS1\u4e0b\uff0c\u8dd1cartographer\uff0c\u8fd9\u4f1a\u540c\u65f6\u542f\u52a8roscore<\/p>\n<pre><code class=\"language-powershell\">    . \/opt\/ros\/noetic\/setup.bash\n    . devel_isolated\/setup.bash\n    roslaunch cartographer_ros cartoForRplidar.launch<\/code><\/pre>\n<p><img src=\"http:\/\/47.103.123.166\/wp-content\/uploads\/2021\/11\/post-157-619a3f8ec2598.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/>2\u3001ROS1\u548cROS2\u4e0b\uff0c\u8dd1ros1_bridge<\/p>\n<pre><code class=\"language-powershell\">    . \/opt\/ros\/noetic\/setup.bash\n    . \/opt\/ros\/foxy\/setup.bash\n    export ROS_MASTER_URI=http:\/\/localhost:11311    \n    ros2 run ros1_bridge dynamic_bridge<\/code><\/pre>\n<p>3\u3001ROS2\u4e0b\uff0c\u8dd1rplidar_ros<\/p>\n<pre><code class=\"language-powershell\">    . \/opt\/ros\/foxy\/setup.bash\n    . install\/setup.bash\n    ros2 launch rplidar_ros2 rplidar_A1.launch.py\n    # \u8fd9\u4e2a\u5305\u540d\u53ebrplidar_ros2\u800c\u975erplidar_ros\uff0c\u662f\u56e0\u4e3a\u4fee\u6539\u4e86launch\u6587\u4ef6\uff0c'frame_id': 'laser'\n    # \u4ee5\u4fbf\u4e8e\u5728\u4e0b\u4e00\u90e8\u5206\u4e0ecartographer\u7684frame\u5bf9\u63a5\u6b63\u786e<\/code><\/pre>\n<p>4\u3001\u51fa\u56fe<br \/>\n&emsp;&emsp;\u53ef\u4ee5\u770b\u5230\uff0cROS1\u7684cartographer\u62ff\u5230\u6570\u636e\u6b63\u5728\u5efa\u56fe\uff0c\u7b2c\u4e8c\u5f20\u56fe\u53f3\u4e0a\u89d2\u7684\u7ec8\u7aef\u663e\u793a\u4e24\u4e2aROS\u6b63\u5728\u901a\u8fc7\u8bdd\u9898sensor_msgs\/LaserScan\u901a\u4fe1\u3002<br \/>\n<img src=\"http:\/\/47.103.123.166\/wp-content\/uploads\/2021\/11\/post-157-619a3f8f2979b.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><img src=\"http:\/\/47.103.123.166\/wp-content\/uploads\/2021\/11\/post-157-619a3f8f87f6b.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h2>\u53c2\u8003<\/h2>\n<p>1\u3001<a href=\"https:\/\/blog.csdn.net\/weixin_41349117\/article\/details\/100551517\">ROS(Kinetic\u548cMelodic)\u4e0b\u4f7f\u7528cartographer\u8e29\u5751\u8bb0\u5f55\u548c\u90e8\u5206\u8c23\u8a00\u7ec8\u7ed3<\/a><br \/>\n2\u3001<a href=\"https:\/\/blog.csdn.net\/qq_23225073\/article\/details\/102825545\">catkin_make, cmake, catkin build\u533a\u522b<\/a><br \/>\n3\u3001<a href=\"https:\/\/blog.csdn.net\/qq825255961\/article\/details\/104761194\/\">ros2\u6fc0\u5149\u96f7\u8fbe\u529f\u80fd\u5305\u79fb\u690d\uff08\u601d\u5c9arplidar A1\uff09<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&emsp;&emsp;\u8fd9\u7bc7\u6587\u7ae0\u7684\u6574\u4f53\u76ee\u7684\u662f\u5728\u591a\u4e2a\u8f66\u4e0a\u8dd1slam\uff0c\u901a\u8fc7ROS2_Foxy\u5c06\u5730\u56fe\u96c6\u4e2d\u5230\u4e00\u4e2a\u7535\u8111\u4e0b\uff0c\u7136\u540e\u62fc\u63a5\u6210\u4e00\u5f20\u5730\u56fe\u3002 &emsp;&emsp;\u4e00\u5f00\u59cb\u7684\u60f3\u6cd5\u662f\u8f66\u4e0a\u7528ROS2\u8dd1SLAM\uff0c\u7531\u4e8e\u5404\u5927\u5f00\u6e90SLAM\u7b97\u6cd5\u5bf9ROS2\u4e0d\u652f\u6301\u6216\u8005\u652f\u6301\u4e0d\u5b8c\u5584\uff08\u53c8\u56e0\u4e3a\u61d2 \u80fd\u529b\u4e0d\u591f\uff0c\u4e0d\u80fd\u628a\u4ee3\u7801\u4eceROS1\u79fb\u690d\u5230ROS2\uff09\uff0c\u56e0\u800c\uff0c\u4f7f\u7528ROS1\u8dd1SLAM\uff0c\u7136\u540e\u901a\u8fc7ROS2\u7684\u5305ros1_bridge\u5728\u5404\u8f66\u4e0e\u7535\u8111\u4e4b\u95f4\u4f20\u9012\u6570\u636e\uff0c\u4ece\u800c\u5b9e\u73b0\u6b64\u9879\u76ee\u3002 &emsp;&emsp;\u5728\u5f15\u5165ros1_bridge\u4e4b\u524d\uff0c\u5148\u5199\u4e00\u5199\u5728ROS1\u4e0a\u8dd1\u5f00\u6e90SLAM\uff0c\u4ee5\u53ca\u5728ROS2\u4e0a\u8dd1\u5f00\u6e90SLAM\u7684\u4e00\u4e9b\u8fc7\u7a0b\u3002 &emsp;&emsp;\u56e0\u4e3a\u6ca1\u505a\u5b8c \u5185\u5bb9\u8f83\u591a\uff0c\u6240\u4ee5\u5206\u4e86\u51e0\u4e2a\u90e8\u5206\u6765\u5199\uff0c\u8fd9\u4e00\u7bc7\u662f\u63a2\u7d22\u53ef\u884c\u6027\u7684\u3002 1 \u73af\u5883\u51c6\u5907 \u8bbe\u5907 \u5904\u7406\u5668 \u7cfb\u7edf ROS1\u7248\u672c ROS2\u7248\u672c \u7535\u8111 amd64_\u9177\u777fi7 5500U_\u5185\u5b588GB Ubuntu 20.04 LTS Noetic Foxy \u8f66 arm64_\u6811\u8393\u6d3e4B_\u5185\u5b584GB Ubuntu mate 20.04 LTS &#8211; Foxy &emsp;&emsp;\u6fc0\u5149\u96f7\u8fbe\u4f7f\u7528\u601d\u5c9aRPLidarA1\uff0c\u7531\u4e8e\u8fd9\u4e2a\u96f7\u8fbe\u9891\u7387\u8f83\u4f4e\uff0c\u56e0\u6b64\u5f00\u6e90SLAM\u9009\u62e9cartographer\u3002\u6ca1\u6709\u9009\u62e9Hector\u7684\u539f\u56e0\u9664\u4e86RPLidarA1\u626b\u63cf\u9891\u7387\u592a\u4f4e\uff0c\u7528Hector\u6548\u679c\u4e0d\u7406\u60f3\u5916\uff0cHector\u5b98\u65b9\u6ca1\u6709\u7ed9ROS2\u7684\u7248\u672c\uff0c\u81ea\u5df1\u79fb\u690d\u592a\u8d39\u65f6\u95f4\u3002 2 ROS1\u4e0b\u6d4b\u8bd5SLAM 2.1 cartographer \u6e90\u7801\u6d4b\u8bd5 &emsp;&emsp;\u53c2\u8003\u5b98\u65b9\u6587\u6863\uff1ahttps:\/\/google-cartographer-ros.readthedocs.io\/en\/latest\/compilation.html \u3002 # \u5b89\u88c5\u5de5\u5177 sudo apt-get update sudo apt-get install -y python3-wstool python3-rosdep ninja-build stow # \u4e0b\u8f7d\u6e90\u7801 mkdir catkin_ws cd [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4],"tags":[],"_links":{"self":[{"href":"http:\/\/47.103.123.166\/index.php?rest_route=\/wp\/v2\/posts\/157"}],"collection":[{"href":"http:\/\/47.103.123.166\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/47.103.123.166\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/47.103.123.166\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/47.103.123.166\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=157"}],"version-history":[{"count":1,"href":"http:\/\/47.103.123.166\/index.php?rest_route=\/wp\/v2\/posts\/157\/revisions"}],"predecessor-version":[{"id":158,"href":"http:\/\/47.103.123.166\/index.php?rest_route=\/wp\/v2\/posts\/157\/revisions\/158"}],"wp:attachment":[{"href":"http:\/\/47.103.123.166\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=157"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/47.103.123.166\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=157"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/47.103.123.166\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=157"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}