Jump to content

Simconnect coding... I'm stuck.


Recommended Posts

Hello everyone, (I assume it's especially for Ian and Peter, so a special Hi to you both :help: )

I hope you can help me out. Perhaps I'll answer my own question after a while as often it helps to just talk about those problems but as long as I don't do it here, I'm stuck.

1) Introduction

2) Project status

3) Problem description & questions

4) Planned steps

5) General comments

1) Introduction

I'm coding a winch launch tool. (Hope it's not too early to come out with this secret.) I'm quite used to coding - especially VisualBasic - but very new to game addon programming. The winch will be my first addon, to be honest.

2) Project status

My project is set up in VB, I referenced simconnect and the communication works. I learned how to read out simconnect variables, how to create objects and how to set variables. No problems so far. My winch is positioned and created as an object (a standard fuel truck actually) at 1000 meters away from the user plane in direction of plane's heading on the ground. I calculate distance and direction between those two objects and the results are reasonable. I vectorise the force in the plane coordinate system into three components (X, Y, Z) and calculate accelerations - regarding the rope/cable/wire (what's that thing called correctly in english?) sagging. With the help of a timer (counting milliseconds between one "SetDataOnSimObject" and the other) I get the speeds, which to set for the variables "BODY VELOCITY .." with the following SetDataOnSimObject-step. Summing up: My plane moves in the direction it's supposed to be accelerated. :yahoo:

3) Problem description & questions

While I SetDataOnSimobject in a loop (start loop, calulate new velocities, setData, go back to start loop) my plane moves fluently and looks fine. As I need new position of the plane (to calculate distance and direction) to the winch each step I added a data-request and with the onRecieve-event I calculate the new speeds and set them... then I call a new data-request and so on. The effect is that my plane is just trembling - it's more of a hopping, don't really know how to describe - in the direction of the winch. I guess that the plane accelerates, then - before the next data-request is handled by simconnect - the ground friction is breaking the plane down to Zero movement and the velocity to what I add the new calculated Speed-Delta is Zero. This could be an explanation why my plane doesn't move correctly, but regretfully I didn't have the time to proof this yet. :whistling: :beatcomputer:

What I didn't understand (yet) is:

Do I have to "update" my RecieveDataByType-structures or is it updated automatically after registering it once and adding a handler for the recieve-event? If it's not updated automatically, what would be a useful interval to request new data? :unknw:

Would it be better to set the "BODY ACCELERATION .." variables directly? That would mean a less of calculation to be done.

4) Planned steps

The next steps after solving the problem above will be: Calculate the correct forces with some function looking aproximately like a rev/torque-curve of a truck-diesel engine. Then I'll add some abort parameters (as for rope break, overload of predetermined breaking point, user action: tow release). Following action will be adding of error handling. Then "Going Beta" - preferably end of may (hope it won't be may 2009 :whistling: ).

5) General comments

Special Thanks go to Peter "Funky" as he got me started, handed me over some very helpful material and answered a lot of stupid beginner's questions.

Same to Ian for publishing his source code... that helped a lot.

If you need any additional information, please don't hesitate to ask here - or via email if you need me to send you an example. My email address is dirk (dot) boehm (at) gmx (dot) de

Hope one can help.

:cheers2: Dirk.

Link to comment
Share on other sites

Hi Dirk,

probably you have already registered a handler for processing received data from your object, like this:

...
        AddHandler FSXSimConnect.OnRecvSimobjectData, New SimConnect.RecvSimobjectDataEventHandler(AddressOf OnRecvSimobjectData)
