Skip to content

Commit 3857bba

Browse files
committed
[wpimath] Make TrajectorySample only contain time
This allows reusing the trajectory infrastructure for non-drivetrain trajectories.
1 parent c173fff commit 3857bba

119 files changed

Lines changed: 2625 additions & 1876 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

wpilibc/src/main/python/semiwrap/FieldObject2d.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
extra_includes:
22
- wpi/math/trajectory/DifferentialTrajectory.hpp
3-
- wpi/math/trajectory/SplineTrajectory.hpp
3+
- wpi/math/trajectory/DrivetrainSplineTrajectory.hpp
44
- wpi/math/trajectory/HolonomicTrajectory.hpp
55
- wpi/math/trajectory/Trajectory.hpp
66

@@ -22,8 +22,8 @@ classes:
2222
ignore: true
2323
SetTrajectory:
2424
template_impls:
25-
- [wpi::math::SplineSample]
2625
- [wpi::math::DifferentialSample]
26+
- [wpi::math::DrivetrainSplineSample]
2727
- [wpi::math::TrajectorySample]
2828
GetPoses:
2929
overloads:

wpilibcExamples/src/main/cpp/examples/SimpleDifferentialDriveSimulation/cpp/Robot.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class Robot : public wpi::TimedRobot {
5959
wpi::math::SlewRateLimiter<wpi::units::scalar> rotLimiter{3 / 1_s};
6060

6161
Drivetrain drive;
62-
wpi::math::SplineTrajectory trajectory;
62+
wpi::math::DrivetrainSplineTrajectory trajectory;
6363
wpi::math::LTVUnicycleController feedback{20_ms};
6464
wpi::Timer timer;
6565
};

wpilibj/src/main/java/org/wpilib/smartdashboard/FieldObject2d.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
import org.wpilib.math.geometry.Pose2d;
1313
import org.wpilib.math.geometry.Rotation2d;
1414
import org.wpilib.math.geometry.Translation2d;
15+
import org.wpilib.math.trajectory.HolonomicSample;
1516
import org.wpilib.math.trajectory.Trajectory;
16-
import org.wpilib.math.trajectory.TrajectorySample;
1717
import org.wpilib.networktables.DoubleArrayEntry;
1818
import org.wpilib.units.measure.Distance;
1919

@@ -107,7 +107,7 @@ public synchronized void setPoses(Pose2d... poses) {
107107
* @param <SampleType> The type of the trajectory sample.
108108
* @param trajectory The trajectory from which the poses should be added.
109109
*/
110-
public synchronized <SampleType extends TrajectorySample> void setTrajectory(
110+
public synchronized <SampleType extends HolonomicSample> void setTrajectory(
111111
Trajectory<SampleType> trajectory) {
112112
m_poses.clear();
113113
for (SampleType state : trajectory.getSamples()) {

wpilibjExamples/src/main/java/org/wpilib/examples/simpledifferentialdrivesimulation/Robot.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import org.wpilib.math.geometry.Pose2d;
1313
import org.wpilib.math.geometry.Rotation2d;
1414
import org.wpilib.math.kinematics.ChassisVelocities;
15-
import org.wpilib.math.trajectory.SplineSample;
15+
import org.wpilib.math.trajectory.DrivetrainSplineSample;
1616
import org.wpilib.math.trajectory.Trajectory;
1717
import org.wpilib.math.trajectory.TrajectoryConfig;
1818
import org.wpilib.math.trajectory.TrajectoryGenerator;
@@ -29,7 +29,7 @@ public class Robot extends TimedRobot {
2929
private final Drivetrain drive = new Drivetrain();
3030
private final LTVUnicycleController feedback = new LTVUnicycleController(0.020);
3131
private final Timer timer = new Timer();
32-
private final Trajectory<SplineSample> trajectory;
32+
private final Trajectory<DrivetrainSplineSample> trajectory;
3333

3434
/** Called once at the beginning of the robot program. */
3535
public Robot() {
@@ -55,7 +55,7 @@ public void autonomousInit() {
5555
@Override
5656
public void autonomousPeriodic() {
5757
double elapsed = timer.get();
58-
SplineSample reference = trajectory.sampleAt(elapsed);
58+
DrivetrainSplineSample reference = trajectory.sampleAt(elapsed);
5959
ChassisVelocities velocities = feedback.calculate(drive.getPose(), reference);
6060
drive.drive(velocities.vx, velocities.omega);
6161
}

wpimath/robotpy_pybind_build_info.bzl

Lines changed: 30 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wpimath/src/generated/main/java/org/wpilib/math/proto/ProtobufDifferentialSample.java

Lines changed: 29 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)