Programming Language
Python
Import Libraries
More information can be found in the individual scripts (.py).
Supported on the following operating systems
Windows, Linux, macOS
An open-source library for interpolation functions of parametric curves (Bézier, B-Spline) useful for robotics applications, such as path planning, etc. The library provides access to specific classes for working with two types of parametric curves: Bézier curves and B-Spline curves. The specific classes focus on the problem of interpolating both two-dimensional and three-dimensional curves from input control points.
The classes also include the methods to calculate the derivative of the individual curves, arc-length, bounding box, simplification of the curves, and much more. The B-Spline interpolation class contains a function to optimize control points using the least squares method.
Path (Bézier): ..\Collision_Detection\src\Interpolation\Bezier\Core.py
Path (B-Spline): ..\Collision_Detection\src\Interpolation\B_Spline\Core.py
In particular, the library focuses on solving the path planning problem of the industrial/collaborative robotic arms. But, as an open-source library, it can be used for other tasks, as creativity knows no limits.
The repository also contains a transformation library with the necessary project-related functions. See link below.
The library can be used within the Robot Operating System (ROS), Blender, PyBullet, Nvidia Isaac, or any program that allows Python as a programming language.
Bernstein Polynomials
$ /> cd Documents/GitHub/Parametric_Curves/Evaluation/Bezier
$ ../Evaluation/Bezier> python3 Bernstein_Polynomials.py
Demonstration of two-dimensional (2D) Curves
$ /> cd Documents/GitHub/Parametric_Curves/Evaluation/Bezier
$ ../Evaluation/Bezier> python3 test_2d_1.py
Demonstration of three-dimensional (3D) Curves
$ /> cd Documents/GitHub/Parametric_Curves/Evaluation/Bezier
$ ../Evaluation/Bezier> python3 test_3d_1.py
A simple program that describes how to work with the library can be found below. The whole program is located in the individual evaluation folder.
# System (Default)
import sys
# Numpy (Array computing) [pip3 install numpy]
import numpy as np
# Matplotlib (Visualization) [pip3 install matplotlib]
import matplotlib.pyplot as plt
# Custom Lib.:
# ../Interpolation/Bezier/Core
import Interpolation.Bezier.Core as Bezier
"""
Description:
Initialization of constants.
"""
# Bezier curve interpolation parameters.
# 'method': The name of the method to be used to interpolate the parametric curve.
# method = 'Explicit' or 'Polynomial'.
# N: The number of points to be generated in the interpolation function.
CONST_BEZIER_CURVE = {'method': 'Explicit', 'N': 100}
# Visibility of the bounding box:
# 'limitation': 'Control-Points' or 'Interpolated-Points'
CONST_BOUNDING_BOX = {'visibility': False, 'limitation': 'Control-Points'}
def main():
"""
Description:
A program to visualize a parametric two-dimensional Bézier curve of degree n.
"""
# Input control points {P} in two-dimensional space.
P = np.array([[1.00, 0.00],
[2.00, -0.75],
[3.00, -2.50],
[3.75, -1.25],
[4.00, 0.75],
[5.00, 1.00]], dtype=np.float32)
# Initialization of a specific class to work with Bézier curves.
B_Cls = Bezier.Bezier_Cls(CONST_BEZIER_CURVE['method'], P,
CONST_BEZIER_CURVE['N'])
# Interpolation of parametric Bézier curve.
B = B_Cls.Interpolate()
# Obtain the arc length L(x) of the general parametric curve.
L = B_Cls.Get_Arc_Length()
# Create a figure.
_, ax = plt.subplots()
# Visualization of relevant structures.
ax.plot(P[:, 0], P[:, 1], 'o--', color='#d0d0d0', linewidth=1.0, markersize = 8.0,
markeredgewidth = 4.0, markerfacecolor = '#ffffff', label='Control Points')
ax.plot(B[:, 0], B[:, 1], '.-', color='#ffbf80', linewidth=1.5, markersize = 8.0,
markeredgewidth = 2.0, markerfacecolor = '#ffffff', label=f'Bézier Curve (N = {B_Cls.N}, L = {L:.03})')
# Show the result.
plt.show()
if __name__ == '__main__':
sys.exit(main())
Basic Functions
$ /> cd Documents/GitHub/Parametric_Curves/Evaluation/B_Spline
$ ../Evaluation/B_Spline> python3 Basic_Functions.py
Demonstration of two-dimensional (2D) Curves
$ /> cd Documents/GitHub/Parametric_Curves/Evaluation/B_Spline
$ ../Evaluation/B_Spline> python3 test_2d_1.py
$ /> cd Documents/GitHub/Parametric_Curves/Evaluation/B_Spline
$ ../Evaluation/B_Spline> python3 test_2d_2.py
Demonstration of three-dimensional (3D) Curves
$ /> cd Documents/GitHub/Parametric_Curves/Evaluation/B_Spline
$ ../Evaluation/B_Spline> python3 test_3d_1.py
$ /> cd Documents/GitHub/Parametric_Curves/Evaluation/B_Spline
$ ../Evaluation/B_Spline> python3 test_3d_2.py
A simple program that describes how to work with the library can be found below. The whole program is located in the individual evaluation folder.
# System (Default)
import sys
# Numpy (Array computing) [pip3 install numpy]
import numpy as np
# Matplotlib (Visualization) [pip3 install matplotlib]
import matplotlib.pyplot as plt
# Custom Lib.:
# ../Interpolation/B_Spline/Core
import Interpolation.B_Spline.Core as B_Spline
"""
Description:
Initialization of constants.
"""
# B-Spline interpolation parameters.
# n: Degree of a polynomial.
# N: The number of points to be generated in the interpolation function.
# 'method': The method to be used to select the parameters of the knot vector.
# method = 'Uniformly-Spaced', 'Chord-Length' or 'Centripetal'.
CONST_B_SPLINE = {'n': 3, 'N': 100, 'method': 'Chord-Length'}
# Visibility of the bounding box:
# 'limitation': 'Control-Points' or 'Interpolated-Points'
CONST_BOUNDING_BOX = {'visibility': False, 'limitation': 'Control-Points'}
def main():
"""
Description:
A program to visualize a parametric two-dimensional B-Spline curve of degree n.
"""
# Input control points {P} in two-dimensional space.
P = np.array([[1.00, 0.00],
[2.00, -0.75],
[3.00, -2.50],
[3.75, -1.25],
[4.00, 0.75],
[5.00, 1.00]], dtype=np.float32)
# Initialization of a specific class to work with B-Spline curves.
S_Cls = B_Spline.B_Spline_Cls(CONST_B_SPLINE['n'], CONST_B_SPLINE['method'], P,
CONST_B_SPLINE['N'])
# Interpolation of parametric B-Spline curve.
S = S_Cls.Interpolate()
# Obtain the arc length L(x) of the general parametric curve.
L = S_Cls.Get_Arc_Length()
# Create a figure.
_, ax = plt.subplots()
# Visualization of relevant structures.
ax.plot(P[:, 0], P[:, 1], 'o--', color='#d0d0d0', linewidth=1.0, markersize = 8.0,
markeredgewidth = 4.0, markerfacecolor = '#ffffff', label='Control Points')
ax.plot(S[:, 0], S[:, 1], '.-', color='#ffbf80', linewidth=1.5, markersize = 8.0,
markeredgewidth = 2.0, markerfacecolor = '#ffffff', label=f'B-Spline (n = {S_Cls.n}, N = {S_Cls.N}, L = {L:.03})')
# Show the result.
plt.show()
if __name__ == '__main__':
sys.exit(main())
The library for parametric curves can also be used within the Blender software. See the instructions below for more information.
Bézier Curves
A description of how to run a program to visualize a parametric three-dimensional Bézier curve of degree n.
- Open Bezier_Curve.blend from the Blender folder.
- Copy and paste the script from the evaluation folder (../Bezier_Curve.py).
- Run it and evaluate the results.
$ /> cd Documents/GitHub/Parametric_Curves/Blender/Interpolation
$ ../Collision_Detection/Blender> blender Bezier_Curve.blend
B-Spline Curves
A description of how to run a program to visualize a parametric three-dimensional B-Spline curve of degree n.
- Open B_Spline.blend from the Blender folder.
- Copy and paste the script from the evaluation folder (../B_Spline.py).
- Run it and evaluate the results.
$ /> cd Documents/GitHub/Parametric_Curves/Blender/Interpolation
$ ../Collision_Detection/Blender> blender B_Spline.blend
@misc{RomanParak_ParametricCurves,
author = {Roman Parak},
title = {An open-source parametric curves library useful for robotics applications},
year = {2023},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/rparak/Parametric_Curves}}
}