Skip to main content

Motion Planning Library that enables easy use of popular planning algorithms with a multitude of existing robots

Project description

Praval's Motion Planning Library

Table Of Contents

Usage

Installation

Python Version: 3.12.9

  1. Clone the repository
git clone https://github.com/pmvt19/motion_planning_library.git
  1. Create a Conda Environment
conda create -n <name> python=3.12.9
  1. Change Directories into the cloned repository
cd motion_planning_library
  1. Install the package to the environment
pip install -e .

Environments

Deterministic Environments

Parking Space Environment

Parking Space Environment

Probabilistic Environments

Biased Passage

Parameters: Num Walls Bias

Biased Passage Environment

Random Sample Passage

Parameters: Num Walls Gap Width

Random Sample Passage Environment

Robots

Point Robot

This robot is a zero-radius point in 2D workspace.

Configuration space: [$x$, $y$]

Disc Robot

Disc Robot

This robot is disc with radius $R$ 2D workspace.

Configuration space: [$x$, $y$]

Parameters: Radius

Disc Robot

Polygonal Robot

This robot is rectangle with distinct height and width in 2D workspace. The positional compoenent of the state represents the center of the rectangle while the orientation is represented by $\theta$.

Configuration space: [$x$, $y$, $\theta$]

Parameters: Height Width

Polygonal Robot

Planar Mobile Arm

This robot is mobile arm with a distinct height and width for the base and $N$ number of links for the arms in 2D workspace. The positional component of the state represents the center of the rectangular base while the $\theta_i$ components represent the position of the $i\text{-th}$ arm.

Configuration space: [$x$, $y$, $\theta_1$, $\theta_2$, ..., $\theta_N$]

Parameters: Base Height? Base Width? Number of Links Length of Links

Planar Mobile Arm Robot

Search Algorithms

This library mostly explores a class of motion planning algorithms known as sampling-based motion planning algorithms. This means each planning algorithm relies on probabilistic properties to alleviate some of the heavy compuation required for classical motion planning algorithms.

Disclaimer: The current implementations for visualizations only show the first two dimensions of the configurations. For some robots, this is the entire dimensionality of the $\mathcal{C}$-Space, while for others it is only a partial visualization for the spatial components.

RRT (Rapidly-Exploring Random Tree)

Steps:

  1. Initialize Search Tree with Root Node as Start
  2. Randomly Sample a Valid Point in the $\mathcal{C}$-Space
  3. Find the Closest Node on the Search Tree to the Sampled Point
  4. Extend the Closest Node a Fixed Distance $\delta$ Toward the Sampled Point and Add this Node as a Child of the Closest Node
  5. Repeat steps 2-4 until the target is within a certain distance of the new node

RRT GIF

Why this works

RRT is inherently biased to expore open regions of the $\mathcal{C}$-Space first, then fill in the gaps later due to the voronoi bias.

The voronoi diagram (pictured below) partitions the space into regions where all points in a given region are closest to a single point. Intuitively this means, that larger regions are more unexplored while smaller regions are explored since the larger region has a lot of space closest to a single point.

If we sample a node uniformly from the $\mathcal{C}$-Space, then it is more likely that this sampled point lives in a larger region. You can think of the proportion of area for each region in the voronoi diagram as the probability that we expand in that region. This inherently biases expansion in more unexplored areas.

RRT Voronoi Diagram

Bi-Directional RRT

Bi-Directional RRT attempts to grow two trees: one from the start (just like RRT) and one from the target. If the trees have any nodes within a certain thresholded distance between them and the edge connecting the two nodes are valid, then the trees connect and a valid path between the start and the target is found.

The following is a GIF showing the start tree (orange) and the target tree (blue) growing towards each other and connecting in the middle:

BiDirectional RRT GIF

RRT*

Unlike RRT, RRT* attempts to find an asymptotically optimal path (i.e. the shortest path between configuration $p$ and $q$). This is done by adding an additional step to the RRT expansion step: rewiring. The goal of the rewiring step is to make the newly added node in the tree have the shortest path to the starting (root) configuration using the existing tree structure and adjusting relationships if necessary.

This means that the tree will not stop building after finding an initial path from $p$ to the $q$; it will continuosly search, refining the path until it hits its maximum runtime.

The following is a GIF showing how an RRT* tree grow compared to a regular RRT tree from the same task:

RRT* vs RRT

RSG (Random Sample Generation)

The RSG algorithm is nearly identical to RRT, except for how it choses what the new node will be. In RRT, we expand in the direction of our sampled node ($q_{sampled}$) a maximum $\delta$ distance from the closest node on the tree: $q_{nearest}$. In RSG, we generate $N$ random candidate nodes around $q_{nearest}$ (sampled with a maximum distance $\delta$), keep nodes with that have a valid edge between themselves and $q_{nearest}$, and add the candidate node that is closest to the sampled node.

The following is an example RSG search tree:

RSG Tree

PRM (Probabilistic Roadmap)

Unlike RRT which is a single query planner, PRM generates a roadmap that can be required for multiple tasks within the same configuration space. The bulk of the computation for PRM is done during the creation of the roadmap.

