Open BallscrewBob opened 7 years ago
C++ doesn't like Type Punning. You would have to deactive checking for strict-aliasing in your compiler, which I wouldn't recommend. Simply replace fastInvSquare() by math.h 1/sqrt(). The speedloss is insignificant.
@facchinm can you explain how to rectify this error(approach)
Simply replace fastInvSquare() by math.h 1/sqrt()
I am with thekunalsaini as I get the same error and don't understand the fix. Do I have to search and replace fastInvSquare() by math.h 1/sqrt()? In what file? Sorry if its a stupid question but I just don't understand it.
Sorry but if I replace float Madgwick::invSqrt(float x) {
with float math.h 1/sqrt(float x) {
it (understandably) throws an error.
math.h is the header containing sqrt()
you can replace
float Madgwick::invSqrt(float x) { float halfx = 0.5f * x; float y = x; long i = *(long*)&y; i = 0x5f3759df - (i>>1); y = *(float*)&i; y = y * (1.5f - (halfx * y * y)); y = y * (1.5f - (halfx * y * y)); return y; }
by
float Madgwick::invSqrt(float x) { return 1/sqrt(x); }
In the desktop IDE I get a couple of "warnings" but in the ONLINE editor CREATE I get a compilation failure with the following output.