一、安装Cartographer

  1. 首先安装ubuntu对应的ROS内核版本(如:Noetic、Melodic、Lunar等版本,注意:要和ubuntu的版本对应)。

ros对应不同的ubuntu版本有不同的版本名字:

ubuntu16.04对应ros-kinetic;

ubuntu18.04对应ros-melodic;

ubuntu20.04对应ros-noetic。

如在Ubuntu20.04上,要安装ros应该用:

sudo apt-get install ros-noetic-desktop-full

参考:https://blog.csdn.net/qaqlalala/article/details/127818168

  1. 再安装cartographer_ros

参考:

(1)官网:https://google-cartographer-ros.readthedocs.io/en/latest/compilation.html#building-installation

(2)保姆级别的安装:https://blog.csdn.net/m0_45805756/article/details/126309855

(3)常见的update错误解决方法:https://blog.csdn.net/Kenny_GuanHua/article/details/116845781

注意:我的cartographer_ros安装目录是google_ws

二、安装Turtlebot3

  1. 安装Turtlebot3

将Turtlebot3安装在cartographer_ros安装目录中,这是因为方便环境变量设置,否则,可能找不到cartographer算法模块。

turtlebot3_simulations:包含了更丰富的仿真文件(如一些rviz和gazebo的launch文件)

turtlebot3:功能包中继承了了TurtleBot3的机器人文件、SLAM和导航功能包、遥控功能包和bringup功能包等

turtlebot3包下载地址:https://github.com/ROBOTIS-GIT/turtlebot3

turtlebot3_simulations包下载地址:https://github.com/ROBOTIS-GIT/turtlebot3_simulations

turtlebot3 wiki简介:http://wiki.ros.org/turtlebot3

主要是两种型号:Burger 和 Waffle Pi:

参数如下:

cd ~/google_ws/src
git clone https://github.com/ROBOTIS-GIT/turtlebot3.git
git clone https://github.com/ROBOTIS-GIT/turtlebot3_simulations.git
cd ..
rosdep install --from-paths src --ignore-src --rosdistro=${ROS_DISTRO} -y
catkin_make_isolated
  1. 启动Turtlebot3仿真环境

首先启动一个Terminal窗口

(1)设置环境变量:source ~/google_ws/devel_isolated/setup.bash

(2)设置默认的 TURTLEBOT3_MODEL。turtlebot3有三个版本,burger、waffle和waffle_pi,其中waffle_pi版本中配备的传感器最全面。

(3)运行。turtlebot3_gazebo是turtlebot3的包名,turtlebot3_stage_4.launch是要运行的文件名称。

这一步的作用是先创建好一个需要仿真的模拟环境。

source ~/google_ws/devel_isolated/setup.bash
export TURTLEBOT3_MODEL=burger
roslaunch turtlebot3_gazebo turtlebot3_stage_4.launch
  1. 开始建图

再新建一个Terminal窗口,运行:

source ~/google_ws/devel_isolated/setup.bash
export TURTLEBOT3_MODEL=burger
roslaunch turtlebot3_slam turtlebot3_slam.launch slam_methods:=cartographer configuration_basename:=turtlebot3_lds_2d_gazebo.lua

这一步的功能是调用相应的建图算法对上一步的环境进行建图。(slam_methods:=cartographer指定SLAM建图算法是cartographer)

每一个terminal都要运行:source ~/google_ws/devel_isolated/setup.bash和export TURTLEBOT3_MODEL=burger,设置环境变量。

source ~/google_ws/devel_isolated/setup.bash
export TURTLEBOT3_MODEL=burger

turtlebot3_slam是turtlebot3的包名;slam_methods:=cartographer是设置slam的算法(支持gmapping, cartographer, hector, karto, frontier_exploration这几个slam算法);configuration_basename:=turtlebot3_lds_2d_gazebo.lua可以自行设置lua配置文件。

