Path2D provides methods for creating, analyzing, and modifying 2D paths in MATLAB – ideal for research, teaching, and applications such as robotics and autonomous vehicle guidance.
- Path operations: Orthogonal projection, cartesian ↔ frenet transformation, intersection with lines/circles
- Path modification: Shift, rotate, and combine paths
- Visualization: Plot and display paths and results
PolygonPath.m: Polygonal paths (defined by waypoints)SplinePath.m: Polynomial spline pathsDubinsPath.m: Dubins paths (sequences of arcs and lines) – work in progress
Most functionality supports code generation and can be used in Simulink.
Two well-known path tracking controllers are the Pure Pursuit [1] and the Stanley controller [2]. Their underlying path tracking error model differs in terms of reference point (rear/front axle), look-ahead (in the direction of the path/none) and lateral error orientation (orthogonal to vehicle heading/path). In literature, you can find several additional path tracking error definitions. As a result, the implementation of a specific path tracking controller not only requires the implementation of the control itself, but also the implementation of the according error model.
To generalize the computation of the path tracking error (and therefore the interface of the local path planner and the path tracking controller), [3] has proposed a classification of path tracking error definitions and also listed the required path operations (e.g. intersection of line/circle with path).
This repository implements these operations (and other such as frenet transformation) for different represenations of 2-dimensional paths.
Run this example for a comparison of Pure Pursuit and Stanley path tracking models.
% Example: Create a PolygonPath from waypoints and visualize the path
points = [0 0; 1 1; 2 0];
pathObj = PolygonPath.xy2Path(points(:,1), points(:,2));
pathObj.plot('r', 'LineWidth',2);
% Example: Create a SplinePath from a piecewise polynomial struct and visualize the path
pp = mkpp([0 1], [0 0 10 0; -6 9 0 0], 2);
pathObj = SplinePath.pp2Path(pp);
pathObj.plot('r', 'LineWidth',2)Further examples are available in the test files and below. Check GitHub Discussions for questions & exchange.
- Just MATLAB – no additional toolboxes required.
- Download or clone the repository.
- Add the root folder to your MATLAB search path or add the project file
Path2D.prjas a Project Reference to your project.
For class-specific help:
help Path2D % Base class
help PolygonPath % Polygonal path
help SplinePath % Spline pathSee the examples folder.
Contributions are welcome – whether through issues, pull requests, or feedback!
- Use issues for feature requests or bug reports.
[1] R. Craig Coulter. "Implementation of the Pure Pursuit Path Tracking Algorithm", 1992, Carnegie Mellon University.
[2] G. M. Hoffmann, C. J. Tomlin, M. Montemerlo and S. Thrun. "Autonomous Automobile Trajectory Tracking for Off-Road Driving: Controller Design, Experimental Validation and Racing", 2007 American Control Conference, New York, NY, USA, 2007, pp. 2296-2301, https://doi.org/10.1109/ACC.2007.4282788
[3] Rumetshofer, J.; Stolz, M.; Watzenig, D. "A Generic Interface Enabling Combinations of State-of-the-Art Path Planning and Tracking Algorithms", Electronics 2021, 10, 788. https://doi.org/10.3390/electronics10070788
[4] A. M. C. Rezende, V. M. Goncalves and L. C. A. Pimenta, "Constructive Time-Varying Vector Fields for Robot Navigation", in IEEE Transactions on Robotics, vol. 38, no. 2, pp. 852-867, April 2022, doi: https://doi.org/10.1109/TRO.2021.3093674