1.安装依赖
sudo apt-get install ros-kinetic-joy ros-kinetic-teleop-twist-joy ros-kinetic-teleop-twist-keyboard ros-kinetic-laser-proc ros-kinetic-rgbd-launch ros-kinetic-depthimage-to-laserscan ros-kinetic-rosserial-arduino ros-kinetic-rosserial-python ros-kinetic-rosserial-server ros-kinetic-rosserial-client ros-kinetic-rosserial-msgs ros-kinetic-amcl ros-kinetic-map-server ros-kinetic-move-base ros-kinetic-urdf ros-kinetic-xacro ros-kinetic-compressed-image-transport ros-kinetic-rqt-image-view ros-kinetic-gmapping ros-kinetic-navigation ros-kinetic-interactive-markers
2.安装三个包
git clone https://github.com/ROBOTIS-GIT/turtlebot3_msgs.git
git clone https://github.com/ROBOTIS-GIT/turtlebot3.git
git clone https://github.com/ROBOTIS-GIT/turtlebot3_simulations.git
3.编译三个包
cd /src
catkin_make
4.测试
https://www.ncnynl.com/archives/201707/1788.html
注意事项:
1)把simulation里的turtlebot模型拷贝进./gazebo中
2)需要设置model,目前都设置的waffle
5.根据需要更改文件
turtulebot3文件夹下
1)turtlebot3_description中修改turtlebot3_waffle_pi.gazebo.xacro文件,添加ground_truth功能
<gazebo>
<plugin name="ground_truth" filename="libgazebo_ros_p3d.so">
<frameName>map</frameName>
<bodyName>base_footprint</bodyName>
<topicName>ground_truth</topicName>
<updateRate>10.0</updateRate>
</plugin>
</gazebo>
2)turtlebot3_navigation/launch/amcl.launch
设置激光雷达测距范围 <param name="laser_max_range" value="3.5"/>
3)turtlebot3_navigation/launch/move_base.launch
这里主要是修改了地图订阅的话题、cost_map的一些参数
<launch>
<!-- Arguments -->
<arg name="model" default="$(env TURTLEBOT3_MODEL)" doc="model type [burger, waffle, waffle_pi]"/>
<arg name="cmd_vel_topic" default="/cmd_vel" />
<arg name="odom_topic" default="odom" />
<!--设置move_base路径规划用的地图话题 -->
<arg name="map_topic" default="/path_map"/>
<!-- move_base -->
<node pkg="move_base" type="move_base" respawn="false" name="move_base" output="screen">
<!-- 修改cost_map参数 -->
<!-- 用自己设定的layer插件,gloabal、local -->
<rosparam file="$(find turtlebot3_navigation)/param/my_costmap_common_params_$(arg model).yaml" command="load" ns="global_costmap" />
<rosparam file="$(find turtlebot3_navigation)/param/my_costmap_common_params_$(arg model).yaml" command="load" ns="local_costmap" />
<rosparam file="$(find turtlebot3_navigation)/param/my_local_costmap_params.yaml" command="load" />
<rosparam file="$(find turtlebot3_navigation)/param/my_global_costmap_params.yaml" command="load" />
<rosparam file="$(find turtlebot3_navigation)/param/my_move_base_params.yaml" command="load" />
<!-- 用自己设定的全局和局部路径规划 -->
<rosparam file="$(find turtlebot3_navigation)/param/my_dwa_local_planner_params_$(arg model).yaml" command="load" />
<rosparam file="$(find turtlebot3_navigation)/param/my_global_planner_params_$(arg model).yaml" command="load" />
<remap from="cmd_vel" to="$(arg cmd_vel_topic)"/>
<remap from="odom" to="$(arg odom_topic)"/>
<remap from="/map" to="$(arg map_topic)"/>
</node>
</launch>
4)turtlebot3_navigation/launch/turtulebot3_navigation.launch
这里改动:1.两个地图服务器; 2.启动自己修改的move_base
<launch>
<!-- Arguments -->
<arg name="model" default="$(env TURTLEBOT3_MODEL)" doc="model type [burger, waffle, waffle_pi]"/>
<arg name="map_file" default="$(find turtlebot3_navigation)/maps/map_1.yaml"/>
<!-- 两张地图 需要把自己的地图放到maps文件夹里-->
<arg name="map_file_2" default="$(find turtlebot3_navigation)/maps/map_2.yaml"/>
<arg name="open_rviz" default="true"/>
<!-- TurtleBot3 -->
<include file="$(find turtlebot3_bringup)/launch/turtlebot3_remote.launch">
<arg name="model" value="$(arg model)" />
</include>
<!-- Map server -->
<node pkg="map_server" name="map_server" type="map_server" args="$(arg map_file)"/>
<!-- Map server 2 用来加载move_base用来规划路径的地图 -->
<node pkg="map_server" name="map_server_2" type="map_server" args="$(arg map_file_2)">
<remap from="map" to="/path_map"/>
</node>
<!-- move_base -->
<include file="$(find turtlebot3_navigation)/launch/my_move_base.launch">
<arg name="model" value="$(arg model)" />
</include>
<!-- AMCL -->
<include file="$(find turtlebot3_navigation)/launch/amcl.launch"/>
<!-- rviz -->
<group if="$(arg open_rviz)">
<node pkg="rviz" type="rviz" name="rviz" required="true"
args="-d $(find turtlebot3_navigation)/rviz/turtlebot3_navigation.rviz"/>
</group>
</launch>
4)turtlebot3_navigation/params里修改move_base的参数
turtulebot3_simulation文件夹下
1)turtlebot3_gazebo/launch
根据自己需要修改创建仿真环境的launch文件,添加环境、机器人
2)turtlebot3_gazebo/worlds
这个文件夹下放入自己创建的world模型