PythonRobotics A Python Code Collection of Robotic
PythonRobotics A Python Code Collection of Robotic
Abstract
This paper describes an Open Source Software (OSS) project: PythonRobotics[21].
This is a collection of robotics algorithms implemented in the Python programming lan-
guage. The focus of the project is on autonomous navigation, and the goal is for beginners
in robotics to understand the basic ideas behind each algorithm. In this project, the algo-
rithms which are practical and widely used in both academia and industry are selected.
Each sample code is written in Python3 and only depends on some standard modules for
readability and ease of use. It includes intuitive animations to understand the behavior of
the simulation.
1 Introduction
In recent years, autonomous navigation technologies have received huge attention in many
fields. Such fields include, autonomous driving[22], drone flight navigation, and other trans-
portation systems.
An autonomous navigation system is a system that can move to a goal over long periods
of time without any external control by an operator. The system requires a wide range of
technologies: It needs to know where it is (localization), where it is safe (mapping), where
and how to move (path planning), and how to control its motion (path following). The
autonomous system would not work correctly if any of these technologies is missing.
Educational materials are becoming more and more important for future developers to
learn basic autonomous navigation technologies. Because these autonomous technologies
need different technological skill sets such as: linear algebra, statistics, probability theory,
optimization theory, and control theory etc. It needs a lot of time to be familiar with these
c 2018. The copyright of this document resides with its authors.
It may be distributed unchanged freely in print or electronic forms.
2 ARXIV: :1808.10703 [CS.RO] 31 AUG 2018
Figure 1: Left: PythonRobotics Project page, Right: GitHub star history graph using [16]
technological areas. Therefore, good educational resources for learning basic autonomous
navigation technologies are needed. Our project which is described in this paper aims to be
one such resource.
In this paper, an Open Source Software(OSS) project: PythonRobotics[21] is described.
This project provides a code collection of robotics algorithms, especially focusing on au-
tonomous navigation. The principle goal is to provide beginners with the tools necessary
to understand it. It is written in Python[12] under MIT license[7]. It has a lot of simula-
tion animations that shows behaviors of each algorithm. It helps for learners to understand
its fundamental ideas. The readers can find the animations in the project page https:
//atsushisakai.github.io/PythonRobotics/. The left figure in Fig.1 shows
the front image of the project page. All source codes of this project are provided at https:
//github.com/AtsushiSakai/PythonRobotics.
This project was started from Mar. 21 2016 as a self-learning project. It already has over
3000 stars on GitHub, and the right figure in Fig.1 shows the history graph of the star counts
using [16].
This paper is organized as follows: Section 2 reviews the related works. The philoso-
phy of this project is presented in Section 3. The repository structure and some technical
backgrounds and simulation results are provided in Section 4. Conclusions are drawn and
some future works are presented in Section 5. Section 6 acknowledges for contributors and
supporters.
2 Related works
There are already some great educational materials for learning autonomous navigation tech-
nologies.
S. Thrun et al. wrote a great textbook "Probabilistic robotics" which is a bible of localiza-
tion, mapping, and Simultaneous Localization And Mapping (SLAM) for mobile robotics[31].
E. Frazzoli et al. wrote a great survey paper about path planning and control techniques for
autonomous driving [25]. G. Bautista et al. wrote a survey paper focusing on path plan-
ning for automated vehicles[22]. J. Levinson wrote an overview paper about systems and
algorithms towards fully autonomous driving[24].
These papers help readers to learn state-of-the-art autonomous navigation technologies.
However, it might be difficult for beginners to understand the basic ideas of the technologies
and algorithms because the papers don’t include implementation examples.
ARXIV: :1808.10703 [CS.RO] 31 AUG 2018 3
Many universities provide great classes to learn robotics and share their lecture notes. For
example, University of Freiburg provides an introduction class to mobile robotics[2]. Swiss
Federal Institute of Technology in Zurich (ETH in Zurich) also provides a class about au-
tonomous mobile robot[3] and robotics programming with Robot Operating System(ROS)[4].
Like the academic literature referenced, these lecture notes also help readers to learn
autonomous navigation technologies. However, it might be also difficult for beginners of
robotics to understand the basic ideas of the technologies and algorithms if the reader is
not a student of the class, because these lecture notes doesn’t include actual implementation
examples of robotics algorithms.
Robot Operating System (ROS) is a middle-ware for robotics software development[13][28].
ROS initially released in 2007, and it has become the defacto standard platform in robotics
software development. ROS includes basic navigation software such as the Adaptive Monte
Carlo Localization (AMCL) package and the local path planner based on Dynamic Win-
dow Approach, etc[14]. Many autonomous navigation packages using ROS are also open-
sourced.
ROS packages can also be useful to learn autonomous navigation algorithms, however
the documentation might be inconsistent and it can be difficult to find implementation details
about the algorithms used. ROS packages are usually written in C++ because the focus is
computational efficiency and not readability, which makes learning from the code harder.
Udacity Inc, which is an online learning company founded by S. Thrun, et al, is pro-
viding great online courses for autonomous navigation and autonomous driving [17]. These
courses provide not only technical lectures, but also programming homework using Python.
This leads to a great learning strategy for beginners to understand the technical background
required for autonomous systems.
The PythonRobotics project seeks to extend Udacity’s approach by giving beginners the
necessary tools to understand and make further study into the methods of autonomous navi-
gation. The details of concepts of this OSS project will be described in the next section.
3 Philosophy
In this section, the philosophy of this project is described. The PythonRobotics project is
based on three main philosophies. Each philosophy will be discussed separately in this
4 ARXIV: :1808.10703 [CS.RO] 31 AUG 2018
Grid mapping with 2D ray casting 2D object clustering with k-means algorithm
Figure 3: Mapping simulation results
section.
3.1 Readability
The first philosophy is that the code has to be easy to read. If the code is not easy to read,
it would be difficult to achieve our goal of allowing beginners to understand the algorithms.
Python[12] programming language is adopted in this project. Python has great libraries for
matrix operation, mathematical and scientific operation, and visualization, which makes code
more readable because such operations don’t need to be re-implemented. Having the core
Python packages allows the user to focus on the algorithms, rather than the implementations.
3.2 Practicality
The second philosophy is that implemented algorithms have to be practical and widely used
in both academia and industry. We believe learning these algorithms will be useful in many
applications. For example, Kalman filters and particle filter for localization, grid mapping
for mapping, dynamic programming based approaches and sampling based approaches for
path planning, and optimal control based approach for path tracking. These algorithms are
implemented in this project.
These modules are OSS and can also be used for free. This repository software doesn’t
depend on any commercial software.
4 Repository structure
In this section, the brief repository structure is described.
There are five directories, each one corresponding to a different technical category in
autonomous navigation: localization, mapping, SLAM, path planning, and path tracking.
There is one sub-directory per algorithm, which has a sample code implementing and testing
the algorithm. In the following subsections, some algorithms and some simulation examples
in each category are described.
4.1 Localization
Localization is the ability of a robot to know its position and orientation with sensors such
as Global Navigation Satellite System:GNSS etc. In localization, Bayesian filters such as
Kalman filters, histogram filter, and particle filter are widely used[31]. Fig.2 shows localiza-
tion simulations using histogram filter and particle filter.
4.2 Mapping
Mapping is the ability of a robot to understand its surroundings with external sensors such as
LIDAR and camera. Robots have to recognize the position and shape of obstacles to avoid
them. In mapping, grid mapping and machine learning algorithms are widely used[31][18].
Fig.3 shows mapping simulation results using grid mapping with 2D ray casting and 2D
object clustering with k-means algorithm.
4.3 SLAM
Simultaneous Localization and Mapping (SLAM) is an ability to estimate the pose of a
robot and the map of the environment at the same time. The SLAM problem is hard to
6 ARXIV: :1808.10703 [CS.RO] 31 AUG 2018
solve, because a map is needed for localization and localization is needed for mapping.
In this way, SLAM is often said to be similar to a ‘chicken-and-egg’ problem. Popular
SLAM solution methods include the extended Kalman filter, particle filter, and Fast SLAM
algorithm[31]. Fig.4 shows SLAM simulation results using extended Kalman filter and re-
sults using FastSLAM2.0[31].
If readers are interested in these future projects, contributions are welcome. Readers can
also support this project financially via Patreon[11].
6 Acknowledgments
We appreciate all contributors: Atsushi Sakai[30], Daniel Ingram[23], Joe Dinius[20], Karan
Chala[19], Antonin RAFFIN[29], and Alexis Paques[26]. We also appreciate all robotics
lovers who give a star to this repository in GitHub.
References
[1] Project jupyter. http://jupyter.org/.
[2] Introduction to mobile robotics - ss 2018 - arbeitsgruppe: Autonome intelligente systeme, .
http://ais.informatik.uni-freiburg.de/teaching/ss18/robotics/.
[3] Autonomous mobile robots - spring 2018 autonomous systems lab | eth zurich,
. http://www.asl.ethz.ch/education/lectures/autonomous_mobile_
robots/spring-2018.html.
[4] Programming for robotics - ros âĂŞ robotic systems lab eth zurich, . http://www.rsl.
ethz.ch/education-students/lectures/ros.html.