Giter Site home page Giter Site logo

fazildgr8 / ros_autonomous_slam Goto Github PK

View Code? Open in Web Editor NEW
195.0 5.0 68.0 24.55 MB

ROS package which uses the Navigation Stack to autonomously explore an unknown environment with help of GMAPPING and constructs a map of the explored environment. Finally, a path planning algorithm from the Navigation stack is used in the newly generated map to reach the goal. The Gazebo simulator is used for the simulation of the Turtlebot3 Waffle Pi robot. Various algorithms have been integrated for Autonomously exploring the region and constructing the map with help of the 360-degree Lidar sensor. Different environments can be swapped within launch files to generate a map of the environment.

Home Page: http://mohamedfazil.com

License: MIT License

CMake 6.95% Python 70.24% C++ 22.81%
gazebo-ros gazebo-simulator pathplanning ros-installation gazebo-installation slam autonomous-robots ros gazebo pathplanning-algorithm

ros_autonomous_slam's Introduction

ros_autonomous_slam

This consist of a ROS package which uses the Navigation Stack to autonomously explore an unknown environment with help of GMAPPING and constructs an Map of the explored environment. Finally a pathplanning algorithm from Navugation stack is used in the newly generated map to reach the goal.The Gazebo simulator is used for the simulation of the Turtlebot3 Waffle Pi robot. Various algorithms have been integrated for the Autonomously exploring the region and constructing the map with help of the 360 degree Lidar sensor. Different environments can be swapped within launch files to generate the map of the environment. The current most efficient algorithm used for autonomous exploration is Rapidly Exploring Random Tree (RRT) algorithm . The RRT Algorithm is implemented using the package from rrt_exploration which was created to support the Kobuki robots which I further modified the source files and built it for the Turtlebot3 robots in this package.

You can see the Towards Data Science Story of this Project

RRT_ROBOT

As this repository is to be updated with more bug free codes as I get requests, please keep reporting the issues and following my updates

There are three Main steps to be executed in this project.

  • Step 1 : Place the Robot in the Environment within Gazebo
  • Step 2 : Perform Autonomous exploration of the environment and generate the Map
  • Step 3 : Perform pathplanning and go to goal in the environment

Follow the execution of the different Launch files to acheive the required tasks of each step. (Look below for Project prerequisites and setup)

Step 1 : Place the Robot in the Environment within Gazebo

Set your environment variable to the model robot to be used.

export TURTLEBOT3_MODEL=waffle_pi
source ~/.bashrc

Execute the given launch to open Gazebo with the given world file and place the robot Turtlebot3 Waffle pi model in it.

roslaunch ros_autonomous_slam turtlebot3_world.launch

Keep this process running always and execute other commands in a different terminal.

Step 2 : Perform Autonomous exploration of the environment and generate the Map

roslaunch ros_autonomous_slam autonomous_explorer.launch 

Run the Autonomous Explorer launch file which executes two tasks for us at the same time.

  1. It starts the SLAM node in the Navigation stack with a custom modified RVIZ file to monitor the mapping of the environment.
  2. It simultaneously starts the Autonomous explorer which is a Python based controller to move around the robot grazing all the areas whcih helps the SLAM Node to complete the mapping. The default algorithm used for the exploration is RRT algorithm. I have also created a explorer method which uses Bug Wall following algorithm for exploration which can be tested by adding explorer argument to the launch which takes [RRT,BUG_WALLFOLLOW].

Setting Exploration region for RRT in RVIZ Window (More Details)

The RRT exploration requires a rectangular region around to be defined in the RVIZ window using four points and an starting point for exploration within the known region of the robot. The total five points must be defined in the exact sequence given below using the RVIZ Publish Points option. Source
points_sequence
Monitor the Mapping process in RVIZ window and sit back and relax unitll our robot finishes mapping XD .
RRT Mapping

Once you are satisfied with the constructed map, Save the map.

rosrun map_server map_saver -f my_map

