fcl icon indicating copy to clipboard operation
fcl copied to clipboard

InterpMotion: initialize reference_p to be zero.

Open xinyazhang opened this issue 3 years ago • 1 comments

The coefficients of Eigen::Vector3d, like other data types in Eigen3, are uninitialized by default.

This can be verified with the following code

#include <Eigen/Core>
#include <iostream>

int main() {
    {
        Eigen::Vector3d v;
        v << 1, 2, 3;
        std::cout << v(0) << " " << v(1) << " " << v(2) << std::endl;
    }
    {
        Eigen::Vector3d v;
        std::cout << v(0) << " " << v(1) << " " << v(2) << std::endl;
    }
    return 0;
}

This change is Reviewable

xinyazhang avatar Nov 19 '20 08:11 xinyazhang

Thanks for this fix. A few requests:

* Please describe the problem this fixes. What happens if reference_p is uninitialized?

* The problem exists in FCL because of the lack of unit tests in the original implementation. We have been following a policy of adding missing tests as we improve the code. Please add a unit test that would have failed with reference_p uninitialized and now succeeds because of your fix. That will prevent future programmers from breaking this code ever again.

Reviewed 1 of 1 files at r1. Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @xinyazhang)

Got it, will add unit tests later.

xinyazhang avatar Nov 19 '20 20:11 xinyazhang