Two-point interpolation with constant acceleration and constant jerk
Project description
Two Points Interpolation Python
Calculate optimal trajectory (position, velocity, acceleration) between two points with kinematic constraints.
Overview
This library provides two trajectory planning algorithms:
- Constant Acceleration: Generates smooth trajectories with acceleration limits
- Constant Jerk: Generates even smoother trajectories with jerk (acceleration derivative) limits
Installation
From PyPI (when published)
pip install two-point-interpolation
From Source
git clone https://github.com/yuokamoto/two_points_interpolation_py.git
cd two_points_interpolation_py
pip install -e .
For Development
git clone https://github.com/yuokamoto/two_points_interpolation_py.git
cd two_points_interpolation_py
pip install -e ".[dev]"
Quick Start
Constant Acceleration
from two_point_interpolation import TwoPointInterpolation
# Create interpolator
interp = TwoPointInterpolation()
# Set start, end, and constraints
interp.init(p0=0.0, pe=100.0, acc_max=2.0, vmax=10.0, dec_max=4.0)
# Calculate trajectory
total_time = interp.calc_trajectory()
# Get state at any time
pos, vel, acc = interp.get_point(t=5.0)
Constant Jerk
from two_point_interpolation.constant_jerk import TwoPointInterpolationJerk
interp = TwoPointInterpolationJerk()
interp.init(p0=0.0, pe=100.0, amax=2.0, vmax=10.0, jmax=1.0)
total_time = interp.calc_trajectory()
pos, vel, acc, jerk = interp.get_point(t=5.0)
Note: Constant jerk implementation is currently under review. See TODO section below.
Examples
Run example scripts to see visualizations:
# Basic constant acceleration
python3 examples/example_constant_acc.py
# Constant jerk (smoother)
python3 examples/example_constant_jerk.py
Testing
# Run all tests
python3 -m pytest tests/ -v
Project Structure
two_points_interpolation_py/
├── two_point_interpolation/ # Main package
│ ├── __init__.py # Package exports
│ ├── constant_acc.py # Acceleration-based planning
│ └── constant_jerk.py # Jerk-based planning (TODO: needs review)
├── examples/ # Example scripts
│ └── images/ # Generated plots
├── tests/ # Unit tests
└── docs/ # Documentation
├── CONSTANT_ACC_DERIVATION.md # Mathematical details
├── QUADRATIC_COEFFICIENTS_DERIVATION.md # Quadratic solution derivation
└── CHANGELOG.md # Version history
Example Results
Case 0: vmax not reached
Parameters: t0=1.0, p0=5, pe=15, acc_max=2.0, dec_max=3.0, vmax=10.0, v0=0, ve=0
Trajectory when the peak velocity is below vmax. Shows two phases: acceleration and deceleration.
Case 1: vmax reached
Parameters: t0=0, p0=0, pe=50, acc_max=2.0, dec_max=4.0, vmax=8.0, v0=2.0, ve=1.0
Trajectory when vmax is reached. Shows three phases: acceleration, constant velocity, and deceleration.
Documentation
- Getting Started: This README
- Mathematical Derivation: docs/CONSTANT_ACC_DERIVATION.md
- Detailed Coefficient Derivation: docs/QUADRATIC_COEFFICIENTS_DERIVATION.md
- Change History: docs/CHANGELOG.md
TODO
Constant Jerk Implementation Issues
The constant_jerk module requires significant improvements:
- API Contract Violation: The
ve(final velocity) parameter is accepted ininit()but never used in calculations - Debug Output:
calc_trajectory()prints debug information to stdout (should use logging or be removed) - Time Boundary Bug: Case 3 condition uses
4*t1+2*2*t2+t3instead of correct4*t1+2*t2+t3, causing phase transition errors - Missing Tests: No test coverage for constant jerk functionality
- Support acc_max != dec_max: Extend to support independent acceleration/deceleration limits
Other
- Add comprehensive test suite for
constant_jerkmodule - Verify mathematical correctness of jerk-based trajectories
Requirements
- Python 3.6+
- NumPy
- Matplotlib (for examples)
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
This software is provided "AS IS" without warranty of any kind.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file two_point_interpolation-0.1.1.tar.gz.
File metadata
- Download URL: two_point_interpolation-0.1.1.tar.gz
- Upload date:
- Size: 28.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f4a3b5d89e9e7794775c72788008840fed564f524db363f452354d1ba9816f5
|
|
| MD5 |
0bd11825403b0b5f4426de9eb4eb9315
|
|
| BLAKE2b-256 |
9cdacb9aeb0ccf0a2ca82ce9ff3c2a169f1c41e4109904d33c9722a5e724e1a4
|
File details
Details for the file two_point_interpolation-0.1.1-py3-none-any.whl.
File metadata
- Download URL: two_point_interpolation-0.1.1-py3-none-any.whl
- Upload date:
- Size: 18.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c28b9adcc302326ec139e0b5fd4148da98a5ab4ed1c827239a0317532b153b6
|
|
| MD5 |
de8ebe5e8f1feeed1906fd7c2d61291e
|
|
| BLAKE2b-256 |
c07ab4f1736c9b4baf11a122d6dc32647a715ddccf1cfb4e1703f205f31ad2eb
|