1. For downloading SimTools plugins you need a Download Package. Get it with virtual coins that you receive for forum activity or Buy Download Package - We have a zero Spam tolerance so read our forum rules first.

    Buy Download Package Now!
  2. Do not try to cheat our system and do not post an unnecessary amount of useless posts only to earn credits here. We have a zero spam tolerance policy and this will cause a ban of your user account. Otherwise we wish you a pleasant stay here! Read the forum rules
  3. We have a few rules which you need to read and accept before posting anything here! Following these rules will keep the forum clean and your stay pleasant here. Do not following these rules will lead to permanent exclusion from this website: Read the forum rules.

Writing a motion cueing software from scratch.

Discussion in 'DIY Motion Simulator Projects' started by Dirty, Feb 28, 2019.

  1. Dirty

    Dirty Active Member Gold Contributor

    Joined:
    Oct 15, 2017
    Messages:
    157
    Occupation:
    All the way up front.
    Location:
    Germany
    Balance:
    1,779Coins
    Ratings:
    +143 / 1 / -0
    Spot on! In motion cueing we are exploiting humans susceptibility to somatogravic and somatogyral illusion to our advantage :)
    Last edited: May 7, 2019
  2. hexpod

    hexpod http://heXpod.xyz Gold Contributor

    Joined:
    Apr 18, 2016
    Messages:
    346
    Location:
    berlin
    Balance:
    2,447Coins
    Ratings:
    +112 / 2 / -0
    My Motion Simulator:
    DC motor, 6DOF
    Thanks for the wiki link.

    Very informative !
  3. hexpod

    hexpod http://heXpod.xyz Gold Contributor

    Joined:
    Apr 18, 2016
    Messages:
    346
    Location:
    berlin
    Balance:
    2,447Coins
    Ratings:
    +112 / 2 / -0
    My Motion Simulator:
    DC motor, 6DOF
    Dreaming dreaming ....

    Native xplane motion algorithm AND VR motion cancellation.

    Certainly doable. 6-variables and that’s it. Headset On, and ready for a real ride.

    Let’s hope that Ben’s “not ASAP” doesn’t hold on ground something which could be the best idea ever!
  4. yobuddy

    yobuddy Well-Known Member Staff Member Moderator SimAxe Beta Tester SimTools Developer Gold Contributor

    Joined:
    Feb 9, 2007
    Messages:
    3,366
    Occupation:
    Computer Technician
    Location:
    Portland, Oregon - USA
    Balance:
    25,640Coins
    Ratings:
    +3,420 / 10 / -0
    Hi Dirty,
    Hope you are well man. I love chatting new ideas! It's the fun part for me buddy.
    My worry is I don't want to break the way we are doing things currently, or so many people may be lost.
    A few people would have sims that won't work they way they want to anymore.
    Or a roller coaster sim where we can't make it tip the whole time as wanted.

    But SimTools is built so one person can do things one way without affecting the next person.
    So there is no reason we can make alternate plugins.
    That's what I meant above actually.
    ~ Lets go over you suggestions buddy. ~
    1)
    I would love to go over all this anytime buddy.
    Maybe form a group chat?

    2)
    Not really, if you mean you want more Min / Max columns.
    But we can premix anything we want in the game plugin itself and then export the normal 9 outputs as usual.

    The more outputs we have in the software thou, means the more the software and the PC has to do, and the harder axis assignments plugins could be to make.
    So striking a balance can be tricky for sure.
    But SimTools will just keep evolving as there is a need, version v2.4 will be a huge jump forward for sure.

    3)
    Yes, this is no problem.
    And with v2.4 there are no limitations on what goes where, meaning weather you send Euler Angles, or degrees or accelerations all the filters will work as usual.

    Chat soon! :thumbs
    Take care,
    yobuddy
    • Like Like x 1
    • Friendly Friendly x 1
  5. Dirty

    Dirty Active Member Gold Contributor

    Joined:
    Oct 15, 2017
    Messages:
    157
    Occupation:
    All the way up front.
    Location:
    Germany
    Balance:
    1,779Coins
    Ratings:
    +143 / 1 / -0
    And here a quick look into the ground model. I have spent virtually no time on tuning that so far.
    The key point of that video is that I will use two different sets of gains and offsets for flight and ground. Tuned independent from each other and then fade over from one to the other within ~2 seconds after touchdown.

    • Like Like x 1
  6. apointner

    apointner Siddhartha

    Joined:
    Aug 16, 2014
    Messages:
    52
    Location:
    N 48° 9'0.88" E 12° 5'45.84"
    Balance:
    255Coins
    Ratings:
    +9 / 3 / -0
    My Motion Simulator:
    3DOF, DC motor, Arduino, Motion platform
    i am builded a 360° 3DOF Full Sim and hope to clear some things out.
    First i must admit i didn´t had the pleasure flying in a GOOD Stuart Plattform, jet.
    Only this: https://drive.google.com/open?id=1YO3eTmCRYn60JTZkiL2O5NfvSI0LT0on
    Feels totaly wrong. So i can´t judge how e.g. the Airbus Hexa Simulator really feels.
    But i have some RL exp with A-320, Aerobatics in Yak-52, Gliders and Paragliding.

    After many testing and tweaking with my 360° Pit i must confirm what @Dirty points out.
    Forget about Euler Position to simulate constant Gs. E.G. in aerobatics i only feel two things:

    1. pos / neg Gs: It´s all about that, imho. By far the strongest force and the most important Value to get a realistic feeling. How to do? Later...#1

    2. Rapid changes in Roll,Pitch,Yaw,Side: If you throw the stick full right, your head may bangs on the canopy...but only for a second *g.
    But after this first "kick" even a steady 200° roll feels smooth to me, nearly no forces at all.

    Some would say, and what´s about constant acc/decc?! This is something special...+ 0.8 G acc is enough to make Humans screaming like childs.
    But in compare to the huge pos Gs, it´s just a joke. So, yes we have to simulate this force cause our brain reacts very sensitive to it (see #2)

    So how feels aerobatics in a 360° Sim?

    Ok i could say, hey i have a 360° Pitch axis, that simulates the RL Pitch behavior perfect!

    Nope, it isn´t.
    Couse you don´t feel the Pitch in RL. You only feel that minium of 3 pos Gs pressing you and your innards into the seat.
    Everything else is mostly not notable.

    But hey, i can perfectly simulate a constant 360° Roll with 220°/sec, right?!
    Hmm, let´s say almost:
    In RL the AC has to overcome the centrifugal force while doing a roll. So the Pilot is pulling the Stick a bit (and some rudderwork)
    This generates...pos Gs again.

    #2 What about Acc/Decc Forces?

    Since you don´t need much force to generate a realistic feeling, I choosed pitch to simulate the constant acc/decc.
    Kicking in the Burner feels just amazing real (Pitch up +8°)! Same with airbrakes.
    But while doing a carrier launch the Pitch Axis goas up +80° (represents +0.8G acc)
    This is for sure a amazing roler coster effect and the result is close to RL Gs, but it feels wrong, couse you still note the pitch upward movement!
    Same with carrier landings. So, this is just a compromise.
    When flying invertet, i reverse this effekt to stay real at least.

    What about slipping (Yaw/Sway)?
    I use bank to simulate this, witch works in many cases well.
    But the Bankangle is max +/- 15° to generate sway. More angle is not possible without braking immersion (see above).
    Now imagine what happens when flying right 30° Bank and apply full left rudder.
    The result feels like a little slide to the right, but in RL Life you would feel a force pulling you to the left.

    Ok, then what about a constant 60° Bank turn?
    Worst thing. In RL you mostly feel...right, pos Gs.
    But in my (banked) Pit it feels like a 0.5G sideslip. Luckly i have a solution for this see #1.

    Errrrr, and then what about level or invert flight!?
    Yes ok , this feels just perfekt like RL :)

    You see 360° is not the better solution for Motion Simulation.
    BUT...


    #1
    To overcome the pos/neg G Problem you can build a heave axis with 50cm travel or more.
    This is enough for soft civ flights, since you feel the rapid changes in all Dimension far more, then the lower constant Forces.

    But as soon you do a little more aerobatics or mill. flight the pos Gs are just insane and dominate everything.
    So we need to simulate CONSANT pos Gs!
    Out of options with my 2DOF i stumble over the Berginson Seat - this is the way to go!
    But i didn´t had the time to build the hole seat - and i just needed the heave Axis anyway.
    So for testing i just connected the belt buckle (from the 5point belt) with a cable to a geared DC Motor.
    And wow!!
    The pressure is distributed cleanly on shoulders, chest, thighs and pelvis.
    You can hardly feel that in reality a pull in the middle is the source of the Gs.
    Each G is noticeable, even at fast rashes during take off.
    At max. Gs i almost lose the air, although the objective pressure on the body is only a fraction of the real Gs.
    Only with the belt tension the 360° Simulator is damn close to real life!
    However i don´t know how cool it would be with the hole system from berginson.
    For example i could imagine that Acc/Dec/Sway/Yaw is way better simulated with the bergison solution.

    Conclusion: no matter what system you plan...solve the pos G problem. Everthing else is minor.

    So why the hack go for 360°?!

    Most people here forget about on important thing:
    The sense of balance!
    Even when you don´t feel constant Gs on your Body while doing a roll at 200°/sec, your Ears will tell you : WTF!!!
    Even with VR It is scary like RL flying! My first real life loop scared me in the same way this simulator did !
    And in the End of the Day it is exhausting - this simulator gives you a small clue what real fighterpilots must accomplish.

    Ok that´s it, i hope this offers some new aspects to this topic and pls don´t blame me for bad english :)
    • Like Like x 1
    Last edited: May 9, 2019
  7. SeatTime

    SeatTime Well-Known Member

    Joined:
    Dec 27, 2013
    Messages:
    2,132
    Location:
    Newcastle Australia
    Balance:
    26,043Coins
    Ratings:
    +2,432 / 23 / -0
    My Motion Simulator:
    DC motor, Motion platform, 6DOF
    Yep all true and it is why I use a G-vest in my own sim :).
    • Winner Winner x 2
  8. apointner

    apointner Siddhartha

    Joined:
    Aug 16, 2014
    Messages:
    52
    Location:
    N 48° 9'0.88" E 12° 5'45.84"
    Balance:
    255Coins
    Ratings:
    +9 / 3 / -0
    My Motion Simulator:
    3DOF, DC motor, Arduino, Motion platform
    Yes, i must say...the vest is a very good idear. I saw some pictures somewhere here, wired with cabels and linked with the harness. The Head, too. Hm, could fit into my Pit...hmmm. Thanks!
  9. harwoodr

    harwoodr New Member Gold Contributor

    Joined:
    Dec 9, 2013
    Messages:
    20
    Balance:
    296Coins
    Ratings:
    +10 / 0 / -0
    My Motion Simulator:
    Motion platform, 6DOF
    So I'm at the point with the (simple) MCA I'm doing for my project where all the classical expected output is being produced (yay!)... and I'm trying to wrap my head around "return to neutral" false cues and how to deal with that. (If anyone has any pointers or links - advice is appreciated)

    mca.png
    In any case, I'm going to move forward with this for now and plug in my inverse kinematics next... well, that and fix a sticky solenoid valve, but some silicone lubricant can fix that... ;)

    After that, I'm going to collect some force data from simtools/no limits roller coaster 2 and run it through the software and see how it looks/ performs.

    I might quickly throw a simulated simulator into my python code using pyQTgraph... we'll see.
    • Like Like x 2
  10. Dirty

    Dirty Active Member Gold Contributor

    Joined:
    Oct 15, 2017
    Messages:
    157
    Occupation:
    All the way up front.
    Location:
    Germany
    Balance:
    1,779Coins
    Ratings:
    +143 / 1 / -0
    Hey there :)
    Nice curves! Trying to build something like this as well to look at the data in real time. So far, I can only log the data and later visualise it in Excel.
    A question about the highpass signal: How do you create that? It is apparently not being created by subtracting the LP-signal from the original signal. Do you have a code snippet? I'm asking because from the looks of it, it should give exactly the kind of motion response I would like to see for a step input.

    And on top: It looks as if THIS is the kind of signal that would actually work nicely with an integrator instead of another LP filter (you remember our conversation?)

    Thumbs up!! :thumbs

    Dirty :)
  11. Dirty

    Dirty Active Member Gold Contributor

    Joined:
    Oct 15, 2017
    Messages:
    157
    Occupation:
    All the way up front.
    Location:
    Germany
    Balance:
    1,779Coins
    Ratings:
    +143 / 1 / -0
    Not sure if that makes sense to anyone outside my own head: The fact that this signal integrates to zero before the step reversal (area below = area above) makes it so appealing to me. This is what I need! :!

    Dirty :)
  12. Dirty

    Dirty Active Member Gold Contributor

    Joined:
    Oct 15, 2017
    Messages:
    157
    Occupation:
    All the way up front.
    Location:
    Germany
    Balance:
    1,779Coins
    Ratings:
    +143 / 1 / -0
    On another note: I've started to populate the GUI of my software, so that a user can eventually use the software :)
    Bildschirmfoto 2019-05-12 um 20.31.07.png

    Up until now, I have made all changes directly in code or inside the Unity editor.
  13. harwoodr

    harwoodr New Member Gold Contributor

    Joined:
    Dec 9, 2013
    Messages:
    20
    Balance:
    296Coins
    Ratings:
    +10 / 0 / -0
    My Motion Simulator:
    Motion platform, 6DOF
    So, I'm using python to generate that... and a couple of libraries (numpy and scypi) to do the heavy lifting... I'll send you a copy of the code.

    In the mean time - when I want to generate a filter, I use a class (that I stole) that gives me a few functions on top of a filter (init, reset and apply - the last of which is "take this new data value and stuff it in the filter"). To instantiate that class with a specific type of filter, I do this:

    #low pass filter - first order
    def firstlp_filter(w):
    b= [0,w]
    a= [1,w]
    return RealtimeFilter(*signal.bilinear(b,a,fs=FREQ))

    Which translates to omega/(s+omega)... or:

    #high pass filter - second order
    def secondhp_filter(z,w):
    b=[1,0,0]
    a=[1,2*z*w,w**2]
    return RealtimeFilter(*signal.bilinear(b,a,fs=FREQ))

    Which translates to s^2/(s^2+2*zeta*omega*s+omega^2)...

    Here's the fun part... want an integral function?

    #single integrator - 1/s
    def sint_filter():
    b= [0,1]
    a= [1,0]
    return RealtimeFilter(*signal.bilinear(b,a,fs=FREQ))

    ...a double integral?

    #double integrator - 1/s**2
    def dint_filter():
    b= [0,0,1]
    a= [1,0,0]
    return RealtimeFilter(*signal.bilinear(b,a,fs=FREQ))

    ...which I just corrected, so, thanks - posting helped me see where I had a bug. lol
    • Like Like x 1
  14. harwoodr

    harwoodr New Member Gold Contributor

    Joined:
    Dec 9, 2013
    Messages:
    20
    Balance:
    296Coins
    Ratings:
    +10 / 0 / -0
    My Motion Simulator:
    Motion platform, 6DOF
    Hmm, so I'm playing with tilt coordination... and comparing input forces against effective output forces... x and y are good... but z is off... Now, yes, I know, there's no actual tilt coordination in the z axis (as yaw doesn't affect it)... but doesn't tilting take away the effect of gravity on the z axis (while adding it to the x and y axes)?

    So if I'm pitched 30 degrees, the effect on the x axis is 1G* cos(30)... wouldn't I lose a corresponding value on the z axis?
  15. Dirty

    Dirty Active Member Gold Contributor

    Joined:
    Oct 15, 2017
    Messages:
    157
    Occupation:
    All the way up front.
    Location:
    Germany
    Balance:
    1,779Coins
    Ratings:
    +143 / 1 / -0
    That's the magic of trigonometry :)

    Indeed, it does so! :) Do you want me to say it straight out or should I leave you the fun of finding out for yourself? ;)

    From your text I figure that you use...
    x = longitudinal axis
    y = lateral axis
    z = vertical axis

    In the beginning we are untitled which means accel(z) is 1 while accel(x) and accel(y) are both zero. If you tilt the platform 30° around the lateral axis (y) then you generate an acceleration along the longitudinal (x) axis of sin(30°)., not cos(30°)!

    Accel(lon) = sin(30°)
    Accel(vert) = cos(30°)!

    Look at the graphs for a sine and a cosine, you will see that for small angles the sine value increases rapidly while the cosine looses barely anything. Only criteria that needs to be fulfilled is √(x^2+y^2+z^2) = 1

    ...same reason why cars that already use 86% of their available traction for turning can still use 50% of their available traction to accelerate :)

    Bottom line: Yes, we shift gravity away from Z onto X, but we get a lot more onto X than we take away from Z.

    ------------------------------------------------------

    btw. I got those filters working nicely, thanks for the code. Using an integrator now works like a charm. Not sure if it will introduce drift though. :)

    This is my backup plan:
    Bildschirmfoto 2019-05-13 um 22.24.08.png
    Grey for pitch and blue for surge. Assuming that the input step is an acceleration(Lon)

    Dirty :)
  16. harwoodr

    harwoodr New Member Gold Contributor

    Joined:
    Dec 9, 2013
    Messages:
    20
    Balance:
    296Coins
    Ratings:
    +10 / 0 / -0
    My Motion Simulator:
    Motion platform, 6DOF
    Yeah, the more I look at it, the less I think that worrying about the loss of of G in z axis is worthwhile.

    So, blue is with the double integration and is effectively distance of the travel in the simulator? and grey is with single integration and is the angle of the platform?
  17. harwoodr

    harwoodr New Member Gold Contributor

    Joined:
    Dec 9, 2013
    Messages:
    20
    Balance:
    296Coins
    Ratings:
    +10 / 0 / -0
    My Motion Simulator:
    Motion platform, 6DOF
    Okay, I've had some success with my motion cueing/kinematics...

    Video from my virtual simulator that I wrote today:



    Video of No Limits 2 - Crystal Beach Cyclone (the data from which is used in the first video):



    Cue the first to about 1:00 and the second to about 1:28 (that's where it gets interesting at least)... the blue line in the virtual simulator is the X-axis looking forward.

    I still have to do some tweaking on the filters/scaling... but this is very exciting for me...
    • Like Like x 2
  18. Dirty

    Dirty Active Member Gold Contributor

    Joined:
    Oct 15, 2017
    Messages:
    157
    Occupation:
    All the way up front.
    Location:
    Germany
    Balance:
    1,779Coins
    Ratings:
    +143 / 1 / -0
    I guess I finally have something to try out for anyone who would like to take a look:

    Nutkicker Motion Control

    It is not pre-alpha or even prototype stage yet. I think "proof of concept" would best describe it. It reads the data from DCS (100% done), processes it (~50% done) and sends the actuator commands via serial connection to a controller (~10% done).

    So far, I only support DCS World but X-Plane and P3D will follow.

    Instructions:
    1. Copy the Export.lua file into your [Saved games folder]/DCS World/Scripts. Please save your existing Export.lua (if present).
    2. Start Nutkicker Motion Control Software.exe and acknowledge the warning.
    3. Click "Start Server"
    4. Start the sim. The data will flow when a mission is running and not paused.

    Keep in mind: There is still a lot to do! This is by no means intended to be actually used for motion cueing at this stage of development. PM me if you want to try it out in VR.

    I have a Mac version as well!

    Dirty :)
  19. Dirty

    Dirty Active Member Gold Contributor

    Joined:
    Oct 15, 2017
    Messages:
    157
    Occupation:
    All the way up front.
    Location:
    Germany
    Balance:
    1,779Coins
    Ratings:
    +143 / 1 / -0
    Sorry, I phrased that totally stupid: That picture showed the filters as I use them NOW. I am about to make a few changes that I wasn't able to before.


    Before I talk about the integration, let me lay things out so that someone new to this has a chance to understand:

    Here's how a lowpass filter works:
    1. You pick a value between 0 and 1 that describes how much you want to smoothen out the signal. Let's call this value "alpha".
    2. To determine the output of your filter, let's assume that the current output of the filter at start time is 0 (zero).
    3. Whenever a "newInput" arrives, you calculate the "newOutput" of the filter by: newOutput = alpha * newInput + (1- alpha) * currentValue
    ...that's it. Your first Exponential Moving Average (EMA) filter :) basically you compose the newOutput with parts of the currentValue and parts of the newValue. How much of which, is determined by the value alpha. The higher that value, the higher the tendency of the filter to adopt the new value. I use values around 0.01 .

    If you send that signal through another LP filter, you have created a filter of 2nd order.
    If you send that signal through another LP filter, you have created a filter of 3rd order.
    If you send...

    ...you get the idea! :)

    Now, why would anyone want to send a signal, that has just been filtered, through the same filter yet again? Because it changes the characteristics of the signal in a quite important way. Each time, you add one level of "continuity".

    Here's the response to a step input of lowpass filters of different orders:
    Step LP.png

    The blue dotted line is the step input and please note that it is NOT continuous! It makes a step! Hence the name :) ...I guess.

    If I take that input value and send it through a lowpass filter, I get a LP filtered signal that is G0 continuous. Meaning each value "touches" its neighbour. It is not tangent, and certainly does not have the same curvature in that spot, but at least there are no more gaps.
    G0-Curve-Example.png

    If I take that output value and send it through another lowpass filter, I get a LP filtered signal that is G1 continuous. Meaning each value "touches" its neighbour, is tangent in that spot, but does still not have the same curvature in that spot, but at least there are no more corners.
    G1-Curve-Continuity.png

    If I take that output value and send it through yet another lowpass filter, I get a LP filtered signal that is G2 continuous. Meaning each value "touches" its neighbour, is tangent in that spot, and also has the same curvature in that spot. The curvature changes only gradually.
    g2-CURVE-CONTINUITY-1.png


    Take a look at that picture again:
    The yellow line has a corner. Curvature and change of curvature are infinitely high in that spot.
    The violett line has a radius. Curvature is present but moderate. Change of curvature (jerk) is still infinitely high.
    The green line builds up it's curvature gradually. Note that both curvature and the change of curvature are moderate.

    In this picture the gradient of the graph represents velocity, the curvature represents acceleration and the change of the curvature represents jerk. I will write about what humans can and cannot perceive next. So, once that is clear, it will become totally obvious why certain filters are chosen for certain DOFs.

    Basically it all boils down to the question of: "Do I want to make the occupant perceive something, or do I want to keep him from perceiving something"

    I'm gonna let that simmer for while :)

    Dirty :)

    Attached Files:

    • Like Like x 1