JSBSim-Team / jsbsim

An open source flight dynamics & control software library
GNU Lesser General Public License v2.1
1.33k stars 444 forks source link

Flightgear visualization not working on Ubuntu Focal #325

Open Jaeyoung-Lim opened 3 years ago

Jaeyoung-Lim commented 3 years ago

When running JSBSim on Ubuntu Focal, the flightgear visualization is not working,

image

I noticed the error

   11.00 [ALRT]:io         Error: version mismatch in FGNetNativeGUI2Props()
   11.00 [ALRT]:io              read 402653184 need 8
   11.00 [ALRT]:io              Need to upgrade net_fdm.hxx and recompile.

Where can I find the compatible versions of flightgear and jsbsim?

bcoconni commented 3 years ago

That's weird: a modification has been introduced recently in net_fdm.hxx in FlightGear but this should be not available before the next release.

In order to reproduce this error, we would need to know which versions of FlightGear and JSBSim you are using ?

Jaeyoung-Lim commented 3 years ago

The version is as the following

bcoconni commented 3 years ago

Ok so you are using the bleeding edge code from FlightGear. in that case, I would say that the easiest workaround in the short term is to use FlightGear 2020.2 instead.

Meanwhile I will investigate how to make JSBSim compatible with 2020.3

bcoconni commented 3 years ago

Just a heads up: I confirm that JSBSim is not compatible with FlightGear 2020.3 since the FDM protocol has been modified as I mentioned earlier. JSBSim network interface does indeed work with FlightGear 2020.2 or earlier so you can use one of these releases as a fallback for the time being.

I have reopened a ticket in FlightGear to raise our issue to their knowledge. Given that FlightGear 2020.2 will a be a LTS release and that the protocol has been changed in FlightGear 2020.3, I guess that our only viable option is to be compatible with both versions of the protocol.

Jaeyoung-Lim commented 3 years ago

@bcoconni Thanks!

bcoconni commented 3 years ago

@Jaeyoung-Lim I've just pushed a revision to handle both versions of FlightGear's FDM network protocol. You need to specify the version:

The version should be specified in the file data_output/flightgear.xml in the attribute version: https://github.com/JSBSim-Team/jsbsim/blob/b42f4238880ae1729acd55894381f74a0fe1ca13/data_output/flightgear.xml#L18-L19

The binary packages are available in our release section so could you please test and let us know if that works ? Thanks.

Jaeyoung-Lim commented 3 years ago

@bcoconni Thanks for the quick response,

I tried with

<output name="localhost" type="FLIGHTGEAR" protocol="UDP" port="5550" rate="60" version="25">
</output>

unfortunately, this still didn't work for me. (The vehicle doesn't move when the simulation is running.

This is the JSBSim FDM model that is being used, so I think this should be the latest release you are referring to

     JSBSim Flight Dynamics Model v1.1.0.dev1 [GitHub build 97/commit b42f4238880ae1729acd55894381f74a0fe1ca13] Oct  3 2020 16:56:25
            [JSBSim-ML v2.0]
bcoconni commented 3 years ago

OK that's unfortunate indeed. Could you please provide the exact sequence of commands you are using ? I'll see if I can reproduce the problem locally. If you are using some Python code, please provide as short as possible a piece of code that triggers the problem.

Also have you checked using FlightGear 2020.2 or earlier ? If so, did that fix the problem ?

bcoconni commented 3 years ago

@Jaeyoung-Lim Have you had the opportunity to investigate about the questions I asked ?

Jaeyoung-Lim commented 3 years ago

@bcoconni Sorry to come back so late. Unfortunately, trying Flightgear 2020.2 did not fix the issue

The sequence I am using is as the following, and is currently part of the PX4 autopilot project startup script

I start flightgear with

        fgfs --fdm=null \
            --native-fdm=socket,in,60,,5550,udp \
            --aircraft=$JSBSIM_AIRCRAFT_MODEL \
            --airport=${world} \
            --disable-hud \
            --disable-ai-models &> /dev/null &

and run a jsbsim bridge that we created

"${build_path}/build_jsbsim_bridge/jsbsim_bridge" ${model} -s "${src_path}/Tools/jsbsim_bridge/scene/${world}.xml" 2> /dev/null &

The bridge can be found in px4-jsbsim-bridge where the output format is selected here and the output directives are defined in flightgear.xml:

    _fdmexec->SetOutputDirectives(SGPath("data_out/flightgear.xml"));

Would help a lot if there are any obvious mistakes that I have made

bcoconni commented 3 years ago

@Jaeyoung-Lim Thanks. I will investigate that.

bcoconni commented 3 years ago

@Jaeyoung-Lim, some changes have been introduced to the socket code by the commit 4fdf246. As per @cgdae feedback, we have moved from non portable socket code (using ioctl(... FIONBIO ...)) to POSIX functions calls fnctl(... O_NONBLOCK ...) as per the explanation in this StackOverflow message.

Could you please test the code from HEAD of the master branch and let us know if that fixes the problem on Ubuntu 20.04 ? The compiled binaries are available in the Rolling release as usual.

N.B. If you plan to conduct your tests with FlightGear 2020.3, do not forget to set the version parameter to 25 in data_output/flightgear.xml as we discussed above.

Jaeyoung-Lim commented 3 years ago

@bcoconni Thanks!

I am wondering if there is something wrong with my system. I will try to test with a fresh system and report back

bcoconni commented 3 years ago

@Jaeyoung-Lim Any progress on that topic ?

Jaeyoung-Lim commented 3 years ago

@bcoconni Hi, I still can't get it to work even with a fresh system...

bcoconni commented 3 years ago

OK. I suggest to leave PX4 aside and to go back to basics. Can you run successfully the basic example from our README ?

layssi commented 6 days ago

I can confirm flightgear does not run in ubuntu