这一步中会自动调用rviz,对建图过程进行可视化。

  1. 手动控制建图

再新建一个Terminal窗口,运行如下命令打开键盘控制界面,可以通过键盘控制机器人进行移动,从而完成建图。

source ~/google_ws/devel_isolated/setup.bash
export TURTLEBOT3_MODEL=burger
roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch

通过键盘进行控制小车的运行。

w和x:线速度;

a和d:角速度;

s:停止

三、分析

(1)首先看看roslaunch命令行:

roslaunch turtlebot3_gazebo turtlebot3_stage_4.launch

这句话是说:调用turtlebot3_gazebo功能包中的turtlebot3_stage_4.launch文件来启动仿真环境。

我们来看看配置文件turtlebot3_stage_4.launch:

目录:google_ws/src/turtlebot3_simulations/turtlebot3_gazebo/launch/turtlebot3_stage_4.launch

<launch><arg name="model" default="$(env TURTLEBOT3_MODEL)" doc="model type [burger, waffle, waffle_pi]"/><arg name="x_pos" default="-0.7"/><arg name="y_pos" default="0.0"/><arg name="z_pos" default="0.0"/><!--首先启动一个empty_world.launch(空的world),这个world的参数有:world_name、pauseduse_sim_time等--><include file="$(find gazebo_ros)/launch/empty_world.launch"><arg name="world_name" value="$(find turtlebot3_gazebo)/worlds/turtlebot3_stage_4.world"/><arg name="paused" value="false"/><arg name="use_sim_time" value="true"/><arg name="gui" value="true"/><arg name="headless" value="false"/><arg name="debug" value="false"/></include>  <param name="robot_description" command="$(find xacro)/xacro --inorder $(find turtlebot3_description)/urdf/turtlebot3_$(arg model).urdf.xacro" /><!--最后启动一个节点spawn_urdf,属于gazebo_ros包,类型是spawn_model,传入上述的arg参数--><node name="spawn_urdf" pkg="gazebo_ros" type="spawn_model" args="-urdf -model turtlebot3_burger -x $(arg x_pos) -y $(arg y_pos) -z $(arg z_pos) -param robot_description" /></launch>

(2)再来看看命令:

source ~/google_ws/devel_isolated/setup.bash

export TURTLEBOT3_MODEL=burger

roslaunch turtlebot3_slam turtlebot3_slam.launch slam_methods:=cartographer configuration_basename:=turtlebot3_lds_2d_gazebo.lua

这个命令是:调用turtlebot3_slam功能包中的turtlebot3_slam.launch文件启动建图功能,参数是:slam_methods和configuration_basename。

a.首先我们来看看配置文件turtlebot3_lds_2d_gazebo.lua。

目录:google_ws/src/turtlebot3/turtlebot3_slam/config/turtlebot3_lds_2d_gazebo.lua

