Skip to content
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

Matrix B is 1x4 yet RebuildB tries to set it 2x4 data #48

Open
Pstoppani opened this issue Jul 26, 2019 · 2 comments
Open

Matrix B is 1x4 yet RebuildB tries to set it 2x4 data #48

Pstoppani opened this issue Jul 26, 2019 · 2 comments

Comments

@Pstoppani
Copy link

With asserts enabled, this crashes:

    private void rebuildB(double dtPredict) {
        double dt2 = 0.5*dtPredict*dtPredict;
        double b[] = {
                dt2, 0.0,
                0.0, dt2,
                dtPredict, 0.0,
                0.0, dtPredict
        };
        m_kf.B.setData(b); <-------  b is 1x4
    }
@Pstoppani
Copy link
Author

I believe the problem here is that the Kalman filter should be initialized with control matrix with dimension 2, not 1.

@Pstoppani
Copy link
Author

Pstoppani commented Jul 27, 2019

BTW - I had to change the assert() calls to:

        if (BuildConfig.DEBUG && !(args.length == rows * cols)) { throw new AssertionError(); }

The current Android Studio apparently no longer supports the old assert() function as indicated by the warning:

"Assertions are unreliable in Dalvik and unimplemented in ART. Use BuildConfig.DEBUG conditional checks instead. less... (⌘F1)

Inspection info:Assertions are not checked at runtime. There are ways to request that they be used by Dalvik (adb shell setprop debug.assert 1), but note that this is not implemented in ART (the newer runtime), and even in Dalvik the property is ignored in many places and can not be relied upon. Instead, perform conditional checking inside if (BuildConfig.DEBUG) { } blocks. That constant is a static final boolean which is true in debug builds and false in release builds, and the Java compiler completely removes all code inside the if-body from the app. For example, you can replace assert speed > 0 with if (BuildConfig.DEBUG && !(speed > 0)) { throw new AssertionError() }.

(Note: This lint check does not flag assertions purely asserting nullness or non-nullness; these are typically more intended for tools usage than runtime checks.) Issue id: Assert More info: https://code.google.com/p/android/issues/detail?id=65183"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant