Skip to content
Open
Show file tree
Hide file tree
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
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,48 @@
# ros_gmapping_movebase
This ROS package provides three behaviors for controlling a simulated mobile robot using gmapping and movebase rospackages.
You can get to know more about the detatils of the source code using the [documentation](https://aliy98.github.io/ros-gmapping-movebase/) provided for this rospackage.

## Installing and runnning
Here is the instruction for using the package:
```bashscript
$ mkdir -p catkin_ws/src
```
```bashscript
$ cd catkin_ws/src
$ git clone https://github.com/aliy98/ros_gmapping_movebase
```
```bashscript
$ git clone -b documentation https://github.com/aliy98/ros_gmapping_movebase
```
```bashscript
$ cd ..
```
```bashscript
$ source /opt/ros/<distro>/setup.bash
```
```bashscript
$ catkin_make
```
```bashscript
$ source devel/setup.bash
```
```bashscript
$ sudo apt install konsole
```
```bashscript
$ roslaunch final_assignment simulation_gmapping.launch
```
in order to run the movebase node, open a new terminal in the same directory and run the following commands:
```bashscript
$ source devel/setup.bash
```
```bashscript
$ roslaunch final_assignment move_base.launch
```
For initializing the master node also, in a new terminal run the following commands:
```bashscript
$ source devel/setup.bash
```
```bashscript
$ roslaunch final_assignment master.launch
```
then you can choose robot's behaviour by inputing the corresponding number
Expand Down
Binary file added _build/doctrees/environment.pickle
Binary file not shown.
Binary file added _build/doctrees/index.doctree
Binary file not shown.
Binary file added _build/doctrees/master.doctree
Binary file not shown.
Binary file added _build/doctrees/movebase_client.doctree
Binary file not shown.
Binary file added _build/doctrees/nodes.doctree
Binary file not shown.
Binary file added _build/doctrees/scripts.doctree
Binary file not shown.
Binary file added _build/doctrees/teleop.doctree
Binary file not shown.
Binary file added _build/doctrees/usage.doctree
Binary file not shown.
4 changes: 4 additions & 0 deletions _build/html/.buildinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 6ad3ad01d5e7b17344fc4e9846b9f860
tags: 645f666f9bcd5a90fca523b33c5a78b7
Empty file added _build/html/.nojekyll
Empty file.
Binary file added _build/html/_images/preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
99 changes: 99 additions & 0 deletions _build/html/_modules/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Overview: module code &mdash; ros_gmapping_movebase 1.0 documentation</title>
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../_static/graphviz.css" type="text/css" />
<!--[if lt IE 9]>
<script src="../_static/js/html5shiv.min.js"></script>
<![endif]-->

<script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<script src="../_static/js/theme.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
</head>

<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="../index.html" class="icon icon-home"> ros_gmapping_movebase
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../usage.html">Usage</a></li>
<li class="toctree-l1"><a class="reference internal" href="../scripts.html">Scripts</a></li>
</ul>

</div>
</div>
</nav>

<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../index.html">ros_gmapping_movebase</a>
</nav>

<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="Page navigation">
<ul class="wy-breadcrumbs">
<li><a href="../index.html" class="icon icon-home"></a> &raquo;</li>
<li>Overview: module code</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">

<h1>All modules for which code is available</h1>
<ul><li><a href="scripts/master.html">scripts.master</a></li>
<li><a href="scripts/movebase_client.html">scripts.movebase_client</a></li>
<li><a href="scripts/teleop_twist_keyboard.html">scripts.teleop_twist_keyboard</a></li>
</ul>

</div>
</div>
<footer>

<hr/>

<div role="contentinfo">
<p>&#169; Copyright 2022, Ali Yousefi.</p>
</div>

Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.


</footer>
</div>
</div>
</section>
</div>
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>

</body>
</html>
173 changes: 173 additions & 0 deletions _build/html/_modules/scripts/master.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>scripts.master &mdash; ros_gmapping_movebase 1.0 documentation</title>
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" />
<!--[if lt IE 9]>
<script src="../../_static/js/html5shiv.min.js"></script>
<![endif]-->

<script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
<script src="../../_static/jquery.js"></script>
<script src="../../_static/underscore.js"></script>
<script src="../../_static/doctools.js"></script>
<script src="../../_static/js/theme.js"></script>
<link rel="index" title="Index" href="../../genindex.html" />
<link rel="search" title="Search" href="../../search.html" />
</head>

<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="../../index.html" class="icon icon-home"> ros_gmapping_movebase
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../usage.html">Usage</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../scripts.html">Scripts</a></li>
</ul>

</div>
</div>
</nav>

<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../../index.html">ros_gmapping_movebase</a>
</nav>

<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="Page navigation">
<ul class="wy-breadcrumbs">
<li><a href="../../index.html" class="icon icon-home"></a> &raquo;</li>
<li><a href="../index.html">Module code</a> &raquo;</li>
<li>scripts.master</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">

<h1>Source code for scripts.master</h1><div class="highlight"><pre>
<span></span><span class="ch">#!/usr/bin/env python</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd">.. module:: master</span>
<span class="sd"> :platform: Unix</span>
<span class="sd"> :synopsis: the main python script in ros_gmapping_movebase package</span>

<span class="sd">.. moduleauthor:: Ali Yousefi &lt;aliyousef98@outlook.com&gt;</span>

<span class="sd">Uses rosparam:</span>
<span class="sd"> /robot_state</span>

<span class="sd">This is the main python script in ros_gmapping_movebase package, it gets user request to choose robot</span>
<span class="sd">behaviour using robot_state rosparam. Everytime you choose a behaviour for robot you should continue</span>
<span class="sd">the process in the corresponding node shell, and then if you want to change the robot behaviour again</span>
<span class="sd">you must come back to this shell.</span>

<span class="sd">&quot;&quot;&quot;</span>

<span class="kn">import</span> <span class="nn">rospy</span>
<span class="kn">from</span> <span class="nn">std_srvs.srv</span> <span class="kn">import</span> <span class="o">*</span>
<span class="kn">import</span> <span class="nn">os</span>

<span class="c1"># 1 - movebase client</span>
<span class="c1"># 2 - teleop keyboard</span>
<span class="c1"># 3 - assisted teleop</span>

<div class="viewcode-block" id="change_state"><a class="viewcode-back" href="../../master.html#scripts.master.change_state">[docs]</a><span class="k">def</span> <span class="nf">change_state</span><span class="p">():</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Function for changing robot&#39;s behaviour and sending the corresponding response to other three nodes</span>

<span class="sd"> robot_state can have valuse from 0 to 3 with the following rules:</span>

<span class="sd"> 0: waiting for user to choose robot behaviour</span>

<span class="sd"> 1: movebase client </span>

<span class="sd"> 2: teleop twist keyboard without obstacle avoidance</span>

<span class="sd"> 3: teleop twist keyboard with obstacle avoidance</span>

<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">os</span><span class="o">.</span><span class="n">system</span><span class="p">(</span><span class="s1">&#39;cls||clear&#39;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;** MASTER NODE **</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">)</span>
<span class="c1"># gets robot behaviour from user</span>
<span class="n">x</span> <span class="o">=</span> <span class="nb">input</span><span class="p">(</span><span class="s1">&#39;&#39;&#39;Choose robot behaviour:</span>
<span class="s1"> 1. reach point(x,y) autonomously</span>
<span class="s1"> 2. drive with keyboard</span>
<span class="s1"> 3. drive robot with collision avoidance</span><span class="se">\n</span><span class="s1"></span>
<span class="s1"> input: &#39;&#39;&#39;</span><span class="p">)</span>

<span class="k">if</span> <span class="n">x</span> <span class="o">==</span> <span class="s1">&#39;1&#39;</span><span class="p">:</span>
<span class="n">rospy</span><span class="o">.</span><span class="n">set_param</span><span class="p">(</span><span class="s1">&#39;robot_state&#39;</span><span class="p">,</span> <span class="s1">&#39;1&#39;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">state changed: movebase client&quot;</span><span class="p">)</span>
<span class="k">elif</span> <span class="n">x</span> <span class="o">==</span> <span class="s1">&#39;2&#39;</span><span class="p">:</span>
<span class="n">rospy</span><span class="o">.</span><span class="n">set_param</span><span class="p">(</span><span class="s1">&#39;robot_state&#39;</span><span class="p">,</span> <span class="s1">&#39;2&#39;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">state changed: teleop keyboard&quot;</span><span class="p">)</span>
<span class="k">elif</span> <span class="n">x</span> <span class="o">==</span> <span class="s1">&#39;3&#39;</span><span class="p">:</span>
<span class="n">rospy</span><span class="o">.</span><span class="n">set_param</span><span class="p">(</span><span class="s1">&#39;robot_state&#39;</span><span class="p">,</span> <span class="s1">&#39;3&#39;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">state changed: assisted teleop&quot;</span><span class="p">)</span></div>


<span class="k">def</span> <span class="nf">main</span><span class="p">():</span>
<span class="n">rospy</span><span class="o">.</span><span class="n">init_node</span><span class="p">(</span><span class="s1">&#39;master&#39;</span><span class="p">)</span>
<span class="n">rospy</span><span class="o">.</span><span class="n">set_param</span><span class="p">(</span><span class="s1">&#39;robot_state&#39;</span><span class="p">,</span> <span class="s1">&#39;0&#39;</span><span class="p">)</span>
<span class="n">rate</span> <span class="o">=</span> <span class="n">rospy</span><span class="o">.</span><span class="n">Rate</span><span class="p">(</span><span class="mi">20</span><span class="p">)</span>
<span class="k">while</span> <span class="ow">not</span> <span class="n">rospy</span><span class="o">.</span><span class="n">is_shutdown</span><span class="p">():</span>
<span class="k">if</span> <span class="n">rospy</span><span class="o">.</span><span class="n">get_param</span><span class="p">(</span><span class="s1">&#39;robot_state&#39;</span><span class="p">)</span><span class="o">==</span><span class="s1">&#39;0&#39;</span><span class="p">:</span>
<span class="n">change_state</span><span class="p">()</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">rate</span><span class="o">.</span><span class="n">sleep</span><span class="p">()</span>
<span class="k">continue</span>
<span class="n">rate</span><span class="o">.</span><span class="n">sleep</span><span class="p">()</span>

<span class="c1"># If the python node is executed as main process (sourced directly)</span>
<span class="k">if</span> <span class="vm">__name__</span> <span class="o">==</span> <span class="s1">&#39;__main__&#39;</span><span class="p">:</span>
<span class="n">main</span><span class="p">()</span>
</pre></div>

</div>
</div>
<footer>

<hr/>

<div role="contentinfo">
<p>&#169; Copyright 2022, Ali Yousefi.</p>
</div>

Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.


</footer>
</div>
</div>
</section>
</div>
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>

</body>
</html>
Loading