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, flipped to the other alliance according to the symmetry of the field. 040 * 041 * @return this sample, flipped to the other alliance according to the symmetry of the field. 042 */ 043 Self flipped(); 044 045 /** 046 * Returns this sample, mirrored to the other alliance. 047 * 048 * @return this sample, mirrored to the other alliance. 049 */ 050 Self mirrorX(); 051 052 /** 053 * Returns this sample, mirrored left-to-right from the driver's perspective. 054 * 055 * @return this sample, mirrored left-to-right from the driver's perspective. 056 */ 057 Self mirrorY(); 058 059 /** 060 * Returns this sample, rotated 180 degrees around the field center. 061 * 062 * @return this sample, rotated 180 degrees around the field center. 063 */ 064 Self rotateAround(); 065 066 /** 067 * Returns this sample, offset by the given timestamp. 068 * 069 * @param timestampOffset the offset to apply to the timestamp. 070 * @return this sample, offset by the given timestamp. 071 */ 072 Self offsetBy(double timestampOffset); 073}