Skip to content

Simple, efficient, open-source package for Simultaneous Localization and Mapping in Python, Matlab, Java, and C++

Notifications You must be signed in to change notification settings

MomsFriendlyRobotCompany/breezy_slam

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 

Repository files navigation

BreezySLAM

This repository contains everything you need to start working with Lidar -based SLAM in Python. (There is also support for Matlab, C++, and Java; however, because of the popularity of Python for this kind of work, I am no longer updating the code for those languages.) BreezySLAM works with Python 3 on Linux and Mac OS X, and with C++ on Linux and Windows. By using Python C extensions, we were able to get the Python and Matlab versions to run as fast as C++. For maximum efficiency on 32-bit platforms, we use Streaming SIMD extensions (Intel) and NEON (ARMv7) in the compute-intensive part of the code.

BreezySLAM was inspired by the Breezy approach to Graphical User Interfaces developed by my colleague Ken Lambert: an object-oriented Application Programming Interface that is simple enough for beginners to use, but that is efficient enough to scale-up to real world problems; for example, the mapping of an entire floor of a house, shown in the image above-right, made by a BreezySLAM user.

As shown in the following code fragment, the basic API is extremely simple: a constructor that accepts Lidar parameters and the size of the map (pixels) and mapping area (meters); a method for updating with the current scan; a method that returns the current robot position; and a method for retrieving the current map as a byte array.

from breezyslam.algorithms import RMHC_SLAM

lidar = MyLidarModel()

mapbytes = bytearray(800*800)

slam = RMHC_SLAM(lidar, 800, 35) 

while True:

    scan = readLidar()

    slam.update(scan)

    x, y, theta = slam.getpos(scan)

    slam.getmap(mapbytes)

If odometry is available, it can also be passed into the update method.

Installing for Python

The BreezySLAM installation uses the popular distutils approach to installing Python packages, so all you should have to do is download and unzip the file, cd to BreezySLAM/python, and do

sudo python3 setup.py install

For a quick demo, you can then cd to BreezySLAM/examples and do

make pytest

This will generate and display a PGM file showing the map and robot trajctory for the Lidar scan and odometry data in the log file exp2.dat. If you have the Python Imaging Library installed, you can also try the log2png.py script to generate a a PNG file instead.

If you have installed PyRoboViz, you can see a “live” animation by doing

make movie

You can turn off odometry by setting the USE_ODOMETRY parameter at the top of the Makefile to 0 (zero). You can turn off the particle-filter (Monte Carlo position estimation) by commenting-out RANDOM_SEED parameter.

To see what other features are available, do

pydoc3 breezyslam

By using the component classes Map, Scan, and Position and the distanceScanToMap() method, you can develop new algorithms and particle filters of your own.

Testing with the Hokuyo URG04LX

If you're running on Linux, you can install the BreezyLidar package, the OpenCV Python package, and try the urgslam.py example in the examples folder.

Testing with the GetSurreal XV Lidar

BreezySLAM includes Python support for the inexpensive XV Lidar from GetSurreal. To try it out, you'll also need the xvlidar Python package. Once you've installed both packages, you can run the xvslam.py example in the BreezySLAM/examples folder.

Testing with the SLAMTEC RPLidar A1

BreezySLAM also includes partial Python support for the inexpensive RPLidar A1 from SLAMTECH. To try it out, you'll also need the rplidar Python package. Once you've installed that package, you can run the rpslam.py example in the BreezySLAM/examples folder.

Unfortunately, I and several users have had trouble using BreezySLAM with the RPLidar A1. The issues are inconsistent enough that I cannot provide support for this lidar unit if you run into trouble using it with BreezySLAM.

Installing for Matlab

I have run BreezySLAM in Matlab on 64-bit Windows, Linux, and Mac OS X. The matlab directory contains all the code you need, including pre-compiled binaries for all three operating systems. To try it out in Matlab, add this directory to your path, then change to the examples directory and do

  >> logdemo('exp2', 1)

If you modify the source code or want to build the binary for a different OS, you can change to the matlab directory and do

  >> make

For making the binary on Windows I found these instructions very helpful when I ran into trouble.

Installing for C++

Just cd to BreezySLAM/cpp, and do

sudo make install

This will put the libbreezyslam shareable library in your /usr/local/lib directory. If you keep your shared libraries elsewhere, just change the LIBDIR variable at the top of the Makefile. You may also need to add the following line to your ~/.bashrc file:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

For a quick demo, you can then cd to BreezySLAM/examples and do

make cpptest

Again, you'll need to change the LIBDIR variable at the top of the Makefile in this directory as well, if you don't use /usr/local/lib.

Installing for Java

In BreezySLAM/java/edu/wlu/cs/levy/breezyslam/algorithms and BreezySLAM/java/edu/wlu/cs/levy/breezyslam/components, edit the JDKINC variable in the Makefile to reflect where you installed the JDK. Then run make in these directories.

For a quick demo, you can then cd to BreezySLAM/examples and do

make javatest

Notes on Windows installation

Because of the difficulties that I and others have had installing Python extensions on Windows, I am no longer supporting the Python version of this package on Windows. If you want to try it yourself, here are some instructions.

To build and use the C++ library on Windows, I used MinGW. Whatever C++ compiler you use, you'll have to add the location of the .dll file to your PATH environment variable in the Advanced Systems Settings.

Adding new particle filters

Because it is built on top of the CoreSLAM (tinySLAM) code base, BreezySLAM provides a clean separation between the map-building and particle-filtering (Monte Carlo position estimation) components of SLAM. To add a new particle filter, you can subclass breezyslam.algorithms.CoreSLAM or breezyslam.algorithms.SinglePositionSLAM classes, implementing the relevant methods.

Personnel

Suraj Bajracharya, Simon D. Levy, Matt Lubas, Alfredo Rwagaju

Acknowledgments

This work was supported in part by a Commonwealth Research Commercialization Fund grant from the Center for Innovative Technology (CRCF #MF14F-011-MS). We thank Michael Searing of Olin College for his help in debugging and testing this package.

GNU LESSER GENERAL PUBLIC LICENSE

Version 3, 29 June 2007

Copyright (C) 2007 Free Software Foundation, Inc. http://fsf.org/ Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.

This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below.

  1. Additional Definitions.

As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License.

"The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below.

An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library.

A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version".

The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version.

The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work.

  1. Exception to Section 3 of the GNU GPL.

You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL.

  1. Conveying Modified Versions.

If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version:

a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or

b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy.

  1. Object Code Incorporating Material from Library Header Files.

The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following:

a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License.

b) Accompany the object code with a copy of the GNU GPL and this license document.

  1. Combined Works.

You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following:

a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License.

b) Accompany the Combined Work with a copy of the GNU GPL and this license document.

c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document.

d) Do one of the following:

   0) Convey the Minimal Corresponding Source under the terms of this
   License, and the Corresponding Application Code in a form
   suitable for, and under terms that permit, the user to
   recombine or relink the Application with a modified version of
   the Linked Version to produce a modified Combined Work, in the
   manner specified by section 6 of the GNU GPL for conveying
   Corresponding Source.

   1) Use a suitable shared library mechanism for linking with the
   Library.  A suitable mechanism is one that (a) uses at run time
   a copy of the Library already present on the user's computer
   system, and (b) will operate properly with a modified version
   of the Library that is interface-compatible with the Linked
   Version.

e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.)

  1. Combined Libraries.

You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following:

a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License.

b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.

  1. Revised Versions of the GNU Lesser General Public License.

The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.

Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation.

If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.

About

Simple, efficient, open-source package for Simultaneous Localization and Mapping in Python, Matlab, Java, and C++

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published