The my_map.pgm and my_map.yaml gets saved in your worspace directory. Move these to files to the package's maps folder (catkin_ws\src\ros_autonomous_slam\maps).Now your new map which is basically a occupancy grid is constructed !
Gmapping
Incase of Autonomous Fail you can manually controll the robot in the environment using the key board with the seperate launch execution given below. You can also manually explore and construct the map like a game.

roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch

Manual Gmapping

Step 3 : Perform pathplanning and go to goal in the environment

We will be using the Navigation stack of the ROS to perform the pathplanning and go to goal using /movebase/goal actions. The given blow launch execution opens up a RVIZ window which shows the Robot location within the previously constructed map.

roslaunch ros_autonomous_slam turtlebot3_navigation.launch

The RVIZ Window shows the robot's local map construction using its Laser sensors with respect to the Global Map previously constructed in Step 2 with help of a cost map.

Setting Goal in the RVIZ Window

  • Firs estimate the initial Pose i.e locating the real robot location with respect to the Map. This can be set in the RVIZ window itself using the 2D Pose Estimate and pointing and dragging the arrow in the current robot's locaion and orientation.
    Nav
  • An GOAL point can be set in the RVIZ window itself using the 2D Nav Goal option which will be available in the top window tab.This allows you to set a goal point in the map within the RVIZ environment, then the robot automaticals performs the path palnning and starts to move in its path.
    Nav

Ros Navigation Stack Tuning Guide

ROS Navigation Stack requires tuning its parameters which works different for different environment types to get the Optimal SLAM and Pathplanning performance.Here is ROS's Navigation Stack parameter tuning guide for Turtlebot3. Turtlebot3 Navigation Parameter Tuning Guide
Nav Nav

Great!!! Now we Have successfully accomplished our SLAM task with help of ROS tools.

Prerequisites and setup for the Project

ROS Installation

I used Ubuntu 18 OS with ros Melodic Version. Check the ROS official documentation for the Installation ROS Installation

Gazebo ROS Installation

The main Gazebo Simulator which is an stand alone application must be installed. Go through the documentation Gazebo Installation. Test the working of Gazebo and its version with

gazebo
which gzserver
which gzclient

After Installing the Gazebo, the Gazebo ROS Package must be installed seperately

sudo apt-get install ros-melodic-gazebo-ros-pkgs ros-melodic-gazebo-ros-control

Replace melodic with your version of ROS everwhere in this tutorial.

Turtlebot3 packages(More Details)

The Turtlebot3 ROS packages can be either downloaded and built from source files in your workspace or else directly installed from the linux terminal. Either way works, I would recommend doing both as it installs all the missing dependencies required automatically.

Direct Installation

source /opt/ros/melodic/setup.bash
sudo apt-get install ros-melodic-turtlebot3-msgs
sudo apt-get install ros-melodic-turtlebot3

Building the packages

cd catkin_ws/src
git clone -b melodic-devel https://github.com/ROBOTIS-GIT/turtlebot3
git clone -b melodic-devel https://github.com/ROBOTIS-GIT/turtlebot3_simulations
cd ..
catkin_make
source /devel/setup.bash

Navigation Stack (More Details)

The Navigation stack can also be downloaded as souce files to your workspace and built.

sudo apt-get install ros-melodic-navigation
cd catkin_ws/src
git clone -b melodic-devel https://github.com/ros-planning/navigation
cd ..
catkin_make
source /devel/setup.bash

ros_autonomous_slam's People

Contributors

fazildgr8 avatar iory avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ros_autonomous_slam's Issues

Launch error

Dear Sir,

(roslaunch ros_autonomus_slam turtlebot3_world.launch ) command can not be executed. The error mentions that it “ is neither a launch file in package“. Instead (roslaunch turtlebot3_gazebo turtlebot3_world.launch) can be executed.

Can you please help me out.

package "ros_autonomous_slam" not found

