Board index FlightGear Development AI Traffic

Populate AI Traffic with real traffic

Intelligent, computer controlled vehicles that drive/fly over the planet!

Re: Populate AI Traffic with real traffic

Postby F-JJTH » Fri Oct 26, 2012 10:44 pm

If I add "-DCMAKE_BUILD_TYPE=DEBUG" to my cmake command FGMS doesn't compile :
Code: Select all
clement@clement-laptop ~/fgms $ ./compile_fgms.sh
Remove existing build dir
Create build dir

*****************************************
CMAKE...
*****************************************

-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- *** set CXX FLAGS [ -Wall  -D_REENTRANT] C FLAGS [ -Wall  -D_REENTRANT]
-- *** Building static library STATIC
-- Found CURL: /usr/lib/x86_64-linux-gnu/libcurl.so
-- Looking for include files CMAKE_HAVE_PTHREAD_H
-- Looking for include files CMAKE_HAVE_PTHREAD_H - found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- *** target_link_libraries( fgms -lfg_server;-lMultiPlayer;-lPlib;-lSGdebug;-lpthread )
-- *** Will install binary to /usr/local/sbin
-- *** Will read config from /usr/local/etc
-- Configuring done
-- Generating done
-- Build files have been written to: /home/clement/fgms/build

*****************************************
MAKE...
*****************************************

Scanning dependencies of target MultiPlayer
[  8%] Building CXX object CMakeFiles/MultiPlayer.dir/src/flightgear/MultiPlayer/tiny_xdr.cxx.o
Linking CXX static library libMultiPlayerd.a
[  8%] Built target MultiPlayer
Scanning dependencies of target Plib
[ 16%] Building CXX object CMakeFiles/Plib.dir/src/plib/netSocket.cxx.o
Linking CXX static library libPlibd.a
[ 16%] Built target Plib
Scanning dependencies of target SGdebug
[ 25%] Building CXX object CMakeFiles/SGdebug.dir/src/simgear/debug/logstream.cxx.o
Linking CXX static library libSGdebugd.a
[ 25%] Built target SGdebug
Scanning dependencies of target fg_server
[ 33%] Building CXX object CMakeFiles/fg_server.dir/src/server/fg_server.cxx.o
[ 41%] Building CXX object CMakeFiles/fg_server.dir/src/server/fg_tracker.cxx.o
[ 50%] Building CXX object CMakeFiles/fg_server.dir/src/server/fg_config.cxx.o
[ 58%] Building CXX object CMakeFiles/fg_server.dir/src/server/fg_player.cxx.o
[ 66%] Building CXX object CMakeFiles/fg_server.dir/src/server/fg_aimgr.cxx.o
[ 75%] Building CXX object CMakeFiles/fg_server.dir/src/server/ai_item.cxx.o
[ 83%] Building CXX object CMakeFiles/fg_server.dir/src/server/daemon.cxx.o
[ 91%] Building CXX object CMakeFiles/fg_server.dir/src/server/fg_geometry.cxx.o
Linking CXX static library libfg_serverd.a
[ 91%] Built target fg_server
Scanning dependencies of target fgms
[100%] Building CXX object CMakeFiles/fgms.dir/src/server/main.cxx.o
Linking CXX executable fgms
/usr/bin/ld: cannot find -lfg_server
/usr/bin/ld: cannot find -lMultiPlayer
/usr/bin/ld: cannot find -lPlib
/usr/bin/ld: cannot find -lSGdebug
collect2: ld a retourné 1 code d'état d'exécution
make[2]: *** [fgms] Erreur 1
make[1]: *** [CMakeFiles/fgms.dir/all] Erreur 2
make: *** [all] Erreur 2

Copy src/server/fgms_example.conf to build/fgms.conf

*****************************************
*****************************************
Now you can run fgms with : cd build/ && ./fgms
*****************************************
*****************************************

clement@clement-laptop ~/fgms $


I don't know what is "gdb" :/

Here I haven't SegFault when the line is commented. Are you sure that's not a problem at your side ?

