Board index FlightGear Development Scenery

How to creat moving traffic

Questions and discussion about enhancing and populating the FlightGear world.

How to creat moving traffic

Postby dtlan201 » Sat Nov 15, 2014 1:20 am

Could anyone help me to creat something like this ?

dtlan201
 
Posts: 187
Joined: Sun Sep 29, 2013 3:49 am
Callsign: MIA0774
Version: 3.7
OS: Windows 7

Re: How to creat moving traffic

Postby Hooray » Sat Nov 15, 2014 6:17 am

The hard-coded AI traffic system isn't yet sufficiently flexible for this kind of ground traffic - also, the underlying vector data for road networks must be available, too.
There's a wiki article giving a summary of the main limitations for these applications at: http://wiki.flightgear.org/Status_of_AI_in_FlightGear

For now, the most straightforward approach would involve using Nasal scripting for creating and controlling independent AI objects, e.g. as per: http://wiki.flightgear.org/Scripted_AI_Objects

As you can see on the wiki, this is currently being worked on, and the Nasal module is already fairly easy to use:
Image
Image

While these may seem like "aircraft", to FlightGear these are just 3D models that are updated each frame, i.e. by setting position, orientation etc
The same thing could be done using 3D models for ground traffic.
Or even for ships/vessels (another long-standing feature request): viewtopic.php?f=6&t=23799

The main problem here is that the underlying code was never designed with this in mind, so isn't necessarily "efficient".

A more promising/better-performing approach would involve using shaders, as per a number of "traffic shader" discussions we've had (especially affected by OSM2City):

What effects are we missing?
Thorsten wrote:If we have linear features like roads mapped in the proper direction and classified into left and right lanes, we could add overlay textures and normalmaps with the shader (think urban effect) and translate them with time, creating the semblance of traffic (like the urban effect, this would break at low altitude, but from reasonably high up might look credible)



osm2city.py development
radi wrote:
I found it in the older LOWI_roads folder: fgdata/Effects.

Ah, right. Note that there are two road effects, and fgdata/Effects/road*eff is Emilian's traffic shader. Though the correct way of using it would be to set TRAFFIC_SHADER_ENABLE = True and then run roads.py.


osm2city.py development
radi wrote:Thorsten, can I make a wish for a shader you suggested a while ago: red and white dots moving in opposite directions, please?


osm2city.py development
radi wrote:
I found it in the older LOWI_roads folder: fgdata/Effects.

Ah, right. Note that there are two road effects, and fgdata/Effects/road*eff is Emilian's traffic shader. Though the correct way of using it would be to set TRAFFIC_SHADER_ENABLE = True and then run roads.py.


osm2city.py development
radi wrote:Image
Thanks Emilian!



This should be the most efficient technology in terms of GPU load - but it will obviously only work for certain situations (i.e. high-altitude) and only for hardware with GLSL/shader support.
Now, the main limitation is having access to usable vector data and visualizing it in FG properly - osm2city is most promising here - but for actually animating traffic properly, this would probably be the "right" approach:


realistic urban car traffic? (sumo+vamos fdm+AI)
miercovich wrote:Hello !
I am interested in educational use of flightgear for an academic project. Part of this will require a richer scenery with urban traffic.

After having looked at the documentation, I understand there is a multiplayer feature in flightgear, as well as generic protocol system for creating custom network protocols, is that true?
Can these systems be used to drive AI ground traffic (cars) on flightgear scenery roads using a network protocol?

If this is not currently possible, would it be possible to create such a custom protocol for doing just that? I am thinking in terms of just GPS coordinates for a number of cars, that get updated at a rate of about 0.1-2 hz, depending on the viewer distance (high priority at low altitudes with high visibility).

I also understand that there is a patch available for flightgear to support the vamos automotive simulator as the fdm: http://www.mail-archive.com/flightgear- ... 22899.html
Image

Then, there is the open source sumo project for simulating urban traffic. Sumo can simulate random urban traffic patterns and uses shape files for moving traffic along real existing roads, in addition it is possible to replay actual recorded real life traffic data. So this would be a great way for populating the scenery.
Image

My question is: Can these features together be used to drive realistic AI road traffic in flightgear from another application (sumo)?
I don't just mean a single AI car, but posssibly hundreds at once to create the impression of realistic traffic driving through the scenery. Like I mentioned, sumo can provide all the traffic information. Flightgear would just need a way to turn the traffic information (positions) into AI objects and move/animate the cars accordingly (using the vamos fdm).

If this is currently not yet possible, what changes would be necessary to support this feature? Could this be added with some scripting, or would we need to look into the C++ source code?
And is anybody working on this or also interested in this idea? What would be the most appropriate (or recommended) route to go about implementing this?

In programmer terms, the following 3 questions are most interesting at the moment:
- can AI traffic be created and controlled using a network protocol?
- can flightgear be used (or made) to accept a sumo feed (positions of car objects)?
- and can these positions then be used to to tell the vamos fdm to move the AI cars realistically?

Thank you very much

- miercovich
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: 11569
Joined: Tue Mar 25, 2008 8:40 am

Re: How to creat moving traffic

Postby ludomotico » Sat Nov 15, 2014 7:19 am

Funnily, I worked on the Skylink at Dallas during last night. I already have some spaghetti nasal code that manages any number of trains in a closed, circular circuit of about 7km (5miles) During this weekend I'm planning to clean a bit the code, texture the models and submit to terrasync.
User avatar
ludomotico
 
Posts: 1046
Joined: Tue Apr 24, 2012 1:01 pm
Version: git
OS: Debian GNU/Linux

Re: How to creat moving traffic

Postby dtlan201 » Sat Nov 15, 2014 4:09 pm

I'm trying to research osm2city base on the wiki page. But there are some points at the installation that I still not understand. Could you please take some screenshots so I have some clues to follow?
Thanks for help
Lan
dtlan201
 
Posts: 187
Joined: Sun Sep 29, 2013 3:49 am
Callsign: MIA0774
Version: 3.7
OS: Windows 7


Return to Scenery

Who is online

Users browsing this forum: No registered users and 1 guest