...
Then, request automatic sending of data every sim frame or every visible frame (it didn't make much difference at my side).
...
        FSXSimConnect.RequestDataOnSimObject(DataRequests.RequestAircraftPosition, _
                               StructDefinitions.AircraftSituation, _
                               Microsoft.FlightSimulator.SimConnect.SimConnect.SIMCONNECT_OBJECT_ID_USER, _
                               Microsoft.FlightSimulator.SimConnect.SIMCONNECT_PERIOD.VISUAL_FRAME, _
                               SIMCONNECT_DATA_REQUEST_FLAG.DEFAULT, 0, 0, 0)
...

This sends fresh data automatically to your registered handler for the sim object data. Though not absolutoely necessary in your case you may also consider some fallback code, most likely something like finalising your winch function, when the user switches away from normal sim operation, say to slewing or to changing the airport and the like. For detecting this you should register callbacks to system events as sim start and sim stop, slew on/off, or dialog mode.

best regards,

Peter

Link to comment
Share on other sites

[snipped the code above]

This sends fresh data automatically to your registered handler for the sim object data. Though not absolutoely necessary in your case you may also consider some fallback code, most likely something like finalising your winch function, when the user switches away from normal sim operation, say to slewing or to changing the airport and the like. For detecting this you should register callbacks to system events as sim start and sim stop, slew on/off, or dialog mode.

best regards,

Peter

Hi Peter,

thank you very much for this explanation (it's more of a verification since I played around with some test-lines tonight... till 2:00 in the morning).

I've had a classical CKI-error (Chair Keyboard Interface), which was the reason for me to ask: If one doesn't use different threads, either the timer ticks or the Win32-message reader part would run... never both :nono: :whistle3:

So I first got new information every simconnect message was recieved but didn't got my form updated (I'm doing that in a timer-ticks-event) and in my second try I got my form updated with old values cause I got my code ticking that timer... :not_i:

In the evening i'll go ahead with coding and most possibly split my tasks into different threads by tonight.

I'll report my efforts. And most likely the next questions as well.

Fallback, error handling etc. will surely follow but - as usual - is of minor priority for my pre-alpha versions ;):lol:

:thanks: Dirk.

BTW: I tried to get myself into a glider the last two weekends but it seems as our local club guys won't fly until thermal lift can carry their hangar doors :ok:

Hope to find another club that uses a winch next weekend.

PS: Is the email adress I got from you still correct?

Link to comment
Share on other sites

... till 2:00 in the morning ....

Gee, I made the same experience.

BTW, once you have set up the automatic sending of data, you can give up your own local timer loop, if you trigger all the processing through the callback routine. CumulusX! does not have timers at all, rather uses events from FSX only (and from the GUI, of course).

BTW: I tried to get myself into a glider the last two weekends but it seems as our local club guys won't fly until thermal lift can carry their hangar doors :ok:

The guys seem pampered with perfect conditions, usually? My club is flying in the Eifel region and we did already training camps where we had to wipe the snow from the wings between the flights (and from the tents, btw). Though, this was 25 years ago.

PS: Is the email adress I got from you still correct?

It is. Did you fail in sending me a message?

Cheers,

Peter

Link to comment
Share on other sites

Gee, I made the same experience.

BTW, once you have set up the automatic sending of data, you can give up your own local timer loop, if you trigger all the processing through the callback routine. CumulusX! does not have timers at all, rather uses events from FSX only (and from the GUI, of course).

You have mail on that one... hopefully

The guys seem pampered with perfect conditions, usually? My club is flying in the Eifel region and we did already training camps where we had to wipe the snow from the wings between the flights (and from the tents, btw). Though, this was 25 years ago.

Yeah... today my wife reported (she used to fly there ten years ago - until she grounded herself before the doctor did) that if there was the slightest possibility of rain they kept their doors shut - even if the rain was expected on another continent... or that was more or less how it felt for the students.

I'll try to get myself up somewhere else. Enough clubs around here, so I still hope one of them will let me do my researchs :pilot:

It is. Did you fail in sending me a message?

Cheers,

Peter

Hope you got one tonight?

:cheers2: Dirk

Link to comment
Share on other sites

Thanks for your efforts thus far on the wench, Dirk! I had to remind myself to quit thinking of myself :whistling: and that a wench in FSX would be another outstanding idea to simulate. I had forgotten :dumb_me: that I most often use it in FS2004 to get up in the air.

sf4JC

Link to comment
Share on other sites

  • 2 weeks later...

How's it coming along Dirk? I had a thought today of watching (and remembering) a radio control aircraft winch at work, and how awsome it would be to be able to see the actual tow line at work from launch point in FSX. For those using FSX for R/C simulation, that would be an incredible addition. Do you or anyone know if this can be possible in FSX?

Scott

Link to comment
Share on other sites

  • 1 month later...
How's it coming along Dirk? I had a thought today of watching (and remembering) a radio control aircraft winch at work, and how awsome it would be to be able to see the actual tow line at work from launch point in FSX. For those using FSX for R/C simulation, that would be an incredible addition. Do you or anyone know if this can be possible in FSX?

