mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-30 02:31:44 +00:00
Fix duplicated state when using quintic splines (#2307)
Generating a trajectory using quintic splines caused a duplicated state at all knot points.
This commit is contained in:
committed by
Peter Johnson
parent
7797da78f5
commit
558c020cca
@@ -1,5 +1,5 @@
|
|||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
|
/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */
|
||||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||||
/* the project. */
|
/* the project. */
|
||||||
@@ -166,7 +166,12 @@ SplineHelper::QuinticControlVectorsFromWaypoints(
|
|||||||
const auto scalar =
|
const auto scalar =
|
||||||
1.2 * p0.Translation().Distance(p1.Translation()).to<double>();
|
1.2 * p0.Translation().Distance(p1.Translation()).to<double>();
|
||||||
|
|
||||||
vectors.push_back(QuinticControlVector(scalar, p0));
|
// Only add the first control vector if this is the first iteration. The
|
||||||
|
// last control vector of this iteration is the first control vector of
|
||||||
|
// the next iteration.
|
||||||
|
if (i == 0) {
|
||||||
|
vectors.push_back(QuinticControlVector(scalar, p0));
|
||||||
|
}
|
||||||
vectors.push_back(QuinticControlVector(scalar, p1));
|
vectors.push_back(QuinticControlVector(scalar, p1));
|
||||||
}
|
}
|
||||||
return vectors;
|
return vectors;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
|
/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */
|
||||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||||
/* the project. */
|
/* the project. */
|
||||||
@@ -69,7 +69,13 @@ public final class SplineHelper {
|
|||||||
// This just makes the splines look better.
|
// This just makes the splines look better.
|
||||||
final var scalar = 1.2 * p0.getTranslation().getDistance(p1.getTranslation());
|
final var scalar = 1.2 * p0.getTranslation().getDistance(p1.getTranslation());
|
||||||
|
|
||||||
vectors.add(getQuinticControlVector(scalar, p0));
|
// Only add the first control vector if this is the first iteration. The
|
||||||
|
// last control vector of this iteration is the first control vector of
|
||||||
|
// the next iteration.
|
||||||
|
if (i == 0) {
|
||||||
|
vectors.add(getQuinticControlVector(scalar, p0));
|
||||||
|
}
|
||||||
|
|
||||||
vectors.add(getQuinticControlVector(scalar, p1));
|
vectors.add(getQuinticControlVector(scalar, p1));
|
||||||
}
|
}
|
||||||
return vectors;
|
return vectors;
|
||||||
|
|||||||
Reference in New Issue
Block a user