[wpilib] FieldObject2d: Add setTrajectory() method (#3277)

This commit is contained in:
Prateek Machiraju
2021-04-02 01:08:07 -04:00
committed by GitHub
parent c97acd18e7
commit 8471c4fb26
3 changed files with 34 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ import edu.wpi.first.networktables.NetworkTableEntry;
import edu.wpi.first.wpilibj.geometry.Pose2d;
import edu.wpi.first.wpilibj.geometry.Rotation2d;
import edu.wpi.first.wpilibj.geometry.Translation2d;
import edu.wpi.first.wpilibj.trajectory.Trajectory;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.ArrayList;
@@ -84,6 +85,19 @@ public class FieldObject2d {
updateEntry();
}
/**
* Sets poses from a trajectory.
*
* @param trajectory The trajectory from which the poses should be added.
*/
public synchronized void setTrajectory(Trajectory trajectory) {
m_poses.clear();
for (Trajectory.State state : trajectory.getStates()) {
m_poses.add(state.poseMeters);
}
updateEntry();
}
/**
* Get multiple poses.
*