#turtlebot3_lds_2d_gazebo.lua-- Copyright 2016 The Cartographer Authors
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
--      http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.include "map_builder.lua"
include "trajectory_builder.lua"options = {map_builder = MAP_BUILDER,trajectory_builder = TRAJECTORY_BUILDER,map_frame = "map", --地图坐标系的名字tracking_frame = "base_footprint", -- imu_link, If you are using gazebo, use 'base_footprint' (libgazebo_ros_imu's bug)published_frame = "odom", -- 设置为tf树最顶端的坐标系名称,设置完成后cartographer会发布map->published_frame的坐标系odom_frame = "odom", -- 里程计的坐标系名字provide_odom_frame = false, -- 是否提供odom的tf, 如果为true,则tf树为map->odom->footprint,如果为false,则tf树为map->published_framepublish_frame_projected_to_2d = false, -- 是否将坐标系投影到平面上,一般为falseuse_odometry = true, --是否使用里程计,如果使用要求一定要有odom的tfuse_nav_sat = false, --是否使用gpsuse_landmarks = false, --是否使用landmark num_laser_scans = 1, --是否使用单线激光数据并设置订阅topic的数量num_multi_echo_laser_scans = 0, --是否使用multi_echo_laser_scans并设置订阅topic的数量num_subdivisions_per_laser_scan = 1, --1帧数据被分成几次处理,一般为1num_point_clouds = 0, -- 是否使用16线点云数据lookup_transform_timeout_sec = 0.2,-- 查找tf时的超时时间submap_publish_period_sec = 0.3,-- 发布数据的时间间隔pose_publish_period_sec = 5e-3,trajectory_publish_period_sec = 30e-3,-- 传感器数据的采样频率rangefinder_sampling_ratio = 1., --设置为0.1则表示每10帧数据使用1帧数据odometry_sampling_ratio = 1.,fixed_frame_pose_sampling_ratio = 1.,imu_sampling_ratio = 1.,landmarks_sampling_ratio = 1.,
}--修改之前5个lua文件参数可以使用这种方式MAP_BUILDER.use_trajectory_builder_2d = true -- 进行2D建图TRAJECTORY_BUILDER_2D.min_range = 0.1 --激光的最近有效距离
TRAJECTORY_BUILDER_2D.max_range = 3.5 --激光最远的有效距离
TRAJECTORY_BUILDER_2D.missing_data_ray_length = 3. --无效激光数据设置距离为该数值
TRAJECTORY_BUILDER_2D.use_imu_data = true --是否使用imu数据
TRAJECTORY_BUILDER_2D.use_online_correlative_scan_matching = true
TRAJECTORY_BUILDER_2D.motion_filter.max_angle_radians = math.rad(0.1)POSE_GRAPH.constraint_builder.min_score = 0.65
POSE_GRAPH.constraint_builder.global_localization_min_score = 0.7return options

b.我们再来看看启动文件

目录:google_ws/src/turtlebot3/turtlebot3_slam/launch/turtlebot3_slam.launch

<!-- turtlebot3_slam.launch -->
<launch><!-- Arguments --><!-- 自己可以设置模型的名称,如:burger, waffle, waffle_pi,一般通过export TURTLEBOT3_MODEL=burger来设置 --><arg name="model" default="$(env TURTLEBOT3_MODEL)" doc="model type [burger, waffle, waffle_pi]"/><!-- 自己可以设置slam算法 --><arg name="slam_methods" default="gmapping" doc="slam type [gmapping, cartographer, hector, karto, frontier_exploration]"/><!-- 配置文件的路径,默认是turtlebot3_lds_2d.lua,但是该参数在命令行中被指定为:turtlebot3_lds_2d_gazebo.lua --><arg name="configuration_basename" default="turtlebot3_lds_2d.lua"/><!-- true:表示默认启动rviz --><arg name="open_rviz" default="true"/><!-- TurtleBot3 --><!-- 启动TurtleBot3包中robot的外形配置文件 --><include file="$(find turtlebot3_bringup)/launch/turtlebot3_remote.launch"><arg name="model" value="$(arg model)" /></include><!-- SLAM: Gmapping, Cartographer, Hector, Karto, Frontier_exploration, RTAB-Map --><!-- 启动TurtleBot3的算法配置文件 --><include file="$(find turtlebot3_slam)/launch/turtlebot3_$(arg slam_methods).launch"><arg name="model" value="$(arg model)"/><arg name="configuration_basename" value="$(arg configuration_basename)"/></include><!-- rviz --><!-- 启动vriz配置文件 --><group if="$(arg open_rviz)"> <node pkg="rviz" type="rviz" name="rviz" required="true"args="-d $(find turtlebot3_slam)/rviz/turtlebot3_$(arg slam_methods).rviz"/></group>
</launch>

c.我们看看TurtleBot3包中robot的外形配置文件turtlebot3_remote.launch

google_ws/src/turtlebot3/turtlebot3_slam/turtlebot3_bringup/launch/turtlebot3_remote.launch

<launch><arg name="model" default="$(env TURTLEBOT3_MODEL)" doc="model type [burger, waffle, waffle_pi]"/><!-- 多机协同,默认为空 --><arg name="multi_robot_name" default=""/><!-- 使用include函数将description.launch.xml文件包含进来 --><include file="$(find turtlebot3_bringup)/launch/includes/description.launch.xml"><arg name="model" value="$(arg model)" /></include><node pkg="robot_state_publisher" type="robot_state_publisher" name="robot_state_publisher"><param name="publish_frequency" type="double" value="50.0" /><param name="tf_prefix" value="$(arg multi_robot_name)"/></node>
</launch>

d.我们看看description.launch.xml文件

目录:google_ws/src/turtlebot3/turtlebot3_slam/turtlebot3_bringup/launch/includes/description.launch.xml

<launch><arg name="model"/><!--使用xacro类型的文件来描述robot的外形,并用xacro命令进行解析,最后形成urdf类型文件,方便gazebo识别--><!--urdf描述语言不能进行逻辑判断等高级操作,而xacro类型文件支持高级语法,如变量定义、逻辑判断--><arg name="urdf_file" default="$(find xacro)/xacro --inorder '$(find turtlebot3_description)/urdf/turtlebot3_$(arg model).urdf.xacro'" /><param name="robot_description" command="$(arg urdf_file)" />
</launch>

f.最后我们看看我们看看turtlebot3_$(arg model).urdf.xacro文件,由于model我们通过export TURTLEBOT3_MODEL=burger命令设置为burger,所以,该文件是:turtlebot3_burger.urdf.xacro

目录:google_ws/src/turtlebot3/turtlebot3_description/urdf/turtlebot3_burger.urdf.xacro

注意base_link和base_footprint的区别:

base_link是固定在机器人本体上的坐标系,通常选择机器人腰部。

base_footprint表示机器人base_link原点在地面上的投影,区别base_link之处是其“z”坐标不同。

一般为了模型不陷入地面,base_footprint的“z”坐标比base_link高。

<?xml version="1.0" ?>
<robot name="turtlebot3_burger" xmlns:xacro="http://ros.org/wiki/xacro"><xacro:include filename="$(find turtlebot3_description)/urdf/common_properties.xacro"/><xacro:include filename="$(find turtlebot3_description)/urdf/turtlebot3_burger.gazebo.xacro"/><link name="base_footprint"/><!--设置joint(关节名为base_joint),将base_link连接到base_footprint上面--><joint name="base_joint" type="fixed"><parent link="base_footprint"/><child link="base_link"/><!--相对于base_footprint坐标系,base_link在base_footprint上方0.01米处,没有旋转--><origin xyz="0.0 0.0 0.010" rpy="0 0 0"/></joint><link name="base_link"><visual><origin xyz="-0.032 0 0.0" rpy="0 0 0"/><geometry><mesh filename="package://turtlebot3_description/meshes/bases/burger_base.stl" scale="0.001 0.001 0.001"/></geometry><material name="light_black"/></visual><collision><origin xyz="-0.032 0 0.070" rpy="0 0 0"/><geometry><box size="0.140 0.140 0.143"/></geometry></collision><inertial><origin xyz="0 0 0" rpy="0 0 0"/><mass value="8.2573504e-01"/><inertia ixx="2.2124416e-03" ixy="-1.2294101e-05" ixz="3.4938785e-05"iyy="2.1193702e-03" iyz="-5.0120904e-06"izz="2.0064271e-03" /></inertial></link><joint name="wheel_left_joint" type="continuous"><parent link="base_link"/><child link="wheel_left_link"/><origin xyz="0.0 0.08 0.023" rpy="-1.57 0 0"/><axis xyz="0 0 1"/></joint><link name="wheel_left_link"><visual><origin xyz="0 0 0" rpy="1.57 0 0"/><geometry><mesh filename="package://turtlebot3_description/meshes/wheels/left_tire.stl" scale="0.001 0.001 0.001"/></geometry><material name="dark"/></visual><collision><origin xyz="0 0 0" rpy="0 0 0"/><geometry><cylinder length="0.018" radius="0.033"/></geometry></collision><inertial><origin xyz="0 0 0" /><mass value="2.8498940e-02" /><inertia ixx="1.1175580e-05" ixy="-4.2369783e-11" ixz="-5.9381719e-09"iyy="1.1192413e-05" iyz="-1.4400107e-11"izz="2.0712558e-05" /></inertial></link><joint name="wheel_right_joint" type="continuous"><parent link="base_link"/><child link="wheel_right_link"/><origin xyz="0.0 -0.080 0.023" rpy="-1.57 0 0"/><axis xyz="0 0 1"/></joint><link name="wheel_right_link"><visual><origin xyz="0 0 0" rpy="1.57 0 0"/><geometry><mesh filename="package://turtlebot3_description/meshes/wheels/right_tire.stl" scale="0.001 0.001 0.001"/></geometry><material name="dark"/></visual><collision><origin xyz="0 0 0" rpy="0 0 0"/><geometry><cylinder length="0.018" radius="0.033"/></geometry></collision><inertial><origin xyz="0 0 0" /><mass value="2.8498940e-02" /><inertia ixx="1.1175580e-05" ixy="-4.2369783e-11" ixz="-5.9381719e-09"iyy="1.1192413e-05" iyz="-1.4400107e-11"izz="2.0712558e-05" /></inertial></link><joint name="caster_back_joint" type="fixed"><parent link="base_link"/><child link="caster_back_link"/><origin xyz="-0.081 0 -0.004" rpy="-1.57 0 0"/></joint><link name="caster_back_link"><collision><origin xyz="0 0.001 0" rpy="0 0 0"/><geometry><box size="0.030 0.009 0.020"/></geometry></collision><inertial><origin xyz="0 0 0" /><mass value="0.005" /><inertia ixx="0.001" ixy="0.0" ixz="0.0"iyy="0.001" iyz="0.0"izz="0.001" /></inertial></link><joint name="imu_joint" type="fixed"><parent link="base_link"/><child link="imu_link"/><origin xyz="-0.032 0 0.068" rpy="0 0 0"/></joint><link name="imu_link"/><joint name="scan_joint" type="fixed"><parent link="base_link"/><child link="base_scan"/><origin xyz="-0.032 0 0.172" rpy="0 0 0"/></joint><!--Laser link的配置--><link name="base_scan"><visual><origin xyz="0 0 0.0" rpy="0 0 0"/><geometry><mesh filename="package://turtlebot3_description/meshes/sensors/lds.stl" scale="0.001 0.001 0.001"/></geometry><material name="dark"/></visual><collision><origin xyz="0.015 0 -0.0065" rpy="0 0 0"/><geometry><cylinder length="0.0315" radius="0.055"/></geometry></collision><inertial><mass value="0.114" /><origin xyz="0 0 0" /><inertia ixx="0.001" ixy="0.0" ixz="0.0"iyy="0.001" iyz="0.0"izz="0.001" /></inertial></link></robot>

参考文献

https://blog.csdn.net/m0_71775106/article/details/128303582

Turtlebot3+Cartographer配置运行相关推荐

  1. cartographer 配置过程

    cartographer 配置过程 1. 安装 系统配置: ubuntu16.04 ROS Kinetic Intel® Core™ i7-9700K CPU @ 3.60GHz × 8 64位操作系 ...

  2. 用Nginx如何配置运行无扩展名PHP文件或非.PHP扩展名文件

    用Nginx如何配置运行无扩展名PHP文件或非.PHP扩展名文件 使用Apache + PHP 很容易做到运行无扩展名的PHP文件. 在Nginx中能做到吗?是可以的. 只需将nginx.conf文件 ...

  3. Docker在Linux上运行NetCore系列(一)配置运行DotNetCore控制台

    Docker在Linux上运行NetCore系列(一)配置运行DotNetCore控制台 原文:Docker在Linux上运行NetCore系列(一)配置运行DotNetCore控制台 转发请注明此文 ...

  4. 3d建模电脑配置要求_专业3d动画建模需要什么配置 运行Blender的电脑配置推荐

    今天我们为大家带来一款专业级的3D动画建模配置单.在我以前推荐的一些关于3D设计渲染的配置中,大都是强调cpu的性能,而这款配置却有所不同.随着nvidia RTX光追和DLSS深度学习超级采样技术的 ...

  5. 【语义地图】Ubuntu18.04 Suma++代码配置运行

    自己的课题涉及到语义场景构建,最近配置运行了Suma++,结合Suma和RangeNet++,此项目基于RangeNet++代码的配置运行 Suma++源码地址:https://github.com/ ...

  6. 获取有道词典在线翻译结果 及 Windows下配置运行ASP

    <% '说明:该程序用于远程调用有道翻译接口中译英,http://fanyi.youdao.com/openapi.do?keyfrom=localhost&key=1204607085 ...

  7. R语言七天入门教程一:配置运行环境

    R语言七天入门教程一:配置运行环境 一.R语言介绍 1.R语言是什么? 参考:R语言教程-R语言介绍 R 语言是为数学研究工作者设计的一种数学编程语言,主要用于统计分析.绘图.数据挖掘.R语言有丰富的 ...

  8. MongoDB的安装、配置运行 与 Robomongo的下载安装

    MongoDB的安装.配置运行和特点 Robomongo的下载与安装 特点 MongoDB 的设计目标是高性能.可扩展.易部署.易使用,存储数据非常方便.其主要功能特性如下: (1)面向集合存储,容易 ...

  9. shell脚本配置运行python程序,小技巧之 Linux 软连接的使用

    shell脚本配置运行python程序,小技巧之 Linux 软连接的使用 实验室的多位博士会在同一台机器上跑python程序,主流的跑程序的方法有两种 使用sh脚本配置路径和程序 直接激活conda ...

最新文章

  1. matlab神经网络 时间序列,请问吧里有大神做过MATLAB时间序列神经网络(NARX)吗?...
  2. OpenCV 双边滤波
  3. android studio入门
  4. ORM + 数据库链接池
  5. 谷歌终于推出TensorFlow Lite,实现在移动设备端部署AI
  6. Bash:把粘贴板上的内容拷贝的文件中。
  7. go语言中顺序查找的案例--人名查找
  8. java代码获取系统时间相差8小时
  9. TCP/UDP Socket调试工具(SocketTool) v4
  10. pc机收集信息cpu\配置\网络信息
  11. 基于php的小区物业管理系统
  12. IIC通信协议总结(详细说明完整过程)
  13. 计算机操作系统(一)——计算机操作系统的概念
  14. canvas绘制五角星
  15. xcode 中生成和打包 ipa文件的方法和步骤
  16. Java经典for循环题目:兔子繁殖问题
  17. SPSS软件的数据分析与GDP和人口老龄化的预测
  18. Chino with Triangle ( 西工大程序设计创新实践基地春季选拔赛)树形dp
  19. vue前端生成二维码,实现扫码下载功能
  20. FlatBuffers vs Protocol Buffers

热门文章

  1. 现在的企业为什么难做,流量、市场、消费者在哪里?
  2. python文件编译与pyc反编译
  3. NR PUSCH(五) DMRS
  4. 图解二进制,带你揭开二进制的神秘面纱
  5. HTML知识点总结(二)
  6. 在JavaScript中时间戳
  7. java hashset 时间复杂度_Java 集合时间复杂度
  8. Modbus通信协议(Modbus protocol)
  9. JavaEE在线测试系统
  10. win10家庭版升级专业版操作步骤