Scott

Hi Scott, hi all,

it's constantly improving, but very slowly - I have to admit that. The last few weeks I had more work for the job I get paid for than I could stand. I think I (with the help of Peter - Thank you again Peter) have solved my major problem (transfering the "world" coordinates into the (settable) system with the aircraft as reference point).

Last tests on this issue will be done tonight.

Follwing steps will be:

- implement rope/cable (still don't know what's correct english term) sagging again... dependant of material this time

- Calculating the actual force by torque and revs of winch engine, probably adjustable (we'll see)

With this two major parts done, all of you guys will get a beta version from me, well, those of you who are interested in testing the beta, at least.

Further steps will be:

- comfortable user interface

- two or three special features

BTW: Anyone got an idea about how to keep the plane parallel to ground (to simulate the guy running next to plane keeping wings leveled)?

Scott: As for the rope, I don't have any idea yet. I think what you would need is an animated object - no further idea. I'll think about this one after start procedure is authentical. Hope you don't mind.

:cheers2: Dirk.

Link to comment
Share on other sites

BTW: Anyone got an idea about how to keep the plane parallel to ground (to simulate the guy running next to plane keeping wings leveled)?

Look for this settable variable in the SDK

PLANE BANK DEGREES

Scott: As for the rope, I don't have any idea yet. I think what you would need is an animated object - no further idea. I'll think about this one after start procedure is authentical. Hope you don't mind.

From the cockpit cable and parachute are only visible until few seconds after take off. Later on it disappears below the rim of the canopy. The cable is hardly visible at all (different from aerotow) because it's much thinner. Consider to show the (animated) stretched parachute only.

cheers,

Peter

Link to comment
Share on other sites

Look for this settable variable in the SDK

PLANE BANK DEGREES

Hmmm... that's what i tried. but it seems as if FSX looses this for the next simulation step. perhaps i'll try to set it every step till glider reaches some defined speed. We'll see.

From the cockpit cable and parachute are only visible until few seconds after take off. Later on it disappears below the rim of the canopy. The cable is hardly visible at all (different from aerotow) because it's much thinner. Consider to show the (animated) stretched parachute only.

cheers,

Peter

I think Scott thought about outside views... But this will presumably one of those steps i'll plan for Ver. 2.5 or higher.

Link to comment
Share on other sites

Great, and excited to hear! Don't worry about the animation part if it's too troublesome. I just woke up that morning with great memories of R/C flight, and the winch system that the club used all the time. I didn't get to have any experience using it, as all my R/C gliding experiences started with a high start (surgical tubing with a length of heavy string attached).

I know Don and I might be really interested in it from the R/C standpoint if the animations were somewhat enjoyable and "readable" so as to not explode the wings right off the model from launch point. But for now, stick with Peter's explaination, to keep it true to real world pilots.

THANKS for your time and dedication to this project.

Scott

Link to comment
Share on other sites

  • 4 months later...

Hello Dirk. How goes the battle? Just wondering if you took a break from it, or if you came to an unexpected snag. Would love to see a good winch launch system in FSX.

Scott

Link to comment
Share on other sites

Hello Dirk. How goes the battle? Just wondering if you took a break from it, or if you came to an unexpected snag. Would love to see a good winch launch system in FSX.

Scott

or even a wench launch system... :winks:

Ian

Link to comment
Share on other sites

Hello Dirk. How goes the battle? Just wondering if you took a break from it, or if you came to an unexpected snag. Would love to see a good winch launch system in FSX.

Scott

Hi Scott,

sad but true: I'm stuck in real life issues for month now and no end in sight. I've still in mind to finish the project this winter - after our roof is repaired, my three additional projects (for the job I'm beeing payed for) are finished. Can't remember when I had a week with less then 6 (12 hour +) days wasting just for the darn money :winks:

I'll keep you informed as soon as I'll resume developing.

:cheers2: Dirk.

Link to comment
Share on other sites

Thanks Dirk. Sorry for the RL stuff. Praying you get through okay and without a lot of grief. Thanks for letting us know you'll keep us informed also. I just thought of the thread and was wondering about it. I hope also the launch system developement goes well for you once back into it.

Scott

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy & Terms of Use