• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

FSX with Multiple Viewpoints using Simconnect

Messages
9
Country
us-arkansas
Hey Guys,

I am working on a project to make FSX work on a Virtual Reality System at my university. I am aware of FSWideView but am interested in attempting to do this without using it.

Basically, I want to use 4 separate computers to create 3 outside views and that shows the cockpits controls. So, this would be 4 total machines.

I am wondering if this is possible using simconnect?

Thanks,

Daniel
 
Multichannel view

Hi Daniel,
If you want to go your own way, I can tell you the methods I tested out:
If you have a single strong computer and one or more graphics adapter in the machine, which can drive the requested number of monitors, you can define different camera views for each monitor. With a little tweaking you can have a 3 channel cockpit view and an instrument panel view. This method does not need any software development and can be done in a couple of hours. I use this method on a 12 Gb I7-980 with a 2GB ATI Double GPU graphics adapter. The disadvantage is, that FSX has a known error. It does not restore the correct window size on the next start. The different channel windows come up but you have to resize the windows manually.

If you want to use 4 computers then you have to deliver Latitude, Longitude, altitude, yaw, pitch and roll as broadcast over the local network. On the receiving target computers you have to setup an AI aircraft which is disconnected from FS-Control. You need to send the 6 values to the AI aircraft. Even here you need to define the camera view to get the 3 channel cockpit view. The disadvantage here is the latency over the network. It may be that the movement of the 3 channels is a bit asynchrony. All this can be controlled via SimConnect.
Regards
Mike
 
As long as all 4 screens can drag windows to and from, then it will take 1 minute. Just click view open new window and drag!

DG:eek:
 
Towsim,

Thanks for the nice reply. Unfortunately, the only option with the setup is to use 4 separate computers. Otherwise, we would have to change the setup of the projectors and PCs every time we used this particular setup with FSX. So, I'm certain we cannot do that.

I like the way you explained it. Looking at the documentation it makes sense. Would the other machines be able to use just the simconnect client or would they each need a full copy of FSX?

Thanks,

Daniel
 
FSX Multichannel

Hi Daniel,
you would need a FSX on each computer. SimConnect would be used on the host (I assume the computer with the instrument panels) to record the position and attitude data. The data have to be sent to the LAN as broadcast. I prefer the DIS protocol because it covers all the needs for flight simulation. If it is only for the 6 values, it would be easier to create an own small protocol. The target machines have a FSX running and receive the Attitude and position data. The data have then to be fed into the local FSX via SimConnect. With this setup you have even the possibility for a remote control of the computers acting as image generator. But this must be programmed in your interface software. You can send a trigger to the image generators to load the right aerodrome, setup the AI aircraft and switch the view to the AI cockpit.
Another possibility would be to connect as SimConnect client directly over the network. But this does not work for your case. You have to contact your local FSX with SimConnect and with a second instance the FSX on the host. If I remember right, you can start only one SimConnect instance for a FSX on a single machine. A way out would be to use FSUIPC as second interface to the local FSX.
Regards
Mike
 
FSX Multichannel

To clarify my explanation, see the attached image.
Regards
Mike
 

Attachments

  • MultiChannel.jpg
    MultiChannel.jpg
    73.2 KB · Views: 1,416
Would a network solve that issue, so you can drag windows to other screens, or other computers on the network? Then you avoid Simconnect.

I figure you have only 1 computer running the game. And the others on a network. I never use multiple computers, so I am not sure what's doing what.

By the way if you save a flight as default, you save all your setups and screens. Not 100% on extra windows.

DG:rolleyes:
 
The best/easiest way to implement something like this with FSX/ESP would be to write a SimConnect in-proc DLL addon that runs on each of the slave/view machines, and this addon would create two SimConnect connections, a local one to the sim it's running inside of, and a network connection to the host machine -this way, SimConnect becomes your network protocol. On the slave machines, you would set the user's SimObject's "Sim Disabled" SimVar to true, and then you can move the object around yourself based on data received from the host (might also need to send the 3 Freeze events as well, not sure).

