Servers by jDrones

A compile error about sitl

I setup the ardupilot SITL following this tutorial(https://ardupilot.org/dev/docs/setting-up-sitl-on-linux.html).
When I run the command ‘sim_vehicle.py -w’, a compile error occured like below:

 ......
[616/697] Compiling libraries/AC_Avoidance/AP_OAPathPlanner.cpp
[617/697] Compiling libraries/AP_ADSB/AP_ADSB.cpp
[618/697] Compiling libraries/AP_GyroFFT/AP_GyroFFT.cpp
[619/697] Compiling libraries/AP_RCTelemetry/AP_RCTelemetry.cpp
../../libraries/AP_GyroFFT/AP_GyroFFT.cpp: In member function ‘uint16_t AP_GyroFFT::run_cycle()’:
../../libraries/AP_GyroFFT/AP_GyroFFT.cpp:387:33: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
     if (gyro_buffer.available() > _state->_window_size + uint16_t(_samples_per_frame >> 1)) { // half the frame size is a heuristic
                                 ^
compilation terminated due to -Wfatal-errors.
cc1plus: some warnings being treated as errors

Waf: Leaving directory `/home/ubuntu-li/ardupilot/build/sitl'
Build failed
 -> task in 'objs/AP_GyroFFT/ArduCopter' failed (exit status 1): 
	{task 139976827606392: cxx AP_GyroFFT.cpp -> AP_GyroFFT.cpp.3.o}
 (run with -v to display more information)
SIM_VEHICLE: Build failed
SIM_VEHICLE: Killing tasks
SIM_VEHICLE: kill_tasks failed: 'Process' object has no attribute 'environ'

What can I do for this error, anyone can help me?

You’re not doing anything wrong.

That’s a bug in the code.

@andyp1per

A patch like this might get you going:

diff --git a/libraries/AP_GyroFFT/AP_GyroFFT.cpp b/libraries/AP_GyroFFT/AP_GyroFFT.cpp
index 849be3ebe6..ebf9277f0a 100644
--- a/libraries/AP_GyroFFT/AP_GyroFFT.cpp
+++ b/libraries/AP_GyroFFT/AP_GyroFFT.cpp
@@ -384,7 +384,7 @@ uint16_t AP_GyroFFT::run_cycle()
     FloatBuffer& gyro_buffer = (_sample_mode == 0 ?_ins->get_raw_gyro_window(_update_axis) : _downsampled_gyro_data[_update_axis]);
     // if we have many more samples than the window size then we are struggling to 
     // stay ahead of the gyro loop so drop samples so that this cycle will use all available samples
-    if (gyro_buffer.available() > _state->_window_size + uint16_t(_samples_per_frame >> 1)) { // half the frame size is a heuristic
+    if (gyro_buffer.available() > unsigned(_state->_window_size + uint16_t(_samples_per_frame >> 1))) { // half the frame size is a heuristic
         gyro_buffer.advance(gyro_buffer.available() - _state->_window_size);
     }
     // let's go!

(that’s probably not the correct fix, but you probably don’t care about that!)

Maybe you should change the uint16_t to int

@githublearner-li - what compiler and version are you using?

This code compiles in CI and is technically correct, there is something more weird going on here.
My compiler version (which it compiles fine with) is:

andy@Eagle:~/github/ardupilot-dev$ g++ --version
g++ (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Copyright © 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Thank you! I will try it:)

My compiler and version is shown below:

g++ (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

is it outdated or do I need to update it to the newest version?

It works! Thank you so much !

OK, I think this problem has been solved with you guys’ help :smiley: Thanks for your help!

@githublearner-li how did you solve this problem??

Hi,

running into the same issue, how did you fix it?

Use gcc 6 or later

More words

awesome thanks for that.

Fixed it by updating my gcc version, instructions here: https://gist.github.com/zuyu/7d5682a5c75282c596449758d21db5ed

I’m so sorry to answer you so late and congratulations on solving this problem. I solved this error by @peterbarker 's patch as written above(A compile error about sitl).

The whole process is:

  1. open the ardupilot folder in your machine, find the ../libraries/AP_GyroFFT/AP_GyroFFT.cpp and open it.
  2. find this the line 387: if (gyro_buffer.available() > _state->_window_size + uint16_t(_samples_per_frame >> 1)) { // half the frame size is a heuristic
  3. change it to if (gyro_buffer.available() > unsigned(_state->_window_size + uint16_t(_samples_per_frame >> 1))) { // half the frame size is a heuristic
  4. compile it again and you will find it works.

Updating GCC works like a charm thank you.

Servers by jDrones