-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Potential Issue with Sequential Updates in savitskyGolayFilter Function #4665
Comments
I agree. Let me noodle on this a bit for how to improve it. There's a few things about this function I don't love so I might just rewrite it all now and fix this as part of it. This can be vastly simplified |
@XinyuKhan can you test and review #4669? |
I also found that control sequence shift operation will set the last control history and the first element in the un-shifted sequence to the same value, that cause there are two repeated element in the filter pipeline. |
Please comment inline the software in PR (if this is an issue wrt my new changes -- or the old method?), I'm not entire sure what you're pointing out 😄 We should fix that (if still there) before merging. |
@XinyuKhan can you please review? |
Since you didn't have time to review yet, I went through and really carefully parsed this to see what you meant. I think I understand what you mean, but I think this is correct.
This sets the last control history to the control_sequence that is about to be executed on the robot hardware (i.e. either shifted or unshifted, depending on the operational mode). In the next cycle, we resample, rescore, and resmooth so the value of If I understand what you mean properly, I think this points out that this is correct due to the trajectory rolling and sampling. |
Closing this and testing + merging the PR, thanks for the report @XinyuKhan ! It also gave me a good reason to rewrite this more cleanly. |
Description:
In the current implementation of the savitskyGolayFilter function, the Savitzky-Golay filter is applied in a sequential manner, where each updated value depends on previously updated values. This contradicts the standard approach of applying the Savitzky-Golay filter, where each value should be computed based on the original unmodified data.
For example, in the function applyFilterOverAxis, when updating sequence[idx], it uses sequence[idx-1], which may have already been updated in a previous step. This can lead to incorrect results, as the filter should always operate on the original data rather than the updated sequence.
Expected Behavior:
The filter should calculate new values based on the original sequence without using previously updated values. A possible solution is to store the filtered results in a temporary array and apply them to the sequence only after all points have been filtered.
Affected Code:
Suggested Fix:
Consider storing the filtered values in a separate temporary array to ensure each value is calculated using the original sequence data, and only update the sequence once all values are computed.
The text was updated successfully, but these errors were encountered: