Skip to main content

Motion planning environment for Sampling-based Planners

Project description

Sampling-Based Motion Planners' Testing Environment

pypi Python version CI Build docs Code style: black License DOI

Sampling-based motion planners' testing environment (sbp-env) is a full feature framework to quickly test different sampling-based algorithms for motion planning. sbp-env focuses on the flexibility of tinkering with different aspects of the framework, and had divided the main planning components into two categories (i) samplers and (ii) planners.

The focus of motion planning research had been mainly on (i) improving the sampling efficiency (with methods such as heuristic or learned distribution) and (ii) the algorithmic aspect of the planner using different routines to build a connected graph. Therefore, by separating the two components one can quickly swap out different components to test novel ideas.

Have a look at the documentations for more detail information. If you are looking for the previous code for the RRdT* paper it is now archived at soraxas/rrdt.

Quick start with custom arbitrary environments

pip install sbp-env
import sbp_env

from math import exp, sin, cos

for functor in [
    # simple inequality
    lambda x: (x[1] < x[0] + 1) and (x[1] > x[0] - 1),
    # equation adopted from https://au.mathworks.com/help/matlab/ref/peaks.html
    lambda x: 0
    < (
        3 * (1 - x[0]) ** 2.0 * exp(-(x[0] ** 2) - (x[1] + 1) ** 2)
        - 10 * (x[0] / 5 - x[0] ** 3 - x[1] ** 5) * exp(-x[0] ** 2 - x[1] ** 2)
        - 1 / 3 * exp(-((x[0] + 1) ** 2) - x[1] ** 2)
    ),
    lambda x: -0.22 < (cos(x[0]) * sin(x[1])),
    lambda x: 0.05 < (cos(x[0] ** 2 + x[1] ** 2)),
]:
    engine = sbp_env.engine.BlackBoxEngine(
        collision_checking_functor=functor,
        lower_limits=[-5, -5], upper_limits=[5, 5],
        cc_epsilon=0.1,  # collision check resolution
    )
    planning_args = sbp_env.generate_args(
        planner_id="rrt", engine=engine,
        start_pt=[-3, -3], goal_pt=[3, 3],
        display=True, first_solution=True,
    )

    env = sbp_env.env.Env(args=planning_args)
    env.run()
    print(env.get_solution_path(as_array=True))

Installation

Optional

I recommend first create a virtual environment with

# assumes python3 and bash shell
python -m venv sbp_env
source sbp_env/bin/activate

Install dependencies

You can install all the needed packages with pip.

pip install -r requirements.txt

There is also an optional dependency on klampt if you want to use the 3D simulator. Refer to its installation guide for details.

Quick Guide

You can get a detailed help message with

python main.py --help

but the basic syntax is

python main.py <PLANNER> <MAP> [options]

It will open a new window that display a map on it. Every white pixel is assumed to be free, and non-white pixels are obstacles. You will need to use your mouse to select two points on the map, the first will be set as the starting point and the second as the goal point.

Demos

Run maps with different available Planners

This repository contains a framework to performs quick experiments for Sampling-Based Planners (SBPs) that are implemented in Python. The followings are planners that had implemented and experimented in this framework.

Note that the commands shown in the respective demos can be customised with additional options. In fact, the actual command format used for the demonstrations is

python main.py <PLANNER> maps/room1.png start <sx>,<sy> goal <sx>,<sy> -vv

to have a fix set of starting and goal points for consistent visualisation, but we omitted the start/goal options in the following commands for clarity.

RRdT*

python main.py rrdt maps/room1.png -vv

RRdT* Planner

RRT*

python main.py rrt maps/room1.png -vv

RRT* Planner

Bi-RRT*

python main.py birrt maps/room1.png -vv

Bi-RRT* Planner

Informed RRT*

python main.py informedrrt maps/room1.png -vv

Informed RRT* Planner

The red ellipse shown is the dynamic sampling area for Informed RRT*

Others

There are also some other planners included in this repository. Some are preliminary planner that inspired RRdT*, some are planners with preliminary ideas, and some are useful for debugging.

Reference to this repository

You can use the following citation if you use this repository for your research

@article{lai2021SbpEnv,
  doi = {10.21105/joss.03782},
  url = {https://doi.org/10.21105/joss.03782},
  year = {2021},
  publisher = {The Open Journal},
  volume = {6},
  number = {66},
  pages = {3782},
  author = {Tin Lai},
  title = {sbp-env: A Python Package for Sampling-based Motion Planner and Samplers},
  journal = {Journal of Open Source Software}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sbp-env-2.0.2.tar.gz (54.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sbp_env-2.0.2-py3-none-any.whl (66.1 kB view details)

Uploaded Python 3

File details

Details for the file sbp-env-2.0.2.tar.gz.

File metadata

  • Download URL: sbp-env-2.0.2.tar.gz
  • Upload date:
  • Size: 54.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.10.0 urllib3/1.26.12 tqdm/4.64.0 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.9

File hashes

Hashes for sbp-env-2.0.2.tar.gz
Algorithm Hash digest
SHA256 3ab89c2efdd3a165dd1cac12041637283d4f1d995ddf25af7f4442d134b42f0b
MD5 acee8d88914d21342a8516a12cfe2858
BLAKE2b-256 295a8878e74f82e9a97697d07a8f211af9fe32715eac95f5f54437001f0a89ed

See more details on using hashes here.

File details

Details for the file sbp_env-2.0.2-py3-none-any.whl.

File metadata

  • Download URL: sbp_env-2.0.2-py3-none-any.whl
  • Upload date:
  • Size: 66.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.10.0 urllib3/1.26.12 tqdm/4.64.0 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.9

File hashes

Hashes for sbp_env-2.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5a22356e3f1b1ff1f7f5ba206bddc989c1e29a0204464e6eef8fcab43c9b4ada
MD5 bfb89516445b3c62f421fdcccf96d76b
BLAKE2b-256 88a18cf380c4f7ec5fdec660c0cf7a96f855a81a383bf6717fc78d482680cc16

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page