I wanted to try SLAM, so I tried it as an entrance.
--Installation --Simulation execution
environment ubuntu 20.04
To install ROS-noetic quickly, I think you should use the shell of ROBOTIS.
python
$ git clone https://github.com/ROBOTIS-GIT/robotis_tools.git
$ cd robotis_tools
$ chmod 755 ./install_ros_noetic.sh
$ bash ./install_ros_noetic.sh
If you install it this way, it will be in ~ / .bashrc alias cw='cd ~/catkin_ws' alias cs='cd ~/catkin_ws/src' alias cm='cd ~/catkin_ws && catkin_make' Shortcuts are created for your convenience. I use cs and cm quite a lot.
If you install with the above shell, a workspace called catkin_ws will be created, so skip it. Anyone who installs it any other way will create a workspace, whatever the name (catkin_ws in this case) is.
python
$ mkdir -p ~/catkin_ws/src
$ cd ~/catkin_ws/src
$ catkin_init_workspace
$ cd ~/catkin_ws && catkin_make
Install the package by specifying branch as noetic-dev
python
$ git clone -b noetic-dev https://github.com/ROBOTIS-GIT/turtlebot3_msgs.git
$ git clone -b noetic-dev https://github.com/ROBOTIS-GIT/turtlebot3.git
$ cd ~/catkin_ws && catkin_make
There are three types of turtlebot3, Burger, Waffle, and Waffle Pi, so you have to specify them. Any one is fine, but this time I will choose Burger.
I don't want to hit export TURTLEBOT3_MODEL = burger every time, so I write it to bashrc. (The editor is familiar)
python
$ gedit ~/.bashrc
On the last line
export TURTLEBOT3_MODEL=burger
Write, save and close.
python
$ source ~/.bashrc
It will be reflected in. (If TURTLEBOT3_MODEL gives an unknown error in the future, please do this again)
Installation of turtlebot3 simulator
python
$ cd ~/catkin_ws/src
$ git clone -b noetic-dev https://github.com/ROBOTIS-GIT/turtlebot3_simulations.git
$ cd ~/catkin_ws && catkin_make
python
$ roslaunch turtlebot3_fake turtlebot3_fake.launch
This will launch turtlebot3.
You will be able to operate the keyboard with the following command, please execute "in a new terminal".
python
$ roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch
Close all terminals and start a new one.
Next, run the simulation in Gazebo. RViz is a debugging tool, but Gazebo can simulate it in any environment.
Here, we will simulate in the space where the standard (?) Pole stands.
python
$ roslaunch turtlebot3_gazebo turtlebot3_world.launch
Various environments are available in (turtlebot3_simulations / turtlebot3_gazebo / launch /. Empty space >> turtlebot3_empty_world.launch Inside the house >> turtlebot3_house.launch)
Next, avoid obstacles and let them control automatically
python
$ roslaunch turtlebot3_gazebo turtlebot3_simulation.launch
If you look at gazebo with this, you can see that it is self-controlling.
At this time, if you start RViz, you can visualize how Turtlebot 3 is measuring the distance with a laser.
python
$ roslaunch turtlebot3_gazebo turtlebot3_gazebo_rviz.launch
Close all terminals and start a new one. SLAM performs self-position estimation and map generation at the same time.
Install the SLAM module.
python
$ sudo apt-get install ros-noetic-slam-gmapping
Then start Gazebo again.
python
$ roslaunch turtlebot3_gazebo turtlebot3_world.launch
Once Gazebo starts, run SLAM immediately.
python
$ roslaunch turtlebot3_slam turtlebot3_slam.launch slam_methods:=gmapping
This will start map generation.
To generate a map of this entire space, just run the non-collide program.
python
$ roslaunch turtlebot3_gazebo turtlebot3_simulation.launch
If you leave it for a while, you can create a whole map.
I want to save the map once it is generated. First, install map server.
python
$ sudo apt-get install ros-noetic-map-server
Create the folder you want to save (maps in this case) and save it there.
python
$ mkdir ~/maps
$ cd ~/maps
$ rosrun map_server map_saver
If you get an error: you may have rosrun map_server map_server, the second time saver.
You can display the acquired map by opening map.pgm.
reference How to Launch the TurtleBot3 Simulation With ROS ["ROS Robot Programming Bible"](https://www.amazon.co.jp/ROS%E3%83%AD%E3%83%9C%E3%83%83%E3%83%88%E3%83 % 97% E3% 83% AD% E3% 82% B0% E3% 83% A9% E3% 83% 9F% E3% 83% B3% E3% 82% B0% E3% 83% 90% E3% 82% A4 % E3% 83% 96% E3% 83% AB-% E8% A1% A8-% E5% 85% 81% E3% 80% 93 / dp / 4274221962 / ref = cm_cr_arp_d_pl_foot_top? Ie = UTF8)
Recommended Posts