Hello There
I have downloaded the ROS2 and all the files of this project but when I run the command
ros2 launch ros_autonomous_slam turtlebot3_world.launch
This error occurs : Package 'ros_autonomous_slam' not found: "package 'ros_autonomous_slam' not found, searching: ['/opt/ros/foxy']"

Kindly Help I need this project for my FYP Presentation. Waiting for reply

ImportError: No module named yaml

Hi there,

I am trying to run the program on Noetic. Below is the error. Your help would be much appreciated : )

Traceback (most recent call last):
  File "/home/yuxiang/catkin_ws/src/ros_autonomous_slam/scripts/filter.py", line 5, in <module>
    import rospy
  File "/opt/ros/noetic/lib/python3/dist-packages/rospy/__init__.py", line 47, in <module>
    from std_msgs.msg import Header
  File "/opt/ros/noetic/lib/python3/dist-packages/std_msgs/msg/__init__.py", line 1, in <module>
    from ._Bool import *
  File "/opt/ros/noetic/lib/python3/dist-packages/std_msgs/msg/_Bool.py", line 6, in <module>
    import genpy
  File "/opt/ros/noetic/lib/python3/dist-packages/genpy/__init__.py", line 34, in <module>
    from . message import Message, SerializationError, DeserializationError, MessageException, struct_I
  File "/opt/ros/noetic/lib/python3/dist-packages/genpy/message.py", line 48, in <module>
    import yaml
ImportError: No module named yaml
Traceback (most recent call last):
  File "/home/yuxiang/catkin_ws/src/ros_autonomous_slam/scripts/assigner.py", line 5, in <module>
    import rospy
  File "/opt/ros/noetic/lib/python3/dist-packages/rospy/__init__.py", line 47, in <module>
    from std_msgs.msg import Header
  File "/opt/ros/noetic/lib/python3/dist-packages/std_msgs/msg/__init__.py", line 1, in <module>
    from ._Bool import *
  File "/opt/ros/noetic/lib/python3/dist-packages/std_msgs/msg/_Bool.py", line 6, in <module>
    import genpy
  File "/opt/ros/noetic/lib/python3/dist-packages/genpy/__init__.py", line 34, in <module>
    from . message import Message, SerializationError, DeserializationError, MessageException, struct_I
  File "/opt/ros/noetic/lib/python3/dist-packages/genpy/message.py", line 48, in <module>
    import yaml
ImportError: No module named yaml
[filter-7] process has died [pid 1950541, exit code 1, cmd /home/yuxiang/catkin_ws/src/ros_autonomous_slam/scripts/filter.py __name:=filter __log:=/home/yuxiang/.ros/log/23246bfe-bd9d-11ec-89fe-d993a19ee3f3/filter-7.log].
log file: /home/yuxiang/.ros/log/23246bfe-bd9d-11ec-89fe-d993a19ee3f3/filter-7*.log
[assigner-8] process has died [pid 1950552, exit code 1, cmd /home/yuxiang/catkin_ws/src/ros_autonomous_slam/scripts/assigner.py __name:=assigner __log:=/home/yuxiang/.ros/log/23246bfe-bd9d-11ec-89fe-d993a19ee3f3/assigner-8.log].
log file: /home/yuxiang/.ros/log/23246bfe-bd9d-11ec-89fe-d993a19ee3f3/assigner-8*.log
Warning: TF_REPEATED_DATA ignoring data with redundant timestamp for frame odom at time 24.857000 according to authority unknown_publisher
         at line 278 in /home/yuxiang/catkin_ws/src/geometry2/tf2/src/buffer_core.cpp
Warning: TF_REPEATED_DATA ignoring data with redundant timestamp for frame odom at time 24.857000 according to authority unknown_publisher
         at line 278 in /home/yuxiang/catkin_ws/src/geometry2/tf2/src/buffer_core.cpp
[ WARN] [1650124346.075714987, 24.879000000]: global_costmap: Parameter "plugins" not provided, loading pre-Hydro parameters

Robot not moving forward

