Error compiling PX4 sitl (JSBsim)

Hi,

I’m compiling PX4 (v 1.12.3) for sitl with JSBsim on macOS 13.0.1 but I got the following error:

fatal error: variable ‘stat_thread’ set but not used [-Wunused-but-set-variable]

at step 343/815; I attach the complete terminal output to help in the solution of the issue.

PX4-SITL-error.pdf (33.2 KB)

I tried to solve the problem and looked for a solution on the internet but without success; any help is appreciated.

My setup is:

  • px4 1.12.3
  • macOS 13.0.1
  • cmake 3.25.0
  • python 3.9.6
  • C and CXX compiler AppleClang 14.0.0.14000029
  • JSBsim 1.1.12

Thanks

Nicolò

Edit: my problem seems similar to this one

https://github.com/ClickHouse/ClickHouse/issues/27705

but I don’t know how to replicate it.

I think the problem may be solved suppressing the warning in the make file, as suggested in

https://github.com/google/j2objc/issues/1883

and

https://github.com/google/j2objc/issues/1872

However, I don’t know where to write this command; can someone help me? @hamishwillee is this your field?

Thanks

Nope. I use Gazebo in a VM. @JulianOes mean anything to you, or could you suggest someone else to advise?

While waiting for an answer I’ve also opened an issue on the PX4 JSBsim GitHub repo:

https://github.com/Auterion/px4-jsbsim-bridge/issues/63

@JulianOes do you know how to solve this? Any help is appreciated

This is only a warning. If you don’t build with -Werror it will still build.

Thanks; I’m not so familiar with these settings, so it took me a little bit of time to figure it out. Now it works.

I modified the px4_add_common_flags.cmake file in PX4-Autopilot/cmake as suggested and it builds.

JSBsim sitl is working correctly and I can interface using QGC. However, I have another problem: flightgear visualization isn’t working.

Flightgear (v.2020.3.17) is correctly installed with home-brew and I can open it independently. I tried to perform a sitl simulation using only flightgear as proposed here but it failed due to errors.

@JulianOes, @roman-dvorak and/or @Jaeyoung-Lim can you help me please?

Hi, can you describe errors? Or provide cli output?

Yes, this is the terminal output:

FlightgearSITL.pdf (29.5 KB).

As suggested here I’ve added the path to flightgear binary. I tried also without the path but with the same result:

FlightgeraSITL_NoFGPath.pdf (29.6 KB).

@roman-dvorak did you have time to look at the files? Do I have to provide other material?
Thanks :slight_smile:

Sorry if I bother you again @roman-dvorak and @JulianOes; I’ve tried to solve the issue related to flightgear by myself but without success. I think it’s something related to my setup and/or OS since on another pc with Ubuntu it works fine. Can you provide any suggestion or help?

If you can help me, I appreciate it.

p.s. is it better to open a new thread since the topic is related to but different from the title?

What’s the actual error?

Is it just the one posted at the beginning? If so, that’s just a warning, so if you remove the -Werror flag it should be a warning rather than an error. You have to search for which -Werror you have to remove.

The initial error has been solved thanks to your suggestion: I removed the -Werror flag and the simulation with JSBsim worked, without visualization.

As next step, I tried a simulation using Flightgear for the visualization: the simulation stared but without visualization.

To understand if the problem is related to the interface between Flightgear and JSBsim or to Flightgear itself, I tried a simulation with Flightgear for both flight mechanics and visualization. The simulation didn’t work so I think the lack of visualization using JSBsim is primarily due to Flightgear itself. The terminal output obtained in this simulation with Flightgear only is this.

Ok, so reading the compiler output it looks like your compiler doesn’t understand the C++14 and later features such as constexpr. I assume the problem is not your compiler (AppleClang 14 is new enough).

What commands are you running to build this? Then I can reproduce this.

I simply open the terminal in the firmware folder and execute the command:

FG_BINARY="/Applications/FlightGear.app/Contents/MacOS/fgfs" make px4_sitl_nolockstep flightgear_rascal .

The only modification I made to the standard firmware available on Github (branch release/1.12) is that I commented out this line of code to suppress -Werror. Flightgear is the latest version avlaible through brew cask.

If I use the command:

make px4_sitl_nolockstep flightgear_rascal

I obtain the same result.

Ok. Any reason you are using v1.12 and not v1.13?

I’m using v1.12 since it’s the standard version adopted in my lab and some custom tools we use haven’t been tested on v1.13 already.

Try to add -std=c++17.

to this file:

It’s in Tools/flightgear_bridge/CMakeLists.txt.

Thanks a lot, adding -std=c++17 to line 22 solved this problem, now flightgear SITL works.

As next step I tried a simulation with JSBsim and flightgear for visualization but the lack of visualization is still there. I think the problem is that JSBsim bridge cannot find flightgear executable on mac, even if I use the command

FG_BINARY="/Applications/FlightGear.app/Contents/MacOS/fgfs" make px4_sitl jsbsim_ascl_vtol_mc ,

so providing the path to flightgear exec. Looking into the source code of the bridge I found that visualization through flightgear is launched from JSBsim itself, not in the bridge (these files included here are part of JSBsim). Probably the way I pass the path to flightgear is not correct, maybe it’s only the variable name.

Have you verified that path is correct? Can you start it like that?