sudrag / line_follower_turtlebot

A repo created to simulate a line following turtlebot in Gazebo environment using ROS
MIT License
72 stars 35 forks source link

Line Follower TurtleBot

Build Status License: MIT Coverage Status

Overview

This project uses ROS to demonstrate a simple line following Turtlebot in a simulated Gazebo environment . Line following is an easy to design application for a robot as all it requires is a robot with a camera and some tape. However this can be used to create complex high level models using multiple robots and multiple paths. This can be implemented in industries and shop floors for material handling and distribution. These robots can be made to follow these paths in periodic intervals autonomously and hence automate the function of the entire material handling system in a highly cost efficient way. This is the project that has been proposed to ACME robotics and the process has been explained below

Procedure

Initially a Gazebo world was created containing some walls and a path for the turtlebot to follow. The world can be seen below:

alt text

This project primarily uses two main classes , one for the detection of the line and one for the navigation of the robot to do so. The detection class first and foremost obtains an image from the turtlebot in the simulated environment , performs color thresholding , masking and centroid detection to communicate the required direction for the robot to move in . The direction is determined based on the position of the centroid of the detected line with respect to the turtlebot .The direction commands are either move forward , turn left , turn right or search i.e spin on spot when no line is detected. The direction published by the detection class is used by the navigation class to publish velocity commands to the Turtlebot and successfully follow the line throughout the environment. Once the Turtlebot reaches the end of the path , it searches for a line to follow again by rotating on spot. This way it finds the same path it took and returns back to the starting point. This way travelling between these points is performed continuously and can be extremely beneficial in any material handling applications. The procedure follows the algorithm shown in the picture below.

alt text

The output from the turtlebot camera can be seen below. The image processing is performed from the images obtained from this camera.

alt text

Dependencies

To build

To build the project run the following steps in a terminal:

To run

To run the project and see the output in the gazebo world , execute the following steps:

cd ~/catkin_ws
source devel/setup.bash
roslaunch line_follower_turtlebot lf.launch

The output generated will be launched in gazebo with one image viewer window similar to this:

The terminal's output will be similar to:

[ INFO] [1513353661.823250213, 2031.649000000]: Turning Left

...

Known Issues and Future Improvements

Demonstration

The entire project has been demonstrated using a video and a presenation which can be accessed from below :

Project slides
Demonstration video

Testing

To run the gtest based unit tests for the classes in the project , run the following commands:

cd ~/catkin_ws
cp -R ~/catkin_ws/src/line_follower_turtlebot/test_images/ ~/catkin_ws/devel/lib/line_follower_turtlebot/
source devel/setup.bash
catkin_make run_tests

There are 10 unit tests overall which should all pass when you follow the commands mentioned above

Testing code coverage

Due to issues with getting coveralls working for this project, a section has been added discussing the code coverage of the tests and how to generate the lcov files to view the percentage of the code covered.

The current coverage for the project is 98.4% . To generate the html file to view the coverage for this code , run the following steps:

cd ~/catkin_ws/build
lcov --directory . --capture --output-file coverage.info
sudo lcov --remove coverage.info '/opt/*' '/usr/*' '*/devel/*' '*test_*' '*_test*' --output-file coverage.info
lcov --list coverage.info

This will list the coverage info in the terminal. For better visualization it is recommended to generate an html file using :

genhtml coverage.info --output-directory out

This will generate a file called index.html in a folder called out in the building directory which contains all the coverage details.

If the coverage.info shows a lesser coverage it is due to the fact that some folders were not removed from the coverage. The files in those folder are used in the workspace but are not tested because they are not user written.

Doxygen Documentation

To generate Doxygen Documentation in HTML and LaTEX, execute the following steps:

cd ~/catkin_ws/src/line_follower_turtlebot
mkdir <documentation_folder>
cd <documentation_folder>
doxygen -g <config_file_name>

Make the following changes inside the configuration file

PROJECT_NAME = 'your project name'
INPUT = ../src ../include ../test

The doxygen documents can be generated in the current directory (unless output directory is modified in the config file) using:

doxygen <config_file_name>

To view the documents easily, access the index.html file with your browser. For further information on the Doxygen Documentation: Doxygen generation

The Doxygen files for this project have already been generated and can be viewed here.

Bag File

This creates a bag file called BagFile.bag in the .ros folder. To view the file:

cd ~/.ros
rosbag info BagFile.bag

This displays the information about the bag file and looks like:

alt text

This repository contains a sample bag file that is 5 seconds long in the Results folder. To view the info of the bag file , type these steps in a terminal :

cd ~/catkin_ws/src/line_follower_turtlebot/Results
rosbag info Bagfile.bag

Solo-Iterative Processes

This project was designed and developed using the SIP process. Tasks were organized after being identified and split up. The Product backlog,Iteration backlog , Time log and Defect log were recorded for each task and can be viewed in the link below:
SIP

Sprint Planning

This project is also developed with sprint planning notes and reviews which can be found in the link below:
Sprint Planning

About the creator

Sudarshan Raghunathan , Graduate student in Robotics at University of Maryland , College Park. Currently working as a Research Assistant at the Medical Robotics Lab at UMD

License

This project uses the MIT license as shown below:

MIT License

Copyright (c) 2017 Sudarshan Raghunathan

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.