This simulation is based on turtlebot3 website. This simulation will keep moving by generating random position and orientation. To avoid unreachable area, a checking method is used. It will check whether the goal position is free or not. This robot will also go to the next step if the robot does not reach the desire position in 30s. It can also prevent the robot to do an undefined behavior.
- ros-noetic-dekstop installed.
- Install some packages required below
sudo apt-get install ros-noetic-gazebo-ros ros-noetic-gazebo-plugins ros-noetic-move-base-* ros-noetic-actionlib-* ros-noetic-gazebo-ros-pkgs ros-noetic-gazebo-ros-control ros-noetic-dwa-local-planner ros-noetic-slam-karto ros-noetic-map-server ros-noetic-amcl python3-catkin-tools
- Clone repository
cd ~
mkdir -p noetic_ws/src && cd noetic_ws/src
git clone https://github.com/labiybafakh/turtlebot3_obstacle_avoidance
- Get turtlebot3 packages to run this reposity, but if it has been installed on system, you can skip it. If vcstool has not been installed, please install it.
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt install curl # if you haven't already installed curl
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install python3-vcstool
cd turtlebot3_obstacle_avoidance
vcs import . < turtlebot3.repos
cd ~/noetic_ws/
catkin build
source devel/setup.bash
to create the map using slam-karto, it can be done by run create_map.launch file.
export TURTLEBOT3_MODEL=burger
roslaunch obstacle_avoidance creating_map.launch
Run turtlebot3_teleop to move the robot by using turtlebot3_teleop_key.launch.
source devel/setup.bash
export TURTLEBOT3_MODEL=burger
roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch
after the whole area has been mapped, teleop can be terminated and save the map by run another launch file.
source devel/setup.bash
roslaunch obstacle_avoidance map_saver.launch
Another shortcut, it also can be also done by changing the path inside the map.yaml file.
image: /home/toys/noetic_ws/src/turtlebot3_obstacle_avoidance/obstacle_avoidance/maps/map.pgm
Make sure that it can be ran like the video below by using 2D Nav Goal tool in RViz. If it is ok, it is better to re-run the launch file, but it also ok to go to the next step.
export TURTLEBOT3_MODEL=burger
source devel/setup.bash
roslaunch obstacle_avoidance simulation.launch
nav-rviz.mp4
It should be run in different terminal.
export TURTLEBOT3_MODEL=burger
source devel/setup.bash
rosrun obstacle_avoidance obastacle_avoidance