After setting everything up as suggested, turtlebot is not moving. It seems RRT node is working fine, but the robot is not receiving any commands on /cmd_vel topic.

Please take a look at below video:
robot-not-moving

Please suggest some changes to make it work.

wall avoidance and multi turtlebot support

Hi Fazil,

I was wondering is it possible to recreate multiple turtlebot3 to run the RRT exploration as shown in the original RRT exploration package?

Also, I managed to get the program running but somehow the turtlebot3 have the tendency to stuck at wall and often requires manual control to unfreeze the robot?
Is there any fine tuning parameters provided? thanks.

Regards,
Billy

Resource not found: turtlebot3_description

prabanjan@ubuntu:$ echo $TURTLEBOT3_MODEL
waffle_pi
prabanjan@ubuntu:
$ source /.bashrc
prabanjan@ubuntu:
$ roslaunch turtlebot3_gazebo turtlebot3_world.launch
... logging to /home/prabanjan/.ros/log/4a5e619c-858b-11ec-856a-000c29ccc10b/roslaunch-ubuntu-7199.log
Checking log directory for disk usage. This may take a while.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

WARNING: Package name "Mine_description" does not follow the naming conventions. It should start with a lower case letter and only contain lower case letters, digits, underscores, and dashes.
WARNING: Package name "Mine_description" does not follow the naming conventions. It should start with a lower case letter and only contain lower case letters, digits, underscores, and dashes.
Resource not found: turtlebot3_description
ROS path [0]=/opt/ros/melodic/share/ros
ROS path [1]=/home/prabanjan/gitbee/src
ROS path [2]=/home/prabanjan/rigbee/src
ROS path [3]=/home/prabanjan/ros/src
ROS path [4]=/home/prabanjan/ADAS/src
ROS path [5]=/home/prabanjan/catkin_ws/src
ROS path [6]=/opt/ros/melodic/share
The traceback for the exception was written to the log file

I am getting this error. How can I resolve?

Configuration to run under Ubuntu 20.04 and ROS noetic

I'm using ROS noetic in a ubuntu docker and I installed the following to successfully run the program.

sudo apt install -y ros-noetic-gmapping ros-noetic-turtlebot3 ros-noetic-turtlebot3-gazebo ros-noetic-dwa-local-planner python3-pip
sudo ln -s /usr/bin/python3 /usr/bin/python
pip install sklearn

Robot stops when it is located at a dead end

I've started with a fresh ubuntu 18, ros melodic version and use ec2 server
with 4 core and 16 memory. when experimenting using this code. it works well. but when the robot is located at a dead-end, it searches in ordinary path and stops that location. If you experienced this situation during the experiment, can you tell me the cause and solution?

And Currently, only global_rrt_detector, local_rrt_detector, assigner, filter files are required to be launched in the launch file, but please let me know why the rrt,rt_single, automatic_rrt files in the node directory are not used and what are available.

Thank you and please reply me.

The TurtleBot3 is working but stuck at wall.

This is my simulation:

https://youtu.be/CY2YYLg8AmI

its working in Noetic and python3. However, it stuck and no warning / error mentioning why its stuck and not follow the path planner provided by RRT.

I checked on the kobuki rrt video and seem its working fine. Why is that? I also notice there is no green line planner refreshing in turtlebot3 as well there is no red branch tree like what they have in kobuki.

https://youtu.be/abGyA3K1lzU?list=PLoGH52eUIHsc1B_xPLL6ogzYxrWy675kr

Where can we improve so turtlebot3 can keep moving and exploring? please kindly help. Thank you.

some missing dependencies

I've started with a fresh ubuntu 18 - ros melodic and follow your steps.
When I launch: roslaunch ros_autonomous_slam autonomous_explorer.launch I get:

NODES
  /
    assigner (ros_autonomous_slam/assigner.py)
    filter (ros_autonomous_slam/filter.py)
    global_detector (ros_autonomous_slam/global_rrt_detector)
    local_detector (ros_autonomous_slam/local_rrt_detector)
    move_base (move_base/move_base)
    robot_state_publisher (robot_state_publisher/robot_state_publisher)
    rviz (rviz/rviz)
    turtlebot3_slam_gmapping (gmapping/slam_gmapping)

