Fix using wrong quadratic solution for timestep #1490
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
In each iteration of the
Check
function, we solve for the next time step to check for constraints by solving a quadratic equation. The next time step to do constraint checking is the time step such that the jointnLargestStepIndex
moves for an amount of its resolution.Relevant codes are as follows
When the current time step is near the inflection time and we expect to the next time step to be after the inflection time,
fMinNextTimeStep
should be set tofLargestInflectionTime
. The valuefMinNextTimeStep
will be used later on to choose an appropriate solution of the following quadratic equationThe Issue
fMinNextTimeStep
should stay the same for the sameistep
. However, the following situation happensj
bComputeNewStep
istrue
so we proceed to computefBestNewStep
as usual.fMinNextTimeStep
is also modified to be the inflection timefLargestInflectionTime
.t_next > fLargestInflectionTime
.istep
does not get incremented because the reached time step ist_reached < fLargestInflectionTime
.bComputeNewStep
is nowfalse
because we should be using the samefBestNewStep
in the following iteration.j + 1
istep
remains the same as in iterationj
. ButfMinNextTimeStep
gets reset toprevtimestep
(which is nowt_reached
).t_next < fLargestInflectionTime
(due to the wrongly setfMinNextTimeStep
.istep
gets incremented while not having reachedfBestNewStep
yet. This messes up the counting ofistep
.istep
can reachnumSteps
while the function does not yet reach the end point of the ramp.This causes an error in parabolic smoother (function
SegmentFeasible2
) when it checks if the returned configurations from theCheck
function actually reached the desired values.The Fix
Make sure that
fMinNextTimeStep
gets computed correctly even whenbComputeNewStep = false
.