Since I'm not able to reproduce your SegFault here I'm not able to fix it. Here I compiled FGMS on 2 differents computer and launched FGMS with line commented. After more than 6 minutes there is no SegFault... It should be cool if another person can compile and run it in order to confirm the SegFault that you see.
Tomorrow I will try on a third computer...
User avatar
F-JJTH
 
Posts: 697
Joined: Fri Sep 09, 2011 11:02 am

Re: Populate AI Traffic with real traffic

Postby Hooray » Fri Oct 26, 2012 11:28 pm

If printing just the callsign via "std::cout" causes the segfault, you can be pretty sure that your pointers are not set up properly. Some pointer is probably invalid.

You have a number of nested pointers there in different classes, so it would be a good to check each pointer individually - you can dereference them step-by-step and move them to separate lines to get a better backtrace. Then, you'll quickly see which pointer is invalid. Also, make sure to check how you are copying the lists, and do a google search for "deep copy" and "copy constructor".
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: 11738
Joined: Tue Mar 25, 2008 8:40 am

Re: Populate AI Traffic with real traffic

Postby F-JJTH » Sat Oct 27, 2012 10:27 am

I found the problem :D It was my iterator/find that was incorrect. The old code was :
Code: Select all
m_AircraftListIt = m_AircraftList.find(hexcode); // We will search if this AI is present in the old list
if ( m_AircraftListIt != m_PrevAircraftList.end() ) // Searching in the old list if this AI is present
{
  // ...
}

the new code is :
Code: Select all
m_PrevAircraftListIt = m_PrevAircraftList.find(hexcode); // We will search if this AI is present in the old list
if ( m_PrevAircraftListIt != m_PrevAircraftList.end() ) // Searching in the old list if this AI is present
{
  // ...
}

It's pushed on git.

@Hooray: this morning I compiled and run FGMS on a third computer : no SegFault appears :/ I really don't understand/know why you have a SegFault but not me on 3 differents computer

On Git I've pushed some statistic that I'm already able to do (climb up/down or constant altitude, accelerate/decelerate or constant speed).
Next step : update the "AI in area selector" and start to make some complex math (calculate velocity)

Cheers,
Clément
User avatar
F-JJTH
 
Posts: 697
Joined: Fri Sep 09, 2011 11:02 am

Re: Populate AI Traffic with real traffic

Postby Hooray » Sat Oct 27, 2012 1:33 pm

pulled your latest changes and rebuilt everything, seeing your new stats, and things look really promising already:

Code: Select all
DL638 is new in the world
This AI use a constant speed, climb down
This AI use a constant speed, use a constant altitude
This AI use a constant speed, use a constant altitude
This AI use a constant speed, use a constant altitude
This AI use a constant speed, use a constant altitude
This AI use a constant speed, climb down
This AI use a constant speed, use a constant altitude
This AI use a constant speed, climb down
This AI use a constant speed, use a constant altitude
This AI use a constant speed, use a constant altitude
This AI use a constant speed, climb up
This AI decelerate, climb down
This AI use a constant speed, climb down
This AI use a constant speed, use a constant altitude
This AI use a constant speed, climb up
PR103 is new in the world
This AI use a constant speed, use a constant altitude
This AI use a constant speed, use a constant altitude
This AI use a constant speed, climb down
This AI use a constant speed, use a constant altitude
This AI use a constant speed, climb up
UA880 is new in the world
This AI use a constant speed, use a constant altitude


Regarding the segfault: I think it may disappear once all the race conditions are fixed, so that there are no more threading issues. Given that there's only a single additional thread being used, that should not be too hard. Possibly, we may want to use pthread barriers or pthread condition variables here instead to make the threading model a little more explicit and straightforward.
I'm sure we'll be able to fix everything!

BTW: Good job regarding the map::find() - which proves the point that the pointers were not valid (they could not be...)
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: 11738
Joined: Tue Mar 25, 2008 8:40 am

Re: Populate AI Traffic with real traffic

Postby F-JJTH » Sat Oct 27, 2012 1:51 pm

I've adapted the AI selector for std::map and started to have a look at the mathematic side... I'm not a great mathematician... the first hour is painful :P
(not yet pushed)
User avatar
F-JJTH
 