You can request as little, or as much data, as you want (if you care about the flaps, ailerons, etc animations, then request those values and pass along to the local system, if you don't care about those animations, don't request/pass along those values :->.

You could also upgrade to Lockheed Martin's Prepar3d, which includes a multi-channel capability, built using the existing Multiplayer and Shared Cockpit features (with some view management extras tacked on). We should have a lo- (or possibly no-) cost education license available soon (not sure of the pricing structure, I just write code :-> ).
 
Everyone,

Thanks for the input! I certainly have more information than I started with now. I am going to spend some time testing out these ideas with probably just 2 machines to start with. If I make some progress, I will definitely share my experience. I am going to first attempt this with SimConnect.

Wish me luck...

Thanks,

Daniel

P.S. If my university could get Prepar3d for cheap or free, then if may be a possibility in the future.
 
Anyone,

So, I have been working on implementing this. So far I have it working with just two computers. I used a standalone executable that runs on a third machine to pull data from one and push it to the other. This works fine. However, I have one issue. I am unable to set the "Sim Disabled" variable successfully.

This is what I tried (of course this is not all of the code):

struct simState
{
bool disabled;
};

......

static enum DATA_DEFINE_ID
{
DEFINITION_3,
};

......

SimConnect_Open(&hSimConnect2, "Passenger", NULL, 0, 0, 2)

......

hr = SimConnect_AddToDataDefinition(hSimConnect2, DEFINITION_3, "Sim Disabled", "Bool");

simState s1;
s1.disabled = true;

SimConnect_SetDataOnSimObject(hSimConnect2, DEFINITION_3, SIMCONNECT_SIMOBJECT_TYPE_USER, 0, 0, sizeof(s1), &s1)

Like i said this is shorted to the code relevant for changing the "Sim Disabled" variable. What am I missing? I keep getting an exception 19. Could someone point me in the right direction? I am able to set plenty of other variables such as the plane lat, lon, alt, velocities (x,y,z), acceleration(x,y,z), etc.

Thanks,

Daniel
 
Hi Daniel,

I suspect that the variable must be declared as Double, even if the value is a bool.

Patrick.
 
You are using the shortened form of the AddToDataDefinition call, the 5th param would be the data type (See the SIMCONNECT_DATATYPE enum in the SDK) - the default value for this is SIMCONNECT_DATATYPE_FLOAT64 if not specified.

Also, bool is a bad C++ var type to use in "sized" data structures (it's not guaranteed to be any size by the standard, and is usually just a byte in Microsoft C++ compilers). You would probably want to use a 32-bit int and the SIMCONNECT_DATATYPE_INT32.
 
Thanks for the help. I believe that solved my problem.

Now, for the next issue.

It seems that I can only achieve just under 20 variable pull and updates per a second (I created some timers in my program to test for this). This update includes z, x, y locations, acceleration and velocities, as well as the rotational velocities. This is not enough to make the control of the user object smooth. It is rather choppy which makes considering it is only 20 updates a second.

I have noticed other people having the same issue online with AI object control with simconnect.

Do you guys have any suggestions on ways to smooth this out? I've tried the search function, but I've yet to find a definitive solution. Even if you can point me in the direction of a thread that I somehow overlooked, I would greatly appreciate it!

Thanks,

Daniel
 
Extrapolation

Hi Daniel,
If you are going to another computer over the network, you are in the trap. Even high sophisticated simulators have the issue of frame rates and latency. The only way out is to construct an extrapolation module to produce additional frames on the target machine. Every frame must have an exact time stamp of the time when the position data were calculated (not when it was sent to the network) . With position, speed and acceleration data you can produce additional frames based on assumption. The extrapolation module calculates the assumed positions for additional frames until the next original frame data arrives. It depends on the smartness of the extrapolation how smooth your traffic moves. Do not try to deal with interpolation. The result is an aircraft on a rubber band. It cannot be controlled anymore.

Regards
Mike
 
Mike,

First, thanks for the response. I am wondering if it is possible to pass enough data about all of the control surfaces of the aircraft to let the simulator do the extrapolation for me. Currently, I am sending data location, velocity, and acceleration data about the aircraft. When the sim is not disabled it still appears that the one simulator is fighting the other. Obviously, when the Sim is disabled it is choppy because of the measly 20 updates per a second.

Would it be possible to pass extra data about the control surfaces and possibly even input events to the secondary machine in order to smooth out the simulation? This would basically let the simulation take care of the extrapolation. If this is possible, what other variable would I need to pass? If you don't think this possible just let me know up front.

Thanks,

Daniel
 
Extrapolation

Hi Daniel,
I assume you are talking about controlling the viewpoint on the secondary computer. You do not need the control surfaces because as soon as sim is disabled , you control the position and attitude of the user aircraft directly with extrapolated data. I wouldn't believe that a 'flying' aircraft produces good results.
What you need for an extrapolation is the following:
  • exact time stamp from the source computer. The best would be a double precise float in seconds. The update rate of 20 frames from the source computer is good enough for extrapolations.
  • X position, Y position, Z position
  • speed along X axis, speed along Y axis, speed along Z axis
  • Attitude as yaw, pitch and roll
  • rotation speed around yaw axis, pitch axis and roll axis
These data are normally sufficient for a simple extrapolation. But you can add an additional calculation level if you send acceleration data for axis movements.
  • First you need to specify an intended frame rate for the secondary computer. It should be synchronized with the FS frame rate. That means, if the FS runs with 30 frames on the secondary computer you should even calculate with 30 frames for the extrapolation. The smartest would be a trigger from the FS every time a frame was produced by the FS.
  • As soon as the trigger is initiated you make a check whether a new frame arrived from the network.
  • If yes, set the received data so as it would be the last extrapolated frame. That synchronizes the extrapolation with real data. Do not send the received data to the FS.
  • determine the time delta from the last extrapolation frame to the time now. You should have a special focus on the time stamp handling and time calculation because you are dealing with the timers of two different computers. That may have some trap doors.
  • With the time delta, attitude, position and velocity data, calculate where the aircraft would be at this moment, based on the last extrapolation frame. The calculation is a simple time distance and time rotation problem. As said, you can incorporate acceleration values to get a more precise result.
  • Send all calculated position and attitude data to the FS.
You will have noticed, that never actual data are given to the secondary FS. Only extrapolated data are transferred. That is because actual data do never fit in the time raster. And that is even what you observe as jumping targets if you send received data directly. You have no constant update rate from the source. This is added with the unreliable network latency and last not least the irregular loop time in your software. The resulting track is what we call a happy dog leg.
Regards
Mike
 
Mike,

Thanks for the response. I am going to talk this over with my professor. You have given me a good push in the right direction. If I can get the synchronization down, your explanation makes the task seem a little simpler than I first thought.

I may very well be back with some questions...

Thanks again!

Daniel
 
Mike,

So far, I have some basic code setup. It subscribes to every frame event on the secondary machine and requests data on the primary machine (the one that the user controls) every sim frame. I have set 30 as my target frame rate. It tests to see if it has received an update from the primary machine and pushes that data to it if it has. Otherwise, it does nothing at the moment. But, I will eventually make it send the extrapolated data instead.

Is there a variable I can use to get actual system time through simconnect? I noticed some environment variables that refer to time. But, isn't this the simulation time?

Thanks,

Daniel
 
Precision time

Hi Daniel,
I wouldn't use simulation time for this purpose. You need a precise time base with about microsecond resolution. On the host computer you should query the precision time at the moment when you receive aircraft data. Put the time as time stamp together with the aircraft data into your network frame record.

On the slave computer you have to setup a local time delta once on application startup. This is done when the first frame arrives from the host. You have to determine a difference value between the local precision time and that received from the host. The delta is used during the session to convert external time stamps into local time.

On reception of a network frame, convert the received time stamp into local precision time. This enables the extrapolation module to calculate the right position in regard to last preceding frame.

The precision time can be queried from the Windows API function 'QueryPerformanceFrequency'. The attached class is a short example how to convert the timer values for use. The timer starts at that moment when the class is constructed. The timer is initiated with 0.0 sec. On every query it returns the time measured from the class construction up to now. You can request double precise values in seconds or, if preferred, in milliseconds. For the extrapolation you should use double precise seconds.
The only disadvantage of the timer use is, that interactive changes of the simulation speed or simulation start/stop are not considered. But with a little extension of the timer software, this could be managed too. Another consideration could be, that the two different timers could drift apart. But by my experience it can be ignored because the timers are hardware driven from the RTC chip.
Regards
Mike
 

Attachments

Mike,

Thanks again for the reply! You are doing a lot to help me out and I really appreciate it! When this is all said and done, I'm hoping my university will allow me to release the source code so that others can benefit from all of my work.

I'm going to see what I can make of all of this. I'll probably be back with a few questions.

Thanks again,

Daniel
 
Back
Top