mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +00:00
[wpilib] FieldObject2d: Add setTrajectory() method (#3277)
This commit is contained in:
committed by
GitHub
parent
c97acd18e7
commit
8471c4fb26
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user