Posts: 697
Joined: Fri Sep 09, 2011 11:02 am

Re: Populate AI Traffic with real traffic

Postby Hooray » Sat Oct 27, 2012 2:13 pm

If you use Philosopher's approach, and just let the whole thing lag behind, it will be easier because you only need to interpolate between two known positions.
Like I mentioned earlier, most of the required math is already in place in SimGear, computing the new lat/lon/alt can be done like described here: viewtopic.php?f=23&t=17803&start=90#p169339

Next step : update the "AI in area selector" and start to make some complex math (calculate velocity)

Once you think about it, you can keep it simple and simply ALWAYS update positions for ALL aircraft.
Imagine a number of aircraft in the same place (i.e. 50+ multiplayer clients at KSFO) - if you always update the whole list, you only need to do the computations once if you only do it for each aircraft separately, then you will always need to re-do the calcuations.

PS: You could make it a little easier for others to look at your source and help with it by using shorter functions (methods) - whenever a method no longer fits onto the screen (needs scrolling), it would be a good idea to introduce another helper
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: 11738
Joined: Tue Mar 25, 2008 8:40 am

Re: Populate AI Traffic with real traffic

Postby polly » Sat Oct 27, 2012 5:07 pm

I hope you will give extrapolation due consideration: the calculations are of identical complexity with extrapolation adding the computed delta to the latest data point ( interpolation would subtract ). Interpolation results will be guaranteed to always mismatch actuality whereas, especially since most flight paths are linear, extrapolation will be close to exact for much of the time.
Consider, too, the result of interpolating the path of a craft taking just less than one data period between flare and having turned off the runway onto a taxiway heading; extrapolation would at least get the on-runway path bearing correct.
The big plus for extrapolation is for anyone intending to listen on e.g. liveatc.net, who will have a more accurate match between map and audio.
User avatar
polly
 
Posts: 455
Joined: Thu Nov 04, 2010 2:45 pm

Re: Populate AI Traffic with real traffic

Postby Hooray » Sat Oct 27, 2012 5:21 pm

Not disagreeing with any of your points - however, keep in mind that most of these services already use a certain offset/delay for security reasons, this includes TCAS but also AIS information reports shown on line.

Also, supporting ground operations (taxiing etc) opens a whole new can of worms.
Coming up with plausible aircraft orientation will be interesting enough using the data we have...

Trajectory computation isn't all that complex and can be approximated easily, but determining plausible pitch/roll/yaw values for each phase of flight will definitely be interesting, especially for different types of aircraft
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: 11738
Joined: Tue Mar 25, 2008 8:40 am

Re: Populate AI Traffic with real traffic

Postby F-JJTH » Sat Oct 27, 2012 10:20 pm

I seen your recent push. You done a lot of work in a little time !
I should admit that I don't know what will contain all these new file but I leave you do that as you want.
I just hope to understand what you do :)

Here i've introduce the MP packet constructor but I need some simgear/math/ files who are not present in FGMS. I don't know how to add them in the project. If I just copy/paste them from Simgear to FGMS I have a lot of error at compilation. I think that CmakeFiles need to be updated but I don't know how.

The MP packet constructor come from my precedent FGAIS project (standalone tool). In this tool I did a simple thing : copy/past all files from simgear/math in my fgais/simgear/math (of course some file wasn't interesting for me...) but here it seem to be hard to do because FGMS use already a file simgear/math/SGMath.hxx who is not identic to the simgear/mathSGMath.hxx provided by Simgear.

It seem that I need : SGVec3.hxx, SGQuat.hxx, SGGeod.hxx, SGGeoc.hxx ... hummm normally that's all. but maybe some dependace need more files.

Are you able to add these files to FGMS ? Or explain me how to do ? (adpataion of the CmakeFile)

PS: for remember, source code of my FGAIS standalone tool (who works) is here : http://clemaez.fr/flightgear/fgais_src.tar.gz Maybe it can help you to see all the math file that I need
User avatar
F-JJTH
 
Posts: 697
Joined: Fri Sep 09, 2011 11:02 am

Re: Populate AI Traffic with real traffic

Postby Hooray » Sat Oct 27, 2012 10:28 pm

Hi, there are two options:

1) add SimGear detection to CMakeLists.txt (can be copied from FlightGear's CMakeLists.txt)
2) copy the required cxx/hxx files to the simgear folder in fgms, and add them to the fgms CMakeLists.txt

