#physics-simulation #path-finding #physics #dubin

dubins_paths

Rust code for calculating Dubin's Paths

33 stable releases

2.7.0 Apr 4, 2025
2.6.0 Mar 11, 2025
2.5.0 Feb 4, 2025
2.4.2 Oct 25, 2024
0.2.5 Oct 22, 2021

#14 in Simulation

Download history 1634/week @ 2025-01-03 1794/week @ 2025-01-10 1961/week @ 2025-01-17 2237/week @ 2025-01-24 2311/week @ 2025-01-31 2160/week @ 2025-02-07 1628/week @ 2025-02-14 2393/week @ 2025-02-21 2799/week @ 2025-02-28 3509/week @ 2025-03-07 4062/week @ 2025-03-14 3761/week @ 2025-03-21 2888/week @ 2025-03-28 4620/week @ 2025-04-04 4399/week @ 2025-04-11 499/week @ 2025-04-18

12,881 downloads per month

MIT license

42KB
617 lines

Dubin's Paths

unsafe forbidden

Rust code for calculating Dubin's Paths

Credit to Andrew Walker for the original C code

I've ported the code to Rust and documented everything that I could understand. Documentation in the original repository was minimal.

Quick example

use dubins_paths::{DubinsPath, PI, PosRot, Result as DubinsResult};

// PosRot represents the car's (Pos)ition and (Rot)ation
// Where x and y are the coordinates on a 2d plane
// and theta is the orientation of the car's front in radians

// The starting position and rotation
// PosRot::from_floats can also be used for const contexts
const q0: PosRot = PosRot::from_floats(0., 0., PI / 4.);

// The target end position and rotation
// PosRot implements From<[f32; 3]>
let q1 = [100., -100., PI * (3. / 4.)].into();

// The car's turning radius (must be > 0)
// This can be calculated by taking a cars angular velocity and dividing it by the car's forward velocity
// `turn radius = ang_vel / forward_vel`
let rho = 11.6;

// Calculate the shortest possible path between these two points with the given turning radius
let shortest_path_possible: DubinsResult<DubinsPath> = DubinsPath::shortest_from(q0, q1, rho);

// Assert that the path was found!
assert!(shortest_path_possible.is_ok());

DubinsPath has many methods you should look into, such as length, extract_subpath, sample, and sample_many.

Features

  • glam - Use a glam compatible API
  • f64 - By default, the library uses f32 precision and the equivalent glam::f32 structs if that feature is enabled. Setting f64 changes all numbers to 64-bit precision, and uses glam::f64 vector types

More documentation

Looking for some more detailed documentation? Head on over to the docs.rs page!

Dependencies

~0–1.1MB
~35K SLoC