Road Runner

Searchâ€¦

Parametric Paths

With a clear coordinate system in place, paths can be specified at the global level (i.e., not 'go forward 60 inches and turn 45 degrees right'). Complex, abstract paths can now be devised without having to explicitly consider the robot velocities necessary to execute them.

Lines

To describe these paths, we will use parametric curves. For our purposes, these curves are composed of two single variable functions

$x(t)$

and $y(t)$

that together determine the path shape. Parametric lines take the form $x(t) = x_0 + v_x \, t$

, $y(t) = y_0 + v_y \, t$

. This can be represented more conveniently in the notation of vectors: $\vec{r}(t) = \vec{x_0} + \vec{v} \, t$

(there is an intimate relationship between parametrics and vectors; they're often called vector-valued functions). Lines and other parametric functions are often defined over the whole $t$

domains; however, for the purposes of constructing finite paths, the domain is constrained to a closed interval. Road Runner assumes parametric curves are only defined on $[0, 1]$

.To create a

`LineSegment`

, simply provide a start vector and an end vector.Java

Kotlin

1

LineSegment line = new LineSegment(

2

new Vector2d(0, 0),

3

new Vector2d(50, 100)

4

);

5

Vector2d position = line.get(0.5);

Copied!

1

val line = LineSegment(

2

Vector2d(0.0, 0.0),

3

Vector2d(50.0, 100.0)

4

)

5

val position = line[0.5]

Copied!

Splines

In addition to lines, there are built-in quintic splines. Unlike lines, splines can assume a variety of curved shapes. The shape of the spline is controlled by waypoints on either end that specify the desired position, first derivative, and second derivative.

Sample quintic spline

The quintic spline above was generated with the following code:

Java

Kotlin

1

QuinticSpline spline = new QuinticSpline(

2

new QuinticSpline.Waypoint(0, 0, 20, 20),

3

new QuinticSpline.Waypoint(30, 15, -30, 10)

4

);

Copied!

1

val spline = QuinticSpline(

2

QuinticSpline.Waypoint(0.0, 0.0, 20.0, 20.0),

3

QuinticSpline.Waypoint(30.0, 15.0, -30.0, 10.0)

4

)

Copied!

As we'll see soon, there are more convenient methods of customizing splines without specifying derivatives directly.

Heading Interpolation

For tank drives, specifying the

$(x, y)$

position of the robot at every point along the path is sufficient to determine the full pose. This so-called nonholonomic constraint mandates that the robot most be oriented tangent to the path. However, for holonomic drives, the heading is fully independent of the translational velocity, and this enables more complex manuevers. For instance, a holonomic drive may traverse a spline while rotating or maintaining a constant heading (relative to the global frame).Road Runner was designed with first-class holonomic support and provides a number of

`HeadingInterpolators`

. The default (and only option for nonholonomic drives) interpolator is `TangentInterpolator`

. The next most commonly used are `ConstantInterpolator`

and `LinearInterpolator`

for strafing and efficient pose-to-pose movements, respectively.The combination of a

`ParametricCurve`

and a `HeadingInterpolator`

is a `PathSegment`

. A sequence of `PathSegments`

can be strung together into a single continuous `Path`

.Here's an example demonstrating the construction of a

`Path`

from lower-level abstractions:Java

Kotlin

1

LineSegment line = new LineSegment(

2

new Vector2d(0, 0),

3

new Vector2d(56, 24)

4

);

5

LinearInterpolator interp = new LinearInterpolator(

6

Math.toRadians(30), Math.toRadians(45)

7

);

8

PathSegment segment = new PathSegment(line, interp);

9

Path path = new Path(segment);

Copied!

1

val line = LineSegment(

2

Vector2d(0.0, 0.0),

3

Vector2d(56.0, 24.0)

4

)

5

val interp = LinearInterpolator(

6

Math.toRadians(30.0), Math.toRadians(45.0)

7

)

8

val segment = PathSegment(line, interp)

9

val path = Path(segment)

Copied!

`PathBuilder`

This process of creating

`Paths`

is a bit tedious, and verbose---there is often duplicate information required to connect the segments. To make things easier, the `PathBuilder`

class provides a more streamlined interface for `Path`

construction.Java

Kotlin

1

Path path = new PathBuilder(new Pose2d(0, 0, 0))

2

.splineTo(new Pose2d(15, 15, 0))

3

.lineTo(new Vector2d(30, 15))

4

.build();

Copied!

1

val path = PathBuilder(Pose2d(0.0, 0.0, 0.0))

2

.splineTo(Pose2d(15.0, 15.0, 0.0))

3

.lineTo(Vector2d(30.0, 15.0))

4

.build()

Copied!

Last modified 1yr ago

Copy link