Board index FlightGear Support Interfacing

SimpleSITL

Connecting two computers, using generic protocol, connecting with Matlab?

SimpleSITL

Postby kwikius » Fri May 28, 2021 11:49 pm

Hi All,
Great project Thankyou!

I got into FlightGear because of its use as a SITL viewer in ArduPilot.
Anyway after studying the ArduPilot source and also reading up on FlightGear and the FlighGear source, it seems that the way ArduPilot does it is kind of complicated:
https://github.com/ArduPilot/ardupilot/ ... JSBSim.cpp
... so I have been looking at a simpler way and it seems that it will work:

I use the readymade FlighGear telnet interface for sending in flight surface positions to FlightGear and the native_fdm out interface for reading the aircraft pose and environment data back in one big binary chunk,
All this was based largely on the examples in the FlightGear source code. Thankyou for those:
https://sourceforge.net/p/flightgear/fl ... es/netfdm/
https://sourceforge.net/p/flightgear/fl ... client.cxx
( though the netfdm is input to FlightGear rather than output, but I used it to get things started as shown here
)

I eventually got a demo working, which seems to meet the basic SITL requirements :
https://github.com/kwikius/fg_ext_fdm/b ... /io/io.cpp
So far all it does is read a joystick and send the controls in to FlightGear via telnet then read the net_fdm struct and output some of its data on the console, but things seem to be working. I can fly it around and FlightGear works pretty much as normal. The interface also seems relatively simple to understand compared to the ArduPilot version and I hope I can hook up my version of ArduPilot into this without too much difficulty.

Ideally someday I would like to make a custom FlightGear HUD as near as possible to the OSD as shown here:

but that is some way down the road!

Anyway, if I get any further with it I will keep you posted.

regards
Andy
kwikius
 
Posts: 7
Joined: Fri May 28, 2021 10:24 pm

Re: SimpleSITL

Postby kwikius » Tue Jun 15, 2021 4:20 pm

Continuing work on this.... After being able to send control surface commands to FlightGear and read the attitude and position data from FlighGear, the next obvious step is to start looking at autonomous flight.
As a first step, I tried to figure out how to move the control surfaces so as to correct any attitude error, the proportional part of a PID controller. I opted to try this in a simpler environment than FlightGear ( and one that takes less time to start up) so just started with an OpenGL simulation. It has some issues, but basically seems to work.



here is the source code

Next steps are to check all the corner cases , then repeat the process for differential error and eventually from there to get a straight and level controller working...
kwikius
 
Posts: 7
Joined: Fri May 28, 2021 10:24 pm

Re: SimpleSITL

Postby Hooray » Tue Jun 15, 2021 5:13 pm

Hi, that's looking really good - I guess other users might be interested in this sort of project.

Thus, I'd suggest considering to set up a dedicated wiki article to document your project, or at the very least, consider adding your project to the newsletter.

You can also upload screen shots/images to the wiki and embed youtube videos there.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: SimpleSITL

Postby kwikius » Tue Jun 15, 2021 11:50 pm

I created a wiki page under my user. It may take a while to work out the Wiki rules and regulations! Anyway it's is a start!
Last edited by Johan G on Wed Jun 16, 2021 2:38 am, edited 1 time in total.
Reason: Please do not quote the entire preceding post.
kwikius
 
Posts: 7
Joined: Fri May 28, 2021 10:24 pm

Re: SimpleSITL

Postby kwikius » Sat Jul 24, 2021 9:28 am

Update on this post.
On my system, it is only possible to get around 10 Hz consistent update rate for the flight data when using FlightGear in this fashion. Any faster and FlightGear just drops packets. I presume this is why ArduPilot used JSBSim direct. They could get a much higher update rate of the data for the autopilot from JSBsim, and then send position data to FlightGear at a lower rate that FlightGear can handle.

The 10 Hz restriction is OK if you just simulate larger and slower reacting planes though.
kwikius
 
Posts: 7
Joined: Fri May 28, 2021 10:24 pm


Return to Interfacing

Who is online

Users browsing this forum: No registered users and 3 guests