-
Notifications
You must be signed in to change notification settings - Fork 0
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
questions about PredictNextPosition #2
Comments
I've found a c++ version, seem more correct, see below URL |
|
I've used to use this code in early implementations, but I don't like hardcoded if/else statements at all. |
below is my modified code. func (b *KalmanBlobie) PredictNextPosition(n int) {
account := min(n, len((*b).Track))
current := len((*b).Track) - 1
prev := current - 1
var deltaX, deltaY, sum = 0, 0, 0
for i := 1; i < int(account); i++ {
deltaX += (((*b).Track)[current].X - ((*b).Track)[prev].X) * (account - i)
deltaY += (((*b).Track)[current].Y - ((*b).Track)[prev].Y) * (account - i)
sum += i
current = prev
prev = current - 1
}
if sum > 0 {
deltaX /= sum
deltaY /= sum
}
(*b).PredictedNextPosition.X = (*b).Track[len((*b).Track)-1].X + deltaX
(*b).PredictedNextPosition.Y = (*b).Track[len((*b).Track)-1].Y + deltaY
} |
I've just updated your message for proper Go-code formatting if you don't mind. So how does it perform against current implementation? I need take a deeper look on this code. I think it is good idea to do tests with some drawing (for proof of conpect you know).... Something like this one https://github.com/LdDl/kalman-filter#usage but for two arrays of data: current position object and predicted (do not confuse 'predicted' with 'filtered'). |
first question regard variable prev and current, seems current is prev, prev is current
prev := len((*b).Track) - 1
current := prev - 1
second question in below loop
for i := 1; i < int(account); i++ {
deltaX += (((*b).Track)[current].X - ((*b).Track)[prev].X) * i
......
the value ((*b).Track)[current].X - ((*b).Track)[prev].X seems can compute before the loop
The text was updated successfully, but these errors were encountered: