Skip to content

Latest commit

 

History

History
82 lines (67 loc) · 4.06 KB

MAP_CONVERSION.md

File metadata and controls

82 lines (67 loc) · 4.06 KB

Converting Maps from Gazebo .world Files to YAML Format

One of the requirements for this project was to provide a demo in Gazebo. Unfortunately there isn't a clean way (that I have found) to create a world in Gazebo and have it work with the costmaps required in the navigation stack.

Overall, what I did was to create a world in Gazebo. I used the building editor to create a simplified maze and then saved it as a .world file. To do the conversion I used a simulated Turtlebot3 and the packaged SLAM algorithm to drive around the map and map it in Rviz.

Unfortunately, this method does require you spend some time driving your robot around using the teleop until you are satisfied with your map.

alt tag

The method I used came from the Turtlebot3 tutorials and worked on Ubuntu 16.04 running ROS Kinetic Kame.

Installing Turtlebot3

  1. The first step in installing Turtlebot3 is to install all of the dependencies. In a terminal window:
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
  1. The next step is to install the Turtlebot3 package
cd ~/catkin_ws/src/
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
cd ~/catkin_ws && catkin_make

Full instructions can be found here.

Running Turtlebot3 SLAM

Once I created my .world file in Gazebo, I modified the turtlebot3_world.launch file to point to the map I had created instead of the default map.

<launch>
  <arg name="model" default="$(env TURTLEBOT3_MODEL)" doc="model type [burger, waffle]"/>
  <arg name="x_pos" default="-2.0"/>
  <arg name="y_pos" default="-0.5"/>
  <arg name="z_pos" default="0.0"/>

  <node pkg="tf" type="static_transform_publisher" name="camera_tf" args="-1.95 -0.55 2.0 -1.58 0 -1.58 /odom /camera_link 100"/>

  <include file="$(find gazebo_ros)/launch/empty_world.launch">
    <arg name="world_name" value="[PATH TO YOUR WORLD FILE HERE]"/>
    <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.py $(find turtlebot3_description)/urdf/turtlebot3_$(arg model).urdf.xacro" />

  <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>

Once you have modified the launch file so that your world is in place, launch the Turtlebot3.

export TURTLEBOT3_MODEL=burger
roslaunch turtlebot3_gazebo turtlebot3_world.launch

To launch the SLAM algorithm:

export TURTLEBOT3_MODEL=burger
roslaunch turtlebot3_slam turtlebot3_slam.launch

To show the RViz visualization:

rosrun rviz rviz -d `rospack find turtlebot3_slam`/rviz/turtlebot3_slam.rviz

To launch the keyboard teleoperation:

roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch

Now you just drive it around until you're happy with how the map looks in RViz. alt tag

Saving Your Map

Open a new terminal window:

rosrun map_server map_saver -f ~/map

Replace ~/map with the filename you would like to save your map as. For example, ~/simple_maze will give you a simple_maze.pgm and simple_maze.yaml.