ROS_MASTER_URI=http://localhost:11311

process[robot_state_publisher-1]: started with pid [31219]
ERROR: cannot launch node of type [gmapping/slam_gmapping]: gmapping
ROS path [0]=/opt/ros/melodic/share/ros
ROS path [1]=/home/elgarbe/workspace/catkin_ws/src
ROS path [2]=/opt/ros/melodic/share
process[rviz-3]: started with pid [31220]
process[move_base-4]: started with pid [31221]
process[global_detector-5]: started with pid [31227]
process[local_detector-6]: started with pid [31229]
process[filter-7]: started with pid [31239]
process[assigner-8]: started with pid [31241]
[ WARN] [1616723575.614585618, 597.417000000]: Timed out waiting for transform from base_footprint to map to become available before running costmap, tf error: canTransform: target_frame map does not exist.. canTransform returned after 597.417 timeout was 0.1.
Traceback (most recent call last):
  File "/home/elgarbe/workspace/catkin_ws/src/ros_autonomous_slam/scripts/filter.py", line 13, in <module>
    from sklearn.cluster import MeanShift
ImportError: No module named sklearn.cluster
[filter-7] process has died [pid 31239, exit code 1, cmd /home/elgarbe/workspace/catkin_ws/src/ros_autonomous_slam/scripts/filter.py __name:=filter __log:=/home/elgarbe/.ros/log/9fcbdc6e-8dd3-11eb-b7a4-7c67a237b388/filter-7.log].
log file: /home/elgarbe/.ros/log/9fcbdc6e-8dd3-11eb-b7a4-7c67a237b388/filter-7*.log
[ WARN] [1616723588.099024189, 602.422000000]: Timed out waiting for transform from base_footprint to map to become available before running costmap, tf error: canTransform: target_frame map does not exist.. canTransform returned after 0.1 timeout was 0.1.

So I think I need gmapping and sklearn.
What would it be the best way to install them?

Thank!

RRT does not work

Hi, Sir. I have followed your instructions. So far so good until i run the following code:

roslaunch ros_autonomous_slam autonomous_explorer.launch

The rviz window already opened and the publish points is set. However, the RRT does not show up. In terminal terminal there is an error
"ERROR: cannot launch node of type [ros_autonomous_slam/global_rrt_detector]: Cannot locate node of type [global_rrt_detector] in package [ros_autonomous_slam]. Make sure file exists in package path and permission is set to executable (chmod +x)
ERROR: cannot launch node of type [ros_autonomous_slam/local_rrt_detector]: Cannot locate node of type [local_rrt_detector] in package [ros_autonomous_slam]. Make sure file exists in package path and permission is set to executable (chmod +x)"

Please give me some insight, Sir

The robot doesn't move

When I run roslaunch ros_autonomous_slam turtlebot3_world.launch, the terminal issues [filter-7] process has died [pid 6452, exit code 1, cmd /home/amaya/catkin_ws/src/ros_autonomous_slam/scripts/filter.py __name:=filter __log:=/home/amaya/.ros/log/3d4bcb8c-6975-11ee-b407-65d4e7192b1e/filter-7.log]. log file: /home/amaya/.ros/log/3d4bcb8c-6975-11ee-b407-65d4e7192b1e/filter-7*.log [assigner-8] process has died [pid 6454, exit code 1, cmd /home/amaya/catkin_ws/src/ros_autonomous_slam/scripts/assignor.py __name:=assigner __log:=/home/amaya/.ros/log/3d4bcb8c-6975-11ee-b407-65d4e7192b1e/assigner-8.log]. log file: /home/amaya/.ros/log/3d4bcb8c-6975-11ee-b407-65d4e7192b1e/assigner-8*.log, I can't find where this question comes from.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.