Quantcast
Channel: gadget – Simple. Clean. Works!
Viewing all articles
Browse latest Browse all 5

cygwin: failed to build ArduPilot because of isnan / isinf

$
0
0

Upon building SITL on Windows 10 via cygwin following this tutorial: Setting up SITL on Windows, I encountered build error in this step :

cd ~/ardupilot/ArduCopter
make sitl -j4

Something like these (the original error is very long):

/home/achmadz/ardupilot/libraries/AP_Math/quaternion.h: In member function 'bool Quaternion::is_nan() const':
/home/achmadz/ardupilot/libraries/AP_Math/quaternion.h:51:24: error: 'isnan' was not declared in this scope
return isnan(q1) || isnan(q2) || isnan(q3) || isnan(q4);
^

So, it seems the libraries is trying to use isnan function but can’t find it.
The solution is quite simple (although I’m not sure if it’s the correct way, but hey.. my solution works!): we edit all .cpp and .h files inside ardupilot/libraries/ folder (and subfolders) and replace all isnan and isinf appearance into std::isnan and std::isinf, for example inside ardupilot/libraries/AP_AHRS/AP_AHRS.cpp line #271, replace:

if (isinf(_cos_roll) || isnan(_cos_roll)) {

into

if (std::isinf(_cos_roll) || std::isnan(_cos_roll)) {

to find files that references isnan and isinf, you can use find command (from within ardupilot/libraries/ folder) like this one:

find ./ -type f \( -iname "*.h" -o -iname "*.cpp" \) -exec grep --color=auto -inH 'isnan' {} \;

find all .h and .cpp files that contain "isnan" reference

find all .h and .cpp files that contain “isnan” reference

and for isinf:

find ./ -type f \( -iname "*.h" -o -iname "*.cpp" \) -exec grep --color=auto -inH 'isinf' {} \;

It’ll show you the files that need to be edited. (You might need to install nano to edit the files — just for convenience).

And done! You are good to go to build SITL in Windows!!

SITL running in windows 10 64bit

SITL running in windows 10 64bit


Viewing all articles
Browse latest Browse all 5

Latest Images

Trending Articles





Latest Images