Board index FlightGear Support Interfacing

Smoothing with external FDM and multiplayer

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

Smoothing with external FDM and multiplayer

Postby techyCoder81 » Mon Jun 03, 2019 7:09 pm

I apologize in advance if I don't explain what im doing well enough...

So I've been trying to figure out a way around a problem I've had for about a week or so now. I'm using flightgear as a visualization for the real position and flight paths of a group of 3 objects. What I've done is I have set up my own C# program to launch and maintain 4 flightgear instances on a single computer, which are set up with "--multiplay" command line arguments between them. I then use a generic protocol to route position and orientation data to these 4 craft. 3 of these instances, i launch at the smallest possible resolution, and the 4th is launched as the primary viewing window for the system. The """camera""" instance is using really small cube as the actual model, and it serves as a camera essentially. My program then sends position and orientation data to each of these 4 instances over a generic protocol, and then the "camera" FG instance is able to see the position of all of the 3 main craft over the multiplayer connection setup with command line arguments.

All of this works just fine, but theres one problem that i havent been able to solve. When I move the "camera" instance, if im in 3rd person view, it of course jumps to the new position. The other 3 instances receive their updated positions at the same time, and then over the multipla,y move to their new position smoothly. But, visually, the motion isnt smooth because i directly move the primary "camera" instance to its new position. So even if this happens at a reasonable enough fps for semi-smooth motion (like maybe 10 or so), it looks bad because the camera moves instantly, but the 3 multiplayer instances then update slightly slowly, because of the nature multiplayer. I've been considering experimenting with setting up an on-the-fly view on the primary instance, which is always centered on one of the 3 multiplayer instances, such that, rather than looking at the small cube, it looks at that particular model. I havent had any luck with that so far, and im not even sure thats really the best solution. I was kind of hoping there might be a built in way so that, when i move the "camera" instance (small cube), the actual FG view itself moves smoothly to this new location. I know this is probably a pretty hacky solution to the problem, but im running out of ideas on how to make this work better. Thoughts?

edit: to clarify, two of the 3 craft are directly inside each other originally. Its like a package being dropped from a plane, onto a target platform. The package, the plane, the target, and the camera instances of FG are being sent positions and orientations with an external fdm over a generic protocol, and are then exchanging multiplayer data over localhost.

edit 2: I've tried to set up a lookat view referencing /ai/models/multiplayer[3]/position/ for the positions and orientations of the relevant model, but this causes flightgear to get stuck on loading scenery. I presume this is because the multiplayer system hasnt been setup yet, and therefore that directory does not exist == it gets stuck. Not sure how i could work around that... I'm starting to get the sneaking suspicion that I'm going to have to learn Nasal.
techyCoder81
 
Posts: 3
Joined: Mon Jun 03, 2019 6:49 pm

Re: Smoothing with external FDM and multiplayer

Postby techyCoder81 » Thu Jun 06, 2019 3:30 pm

Just thought I'd update:

I've been learning nasal, and wow this makes my life so much easier. I am no longer using multiplayer at all, and instead I'm using an AI scenario. I'm using a generic protocol to create and set a bunch of properties, and then using a nasal script every frame to map each of those properties to the appropriate models from the AI scenario. It's working quite well, however I do have a new issue. I would like to be able to update an /ai/models/static object's model offsets on the fly. However, i cannot seem to find the appropriate property to modify with nasal to achieve this effect. Here's my scenario, and my aircraft model xml:

Code (scenario.xml): Select all
<?xml version="1.0"?>
<PropertyList>
<scenario>
<name>sgm flight scenario</name>
<description>This scenario is used to demonstrate the flightpath with targets and launch craft</description>
<entry>
<callsign>object-nasal</callsign>
<type>static</type>
<class>jet_transport</class>
<model>Aircraft/target-truck/Models/aircraft.xml</model> <!-- this is the one i need to modify the offsets for -->
</entry>
</scenario>
</PropertyList>


aircraft xml file:

Code (aircraft.xml): Select all
<?xml version="1.0"?>
<PropertyList>
<path>aircraft.ac</path>
<offsets>
<x-m>5</x-m>
<y-m>0</y-m>
<z-m>0</z-m>
</offsets>
</PropertyList>


Important to note is that this does offset the aircraft by 5 meters when launched. However, I cant seem to find anywhere in the property tree where i can modify this value. How would i do that?
techyCoder81
 
Posts: 3
Joined: Mon Jun 03, 2019 6:49 pm


Return to Interfacing

Who is online

Users browsing this forum: No registered users and 1 guest

cron