mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
[wpimath] ExponentialProfile: Return copy of input state (#6370)
As State is mutable, this avoids accidental modification of the passed-in object by the caller modifying the return value.
This commit is contained in:
@@ -191,7 +191,7 @@ public class ExponentialProfile {
|
||||
var timing = calculateProfileTiming(current, inflectionPoint, goal, u);
|
||||
|
||||
if (t < 0) {
|
||||
return current;
|
||||
return new State(current.position, current.velocity);
|
||||
} else if (t < timing.inflectionTime) {
|
||||
return new State(
|
||||
computeDistanceFromTime(t, u, current), computeVelocityFromTime(t, u, current));
|
||||
@@ -200,7 +200,7 @@ public class ExponentialProfile {
|
||||
computeDistanceFromTime(t - timing.totalTime, -u, goal),
|
||||
computeVelocityFromTime(t - timing.totalTime, -u, goal));
|
||||
} else {
|
||||
return goal;
|
||||
return new State(goal.position, goal.velocity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user