OxMPL
The Open Motion-Planning Library but Oxidised
Additional Links
Introduction
The What?
oxmpl
is a sampling-based motion planning library written in Rust, inspired by the structure and concepts of the Open Motion Planning Library (OMPL).
It is NOT OMPL with Rust bindings.
It provides a flexible and type-safe Rust API for core planning algorithms and offers high-level Python bindings for rapid prototyping and integration into existing Python-based robotics projects.
The Why?
[!WARNING] I will delete this section when the project hits v1.0.0 or when I decide to create a dedicated documentation static site.
OMPL is great, but it isn't written in Rust. While that's not a valid reason to rewrite it, the truth is C++ doesn't particularly spark joy for me. Nonetheless, it's a library I had to use regularly as a university student and still use in my work.
I'm teaching myself Rust, and after a few small projects, I found that it sparked joy. So, to really dive deep into the language, I decided to do what many Rustaceans do: rewrite something that already exists. In this case, my target was OMPL.
My goal isn't to create a full "drop-in" replacement for OMPL. I've found that Rust's traits and implementations can handle OMPL's modular nature more elegantly. However, I do want to provide Python bindings so the library can be used by people not keen on diving into Rust (looking at you, researchers).
This library will be similar to OMPL at a high level since I'm using the original as a reference. I'm still relatively new to Rust, so I'll often refer to the C++ source to help structure the code.
If you spot any issues or have ideas for improvements, please don't hesitate to open an issue or a PR. It would be a great learning opportunity for me.
Key Features
- Safe & Fast: Built in Rust for memory safety and performance.
- Extensible Architecture: Core concepts like
StateSpace
,StateValidityChecker
, andPlanner
are defined as traits, making the library highly extensible. - Pythonic Bindings: A simple, easy-to-use Python API powered by PyO3 that allows users to define problem-specific logic (like collision checkers) in pure Python.
- Inspired by OMPL: Follows the modular design of OMPL, making it familiar to those in the robotics community.
Installation
You can use oxmpl
in Rust, Python, or JavaScript projects.
For Python Users
The library is available on PyPI and can be installed with pip
:
For JavaScript/TypeScript Users
JavaScript/WASM bindings are available:
Note: Currently available as source. See oxmpl-js/README.md for build instructions.
For Rust Users
The core library is available on crates.io and can be added to your project's Cargo.toml
:
[]
= "0.4.0" # Replace with the latest version
Quick Start
JavaScript
import * as oxmpl from 'oxmpl-js';
// A state is invalid if it's inside a circular obstacle at the origin
// Create a 2D state space with bounds
const space = ;
// Define start state
const start = ;
// Define circular goal region
const target = ;
const radius = 0.5;
const goal = ;
// Create problem and run planner
const problem = ;
const validityChecker = ;
const planner = ;
planner.;
try catch
Python
Here is a complete example of solving a 2D planning problem with a custom collision checker written in Python.
"""A state is invalid if it's inside a circular obstacle at the origin."""
, =
return > 2.0
=
=
=
return <=
# A real implementation would use a random number generator
return
=
=
=
=
=
=
# for state in path.states:
# print(f" -> {state.values}")
Rust
use ;
use ;
use RRT;
use Rng;
/// A StateValidityChecker that defines a simple vertical wall obstacle.
/// A Goal definition where success is being within a certain radius of a target state.
Project Structure
This project is a Cargo workspace containing three separate crates:
- oxmpl/: The core Rust library containing all the planning logic, traits, and data structures. It has no Python or JavaScript-specific code.
- oxmpl-py/: A lightweight crate that contains the PyO3 bindings to expose the functionality of the
oxmpl
library to Python. - oxmpl-js/: JavaScript/WASM bindings using wasm-pack to provide
oxmpl
functionality in web browsers and Node.js.
Development
Prerequisites
- Rust toolchain (via rustup)
- Python 3.8+ and a virtual environment
maturin
for building the Python bindings
Setup
# Clone the repository
# Set up the Python environment (optional, but recommended)
Running Tests
To run the complete test suite for both crates:
# Run all Rust unit and integration tests
# Run the Python integration tests
# (make sure the module is installed in your venv first)
Contributing
Contributions are welcome! Please feel free to open an issue to discuss a bug or new feature, or submit a pull request.
License
This project is licensed under the BSD-3-Clause License. See the LICENSE file for details.