When I added support for SimGear's SGThread, I simply copied the required files to the folder and then edited the CMakeLists.txt file, just look at my changes in CMakeLists.txt here: https://gitorious.org/~f-jjth/fgms/f-jj ... c694145f7a

Code: Select all
add_library( SGdebug ${LIB_TYPE} ${sgdebug_SRCS} ${sgdebug_HDRS})
191   ### add SGThread sources from SimGear
192   set( sgthread_SRCS src/simgear/threads/SGThread.cxx )
193   set( sgthread_HDRS src/simgear/threads/SGThread.hxx )
194   add_library( SGthread  ${LIB_TYPE} ${sgthread_SRCS} ${sgthread_HDRS})



As you can see, another line is used to append the new library - for all supported OS, i.e.:
list(APPEND add_LIBS -lSGdebug -lSGthread)
and
list(APPEND add_LIBS SGdebug SGthread)

But it's fairly simple actually
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: 11738
Joined: Tue Mar 25, 2008 8:40 am

Re: Populate AI Traffic with real traffic

Postby F-JJTH » Sun Oct 28, 2012 10:59 am

I found interesting source code in FG (as expected :) ) :

Some line who make interpolation : https://gitorious.org/fg/flightgear/blo ... xx#line252
Some line who make extrapolation : https://gitorious.org/fg/flightgear/blo ... xx#line342

My current problem is that I need a lot of simgear/math/ * files but they are not include in FGMS. i need to copy/paste them from simgear to FGMS. I've adapted the CMakeLists.txt but I've a lot of error during compilation. Also it seem that some FGMS source code need to be adapted to match the new simgear/math/ * files.

I will see that with Oliver (author of fgms)
User avatar
F-JJTH
 
Posts: 697
Joined: Fri Sep 09, 2011 11:02 am

Re: Populate AI Traffic with real traffic

Postby Hooray » Sun Oct 28, 2012 11:34 am

see my previous posting, you will either need to add all sources (cxx/hxx files) including their dependencies (other included files) OR simply modify CMakeLists.txt such that it depends on SimGear and so that you can automatically use all headers/libs directly. You can check FlightGear's top-level CMakeLists.txt file to see how it checks for SG.
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: 11738
Joined: Tue Mar 25, 2008 8:40 am

Re: Populate AI Traffic with real traffic

Postby F-JJTH » Sun Oct 28, 2012 12:23 pm

You can be sure that I've tried a lot of thing before said that I've a problem. I've spend 2 hours trying to adapt the CMakeLists.txt file.

I've tryed your technique without success, I've tried the simgear technique without success, I've tried a technique from another forum without success...
User avatar
F-JJTH
 
Posts: 697
Joined: Fri Sep 09, 2011 11:02 am

Re: Populate AI Traffic with real traffic

Postby Hooray » Sun Oct 28, 2012 1:26 pm

Ok, I have modified the cmake build system such that it now requires the latest SimGear version from git (2.9.0 !) - this makes it possible to easily use all SimGear headers and libraries without having to copy stuff manually. Let me know if it breaks anything for you
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: 11738
Joined: Tue Mar 25, 2008 8:40 am

Re: Populate AI Traffic with real traffic

Postby F-JJTH » Sun Oct 28, 2012 2:15 pm

Cool ! But I've have a compilation error.
Code: Select all
clement@clement-desktop ~/fgms $ cmake -D "CMAKE_PREFIX_PATH=../fgfs/install/simgear" ../