The standard PRM algorithm is as follows:

  1. Sample N Random Points in the Configuration Space
  2. Validate All Sampled Points and Remove Invalid Points
  3. Attempt Edge Connections with either M Neighbors or All Other Points within Radius R and Keep Only Valid Edges
  4. Attach the start and target nodes to the roadmap and validate their edges
  5. Use a shortest path algorithm such as Dijkstra's or A* to solve for the path

The following is a GIF of the generation of a PRM

PRM Generation

Incremental PRM

Similar to traditional PRM, Incremental PRM also builds a roadmap in the $\mathcal{C}$-Space, but will continue to add nodes until the start and target configuration are in the same connected component. Once $p$ and $q$ are in the same connected component, this means there exists a valid path from start to the target, and thus this search algorithm can stop extending the graph and return the shortest path connecting the start and target via the existing roadmap.

The following is a GIF of Incremental PRM iteratively extending the roadmap to connect the start and target:

Incremental PRM Generation

NonUniform PRM

Typically, building PRMs sample uniformly in the robot's $\mathcal{C}$-Space; however, many nodes in open areas of the $\mathcal{C}$-Space may not be as beneficial as nodes on the border of $\mathcal{C}_{free}$ and $\mathcal{C}_{obst}$.

NonUniform PRM works by initially sampling a set of nodes in the configuration space uniformly (just like traditional PRM), adding some normally distributed noise to the points, and comparing if one of the original points or noise affected points are in $\mathcal{C}_{free}$ while the other is in $\mathcal{C}_{obst}$. This means that we retain the node only if exactly one of the configuration (either the originally sampled one or the noise affected one) is in $\mathcal{C}_{free}$. This ensures that retained nodes are typically near $\mathcal{C}_{obst}$ regions.

The following is an example of a roadmap generated via the NonUniform PRM algorithm:

Non-Uniform PRM

Lazy PRM

Lazy PRM works almost exactly like PRM, but delays the most computationally expensive part of the algorithm: the edge collision checks. In traditional PRM, we validate all the edges of our roadmap before attempting to find a path from the start to the target.

In contrast, Lazy PRM does not validate edges before attempting to search for a path. Instead Lazy PRM validates the edges of only potential paths connecting the start to the target.

Lazy PRM searchs for an initial potential path in the roadmap. If found, it then validates all the edges in the potential path. If there are no invalid edges in the potential path, the algorithm will simply return that path as the final path. However, if there are invalid edges in the path, Lazy PRM will remove those edges from the roadmap and search again from a path from the start to the target. This will repeat until either a path is found with no invalid edges or it reaches a maximum number of iterations.

The following is a GIF of Lazy PRM Searching for a path with the invalid edges marked in pink:

Lazy PRM

Visualizations

2D C-Space

For robots whos configuration space is only 2 dimensions, we can fully visualize their configuration space. There are two robots in this library that have implementations compatible with the CSpace visualizer: Disc Robot and Fixed Arm Robot.

The following are example of workspace and their respective configuration space.

Disc Robot Workspace and $\mathcal{C}$-Space Visualization:

2D C-Space Disc Robot

Fixed Arm Workspace and $\mathcal{C}$-Space in Interactive Visualization:

2D C-Space Robot Arm

Accelerated Collision Checks

Circle Approximations For the Environment and Robot

Environments consisting of rectangles can be approximated using this implementation.

Robots consisting of points/circles, line segments, and rectangles can all be approximated using circles in this implementation.

Original Robot Representation

Base Environment

Circle Approximation Representation

Circle Approximated Environment

Under and Over Approximations

Under approximations mean the circles do not cover the entirety of the rectangular shapes in the environment, include those that are part of the robot and part of the environment obstacles. This leaves the risk of saying an invalid state that falls inside the corner of the rectangular obstacle is valid.

Circle-based Under-Approximated Environment

Over approximations mean the circles do cover the entirety of the rectangluar shapes in the environment. However, it will also spill over into some free space, meaning the $\mathcal{C}_{free}$ will appear smaller than it actually is. This leaves the risk of saying a valid state near the edge of a rectangular obstacle is actually invalid. This is mostly a concern for $\mathcal{C}$-Spaces with narrow passages.

Circle-based Over-Approximated Environment

Acknowledgements

This repository is heavily inspired by work done during my time at the Parasol Lab working with, at the time, PhD candidate Amnon Attali. A few items in this codebase are a reimplementation intended to better my skills with NumPy and general motion planning fundamentals.

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

pmpl_robot-1.1.0.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

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

pmpl_robot-1.1.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file pmpl_robot-1.1.0.tar.gz.

File metadata

  • Download URL: pmpl_robot-1.1.0.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pmpl_robot-1.1.0.tar.gz
Algorithm Hash digest
SHA256 c4781a05b6c6e17bb417bdaaf91eefd7ce1936bf95db83d648b6b5b920532f5d
MD5 7a3a10e900b9a29ef6e47f3ee7bad83b
BLAKE2b-256 35c2d73d89bd4cf57543d496727ff6bfe91dcc6c6805fc5191e66ea84635374f

See more details on using hashes here.

File details

Details for the file pmpl_robot-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: pmpl_robot-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pmpl_robot-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 707cd9244c60b251d1c4fcc90c414d9a66e9c18184ea6c71eacfb1e552b7a62f
MD5 71e37a07ec6bf9d82543cfbd008a142f
BLAKE2b-256 dd0c145cc1e8501f7ec7543571057791b53a3f96ac89f565bccf68a5c411e461

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