DrivetrainSplineTrajectoryBase

class wpimath.DrivetrainSplineTrajectoryBase(samples: collections.abc.Sequence[wpimath._wpimath.DrivetrainSplineSample])

Bases: pybind11_object

Represents a trajectory consisting of a list of samples, kinematically interpolating between them.

@tparam SampleType The type of sample (e.g., SplineSample, DifferentialSample)

Constructs a Trajectory from a vector of samples.

Parameters:

samples – The samples of the trajectory. Order does not matter as they will be sorted internally. @throws std::invalid_argument if the vector of samples is empty.

duration() wpimath.units.seconds

Returns the overall duration of the trajectory.

Returns:

The duration of the trajectory.

end() wpimath._wpimath.DrivetrainSplineSample

Returns the last sample in the trajectory.

Returns:

The last sample.

initial_pose() wpimath._wpimath.Pose2d

Returns the initial pose of the trajectory.

Returns:

The initial pose of the trajectory.

interpolate(start: wpimath._wpimath.DrivetrainSplineSample, end: wpimath._wpimath.DrivetrainSplineSample, t: SupportsFloat | SupportsIndex) wpimath._wpimath.DrivetrainSplineSample

Interpolates between two samples. This method must be implemented by subclasses to provide drivetrain-specific interpolation logic.

Parameters:
  • start – The starting sample.

  • end – The ending sample.

  • t – The interpolation parameter between 0 and 1.

Returns:

The interpolated sample.

sample_at(*args, **kwargs)

Overloaded function.

  1. sample_at(self: wpimath._wpimath.DrivetrainSplineTrajectoryBase, t: wpimath.units.seconds) -> wpimath._wpimath.DrivetrainSplineSample

Sample the trajectory at a point in time.

Parameters:

t – The point in time since the beginning of the trajectory to sample.

Returns:

The sample at that point in time. @throws std::runtime_error if the trajectory has no samples.

  1. sample_at(self: wpimath._wpimath.DrivetrainSplineTrajectoryBase, t: typing.SupportsFloat | typing.SupportsIndex) -> wpimath._wpimath.DrivetrainSplineSample

Sample the trajectory at a point in time.

Parameters:

t – The point in time since the beginning of the trajectory to sample (in seconds).

Returns:

The sample at that point in time.

samples() list[wpimath._wpimath.DrivetrainSplineSample]

Returns the samples of the trajectory.

Returns:

The samples of the trajectory.

start() wpimath._wpimath.DrivetrainSplineSample

Returns the first sample in the trajectory.

Returns:

The first sample.