Metadata-Version: 2.4
Name: mplib2
Version: 0.3.0
Summary: A lightweight motion planning library (actively maintained fork of MPlib)
Author-email: Minghua Liu <minghua@ucsd.edu>, Jiayuan Gu <jigu@ucsd.edu>, Kolin Guo <ruguo@ucsd.edu>, Xinsong Lin <x8lin@ucsd.edu>
Maintainer-email: Albert Khalikov <al.ry.ri@gmail.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/dd114/MPlib2
Project-URL: Repository, https://github.com/dd114/MPlib2
Project-URL: Issues, https://github.com/dd114/MPlib2/issues
Project-URL: Upstream, https://github.com/haosulab/MPlib
Keywords: robotics,motion planning
Classifier: Operating System :: POSIX :: Linux
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: Other Audience
Classifier: Intended Audience :: Science/Research
Classifier: Natural Language :: English
Classifier: Framework :: Robot Framework :: Tool
Classifier: Programming Language :: C++
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Education
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Utilities
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.26
Requires-Dist: toppra>=0.6.3
Requires-Dist: transforms3d>=0.3.1
Dynamic: license-file

# MPlib2: a Lightweight Motion Planning Library

<p align="center">
  <img src="https://raw.githubusercontent.com/dd114/MPlib2/main/docs/demo.gif">
</p>

[![License](https://img.shields.io/github/license/dd114/MPlib2)](https://github.com/dd114/MPlib2/blob/main/LICENSE)
[![Python](https://img.shields.io/badge/python-3.10%20|%203.11%20|%203.12-blue)](https://github.com/dd114/MPlib2)
[![Upstream MPlib](https://img.shields.io/badge/fork%20of-haosulab%2FMPlib-lightgrey)](https://github.com/haosulab/MPlib)

MPlib2 is an actively maintained standalone fork of [MPlib](https://github.com/haosulab/MPlib) — a lightweight Python motion planning library decoupled from ROS. It brings modern dependency compatibility (Python 3.10–3.12, NumPy 2, Pinocchio 3, Boost 1.88+, modern `pybind11`) and stability fixes while remaining a drop-in `import mplib` replacement for existing ManiSkill, SAPIEN, and MPlib codebases.

## Installation

### Standard Pip Installation

The PyPI distribution name is `mplib2`, while the Python import module remains `mplib`:

```bash
pip install mplib2
```

> **Note (migrating from upstream `mplib`)**: Because `mplib2` provides the `mplib` Python module as a drop-in replacement, it cannot coexist with upstream `mplib` in the same environment. Uninstall upstream `mplib` first to avoid package shadowing:
> ```bash
> pip uninstall -y mplib && pip install mplib2
> ```

### Building from Source & Editable Installation

#### Prerequisites

Building MPlib2 from source requires Python >= 3.10, a C++17 compiler (`g++` or `clang++`), CMake (>= 3.12), Ninja, `pybind11` (>= 2.13, required for NumPy 2 compatibility), and C++ dependency libraries:
- Eigen3 (>= 3.4.0)
- Pinocchio (>= 3.0, < 4.0)
- FCL / Coal
- OMPL (>= 1.5)
- Boost (>= 1.70: `filesystem`; `system` linked conditionally if present)
- Orocos-KDL
- URDFDOM
- Assimp

#### Option A: Managed Environment with Pixi (Recommended)

[Pixi](https://pixi.sh/) automatically installs required C++ libraries and Python toolchains (Python >= 3.10, < 3.13):

```bash
# Clone the repository
git clone https://github.com/dd114/MPlib2.git
cd MPlib2

# Install development environment and execute test suite
pixi run pytest tests
```

#### Option B: Editable Installation via Pip (Python 3.10–3.12)

Within an existing Conda or system environment providing the prerequisite C++ libraries:

```bash
# Install runtime Python dependencies
pip install "numpy>=1.26" "toppra>=0.6.3" "transforms3d>=0.3.1"

# Build C++ pybind11 extension in-place and install editable package
pip install -e . --no-build-isolation
```

## Quickstart

```python
import numpy as np
import mplib

# Initialize planner for Franka Emika Panda arm
planner = mplib.Planner(
    urdf="data/panda/panda.urdf",
    srdf="data/panda/panda.srdf",
    move_group="panda_hand",
)

# Set initial joint configuration (7 arm joints + 2 gripper fingers)
start_qpos = np.array([0.0, 0.2, 0.0, -2.6, 0.0, 2.9, 0.8, 0.02, 0.02])
planner.robot.set_qpos(start_qpos, full=True)

# Forward Kinematics: compute end-effector pose
planner.pinocchio_model.compute_forward_kinematics(start_qpos)
ee_idx = planner.link_name_2_idx["panda_hand"]
target_pose = planner.pinocchio_model.get_link_pose(ee_idx)

# Inverse Kinematics: solve for joint angles matching target pose
status, ik_qpos = planner.IK(target_pose, start_qpos, return_closest=True)
if status == "Success":
    print("IK Solution found:", ik_qpos[:7])

# Motion Planning: plan collision-free trajectory to target pose
target_pose.p[0] += 0.1  # Translate 10 cm in X
result = planner.plan_pose(target_pose, start_qpos)

if result["status"] == "Success":
    print(f"Planned trajectory duration: {result['duration']:.2f} s")
    print(f"Waypoints: {len(result['position'])}")
```

## Documentation & Attribution

- Upstream API reference and tutorials (applicable to the `mplib` Python API): [motion-planning-lib.readthedocs.io](https://motion-planning-lib.readthedocs.io/latest/tutorials/getting_started.html)
- Originally created by Hao Su's Lab, UC San Diego ([haosulab/MPlib](https://github.com/haosulab/MPlib)); maintained as MPlib2 at [dd114/MPlib2](https://github.com/dd114/MPlib2).
