001// Copyright (c) Choreo contributors 002 003package choreo.trajectory; 004 005import edu.wpi.first.math.geometry.Pose2d; 006import edu.wpi.first.math.interpolation.Interpolatable; 007import edu.wpi.first.math.kinematics.ChassisSpeeds; 008import edu.wpi.first.util.struct.StructSerializable; 009 010/** 011 * The generic interface for a sample in a trajectory. 012 * 013 * @param <Self> Derived sample type. 014 */ 015public interface TrajectorySample<Self extends TrajectorySample<Self>> 016 extends Interpolatable<Self>, StructSerializable { 017 /** 018 * Returns the timestamp of this sample. 019 * 020 * @return the timestamp of this sample. 021 */ 022 double getTimestamp(); 023 024 /** 025 * Returns the pose at this sample. 026 * 027 * @return the pose at this sample. 028 */ 029 Pose2d getPose(); 030 031 /** 032 * Returns the field-relative chassis speeds of this sample. 033 * 034 * @return the field-relative chassis speeds of this sample. 035 */ 036 ChassisSpeeds getChassisSpeeds(); 037 038 /** 039 * Returns this sample, mirrored across the field midline. 040 * 041 * @return this sample, mirrored across the field midline. 042 */ 043 Self flipped(); 044 045 /** 046 * Returns this sample, offset by the given timestamp. 047 * 048 * @param timestampOffset the offset to apply to the timestamp. 049 * @return this sample, offset by the given timestamp. 050 */ 051 Self offsetBy(double timestampOffset); 052 053 /** 054 * For internal use only. 055 * 056 * @param length the length of the array to create. 057 * @return the created array. 058 */ 059 Self[] makeArray(int length); 060}