-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- *** set CXX FLAGS [ -Wall  -D_REENTRANT] C FLAGS [ -Wall  -D_REENTRANT]
-- *** Building static library STATIC
-- SimGear include directory: /home/clement/fgfs/install/simgear/include
-- found SimGear version: 2.9.0 (needed 2.9.0)
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.3.4")
-- Looking for include files CMAKE_HAVE_PTHREAD_H
-- Looking for include files CMAKE_HAVE_PTHREAD_H - found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- looking for static SimGear libraries
-- Looking for clock_gettime in rt
-- Looking for clock_gettime in rt - found
-- found SimGear libraries
-- Performing Test SIMGEAR_COMPILE_TEST
-- Performing Test SIMGEAR_COMPILE_TEST - Success
-- Found SimGear: optimized;/home/clement/fgfs/install/simgear/lib/libSimGearScene.a;debug;/home/clement/fgfs/install/simgear/lib/libSimGearScene.a;/home/clement/fgfs/install/simgear/lib/libSimGearCore.a;optimized;/home/clement/fgfs/install/simgear/lib/libSimGearCore.a;debug;/home/clement/fgfs/install/simgear/lib/libSimGearCore.a (Required is at least version "2.9.0")
-- Found CURL: /usr/lib/x86_64-linux-gnu/libcurl.so
-- *** target_link_libraries( fgms -lfg_server;-lMultiPlayer;-lPlib;-lSGdebug;-lSGthread;-lpthread )
-- *** Will install binary to /usr/local/sbin
-- *** Will read config from /usr/local/etc
-- Configuring done
-- Generating done
-- Build files have been written to: /home/clement/fgms/build

*****************************************
MAKE...
*****************************************

Scanning dependencies of target MultiPlayer
[  7%] Building CXX object CMakeFiles/MultiPlayer.dir/src/flightgear/MultiPlayer/tiny_xdr.cxx.o
Linking CXX static library libMultiPlayer.a
[  7%] Built target MultiPlayer
Scanning dependencies of target Plib
[ 14%] Building CXX object CMakeFiles/Plib.dir/src/plib/netSocket.cxx.o
Linking CXX static library libPlib.a
[ 14%] Built target Plib
Scanning dependencies of target SGdebug
[ 21%] Building CXX object CMakeFiles/SGdebug.dir/src/simgear/debug/logstream.cxx.o
Linking CXX static library libSGdebug.a
[ 21%] Built target SGdebug
Scanning dependencies of target fg_server
[ 28%] Building CXX object CMakeFiles/fg_server.dir/src/server/fg_server.cxx.o
[ 35%] Building CXX object CMakeFiles/fg_server.dir/src/server/fg_tracker.cxx.o
[ 42%] Building CXX object CMakeFiles/fg_server.dir/src/server/fg_config.cxx.o
[ 50%] Building CXX object CMakeFiles/fg_server.dir/src/server/fg_player.cxx.o
[ 57%] Building CXX object CMakeFiles/fg_server.dir/src/server/fg_aimgr.cxx.o
[ 64%] Building CXX object CMakeFiles/fg_server.dir/src/server/ai_item.cxx.o
[ 71%] Building CXX object CMakeFiles/fg_server.dir/src/server/PlanefinderProvider.cxx.o
[ 78%] Building CXX object CMakeFiles/fg_server.dir/src/server/HTTPSource.cxx.o
[ 85%] Building CXX object CMakeFiles/fg_server.dir/src/server/daemon.cxx.o
[ 92%] Building CXX object CMakeFiles/fg_server.dir/src/server/fg_geometry.cxx.o
Linking CXX static library libfg_server.a
[ 92%] Built target fg_server
Scanning dependencies of target fgms
[100%] Building CXX object CMakeFiles/fgms.dir/src/server/main.cxx.o
Linking CXX executable fgms
/usr/bin/ld: cannot find -lSGthread
collect2: ld a retourné 1 code d'état d'exécution
make[2]: *** [fgms] Erreur 1
make[1]: *** [CMakeFiles/fgms.dir/all] Erreur 2
make: *** [all] Erreur 2

clement@clement-desktop ~/fgms $
User avatar
F-JJTH
 
Posts: 697
Joined: Fri Sep 09, 2011 11:02 am

PreviousNext

Return to AI Traffic

Who is online

Users browsing this forum: No registered users and 1 guest