Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README.md #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 61 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,80 @@
# A Naive Obstacle Avoidance Technique for Turtlebot 3 implemented in ROS
This is a part of my small effort in creating some basic projects implemented in ROS. As I am totally new at learning ROS, feel free to give constructive comments. If you are absolutely new at learning ROS, it might help you. You may use the codes as-is.
The goal of this assignment is to get you started writing software that controls a (simulated) robot using ROS.
In this assignment you will create a ROS node that will drive the robot around with a simple wanderer algorithm, much like a Roomba robot vaccum cleaner. More specifically, the robot should move forward until it reaches an obstacle, then rotate in place until the way ahead is clear, then move forward again and repeat.

## Introduction
This is an obstacle avoidance technique simulated with Turtlebot 3 in Gazebo, ROS. The Turtlebot uses planar laser range-finder to detect obstacles in front as well as 15 degrees left and right from the front. Then based on the obstacle range, it either goes forward with linear velocity or, stops and rotates with angular velocity until it finds an obstacle-free path to go forward again.

## Pre-requisites
- Python 2
- Gazebo (comes pre-installed with ros-desktop-full)
- Python 2
- ubuntu 18.04
- Installed ROS Melodic Morenia.
- [Turtlebot 3 simulation package](https://github.com/ROBOTIS-GIT/turtlebot3_simulations.git)

## Installation
```
cd ~/catkin_ws/src
git clone https://github.com/enansakib/obstacle-avoidance-turtlebot.git
cd ~/catkin_ws
catkin_make
```
## Installation and Create packages
if you installed catkin via apt-get for ROS melodic, excute following comand:
$ source /opt/ros/melodic/setup.bash

## Usage
```
roslaunch turtlebot3_gazebo turtlebot3_world.launch
roslaunch obstacle-avoidance-turtlebot naive_obs_avoid.launch
```
- Create catkin workspace
```
$ mkdir -p ~/catkin_ws/src
$ cd ~/catkin_ws/
$ catkin_make
$ source devel/setup.bash
```
on the catkin workpsace, it should includes three folders:build,devel,src
To make sure your workspace is properly overlayed by the setup script, make sure ROS_PACKAGE_PATH environment variable includes the directory you're in
something should like this:
```
$ echo $ROS_PACKAGE_PATH
/home/youruser/catkin_ws/src:/opt/ros/kinetic/share
```
- Create ROS package
```
$ cd ~/catkin_ws/src
$ catkin_create_pkg wander_bot rospy geometry_msgs sensor_msgs

# build the package on the catkin workspace:
$ cd ~/catkin_ws
$ catkin_make
$ . ~/catkin_ws/devel/setup.bash
```
- Installed turtlebot3_simulations.
```
$ cd ~/catkin_ws/src/
$ git clone https://github.com/ROBOTIS-GIT/turtlebot3_simulations.git
$ cd ~/catkin_ws && catkin_make
$ . ~/catkin_ws/devel/setup.bash
$ export TURTLEBOT3_MODEL=burger
```

## Demo
![demo.gif](demo/demo.gif)
## Usage
```
$ cd ~/catkin_ws
$ catkin_make
$ source devel/setup.bash
$ roslaunch wander_bot wander_bot.launch
```


## Details
The code inside the `src` folder already has necessary comments to understand what's going on.
We define a `obstacle_avoidance_node` which subscribes to `/scan` topic and reads `LaserScan` type messages (because we want to detect obstacles). And it publishes `Twist` type message to `/cmd_vel` topic (because we want to move the robot).

The launch folder includes the wander_bot.launch
The nodes folder includes the wander_bot node code
The src includes the init.py of wander_bot
Also there are CMakeLists.txt,package.xml and setup.py in wander_bot package.
In order to implemete avoiding the obstacles, we need to use rospy, geometry_msgs,and sensor_msgs packages

If you do `rosmsg show LaserScan` and `rosmsg show Twist`, you would see the message formats.
- we are interested in the `float32[] ranges` from the `LaserScan` message which is nothing but a `list` of 359 obstacle distances from the robot (0 degree to 359 degree).
And,
- we are interested in both `linear` and `angular` 3D vectors' x and z values, respectively (to move forward and rotate) from the `Twist` message.

### Note
This is implemented on Ubuntu 18.04, ROS Melodic Morenia.
since the turtlebot3_world.launch file has already includes in wander_bot.launch file. To excute the code, you only need to do following action under terminal considering you have created a catkin workspace and installed all needed packages:
```
$ cd ~/catkin_ws
$ catkin_make
$ source devel/setup.bash
$ roslaunch wander_bot wander_bot.launch
```
Open other terminal and excute `rosmsg show LaserScan` and `rosmsg show Twist`, you would see the message formats

## Reference
1. http://wiki.ros.org/ROS/Tutorials
2. https://github.com/ROBOTIS-GIT/turtlebot3_simulations.git
3. http://gazebosim.org/tutorials?tut=ros_overview
4. https://github.com/enansakib/obstacle-avoidance-turtlebot.git