1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Using Slew Mode

Discussion in 'SimConnect' started by davidt, 20/8/07.

  1. davidt

    davidt

    Joined:
    15/8/07
    Messages:
    34
    Country:
    canada
    Hello,

    So I've been playing around with sending updates to a NonATCAircraft that I've created from a SimConnect client.

    Between updates, the plane wobbles a bit, and drifts here and there. I had an idea to give it a way point a bit ahead of where it's going based on the heading, pitch, bank and speed, so I started looking around the forums here to see if anyone had asked anything similar.

    Now, I think I found some stuff about that, but I also came across people talking about using slew mode and sending updates regularly.

    This may sound like something I would want to use, but after looking through the SDK documentation, all I've seen about slew mode is a few events for setting or increasing/decreasing some variables.. I'm really quite unsure how to use any of them.

    Are there any code examples of someone using slew mode, or can anyone give me some tips on what I'd need to do to be able to control an external (ie: not the plane I'm currently flying.. not external to FSX) plane that's in slew mode?

    Thanks,
    David
  2. lc0277

    lc0277

    Joined:
    25/9/06
    Messages:
    156
    Country:
    france
    Hi David,

    Some time ago, I made a small "toy" application that replicated the user aircraft at fixed offsets, so as to simulate a formation flight. Nothing serious, it was just some experiments with simconnect. I encountered the same problem as you : when updating regularly the position of AI aircraft, they were wobbling and shaking, and sometimes just teleported 10 meters away. Unfortunately I haven't solved this problem yet.

    Using slew mode can be an opportunity. The programming is slightly different because slew is only used with events, not variables. You first have to register every slew events :
    - the on/off switch SLEW_ON and SLEW_OFF
    - the 3 axis AXIS_SLEW_AHEAD_SET, AXIS_SLEW_SIDEWAYS_SET and AXIS_SLEW_ALT_SET
    - the 3 rotation axis AXIS_SLEW_HEADING_SET, *PITCH* *BANK*
    ie
    SimConnect_MapClientEventToSimEvent(hSimConnect, EVENT_ID_SLEW_ON, "SLEW_ON")
    etc

    Then instead of updating variables, you "fire" each event, with TransmitClientEvent()
    and setting dwData parameter equal the value of the speed of in the given axis. Note that you're controlling speed and not position. If you have some physics engine controlling the AI object, speed is the derivative of the position (but generally movement is calculated from acceleration formulaes and then integrating two times to get velocity and position)

    However there's still someting I'm missing about the value you give as event data. The relation between the slew value in one axis and the speed in the same axis is not documented, and I don't know if we can establish a reliable conversion. For small values, it's linear, although you'd have to calculate the proportionnal factor experimentally.

    Another problem could come from performance. Instead of setting all position variables in one packet, you send 6 events, which are probably handled separately by FS.
    And more troubles : aircrafts in slew are not producing sound. Animations are frozen (eg props)

    Good luck !:)
  3. davidt

    davidt

    Joined:
    15/8/07
    Messages:
    34
    Country:
    canada
    Thanks LC,

    That doesn't sound so great, though... sending all those events separately will really add up if there are several other planes/vehicles to worry about, and that they won't be animated isn't that appealing either.

    My other thought would be to use all the current information and calculate a waypoint lat/lon and give that to the plane... that way FS can handle the details while I'm waiting for a new update to come in, and hopefully keep the plane steady on that course.

    If the date makes it deviate a little, then there will be a jump in position, but hopefully it won't be too severe if the updates happen frequently enough.. right? :p

    David

Share This Page