1. Do not share user accounts! Any account that is shared by another person will be blocked and closed. This means: we will close not only the account that is shared, but also the main account of the user who uses another person's account. We have the ability to detect account sharing, so please do not try to cheat the system. This action will take place on 04/18/2023. Read all forum rules.
    Dismiss Notice
  2. 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 Now a Download Plan!
  3. 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
  4. 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. Do not follow these rules can lead to permanent exclusion from this website: Read the forum rules.
    Are you a company? Read our company rules

Writing a motion cueing software from scratch.

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

  1. hexpod

    hexpod http://heXpod.xyz

    Joined:
    Apr 18, 2016
    Messages:
    1,185
    Location:
    berlin
    Balance:
    7,636Coins
    Ratings:
    +369 / 5 / -0
    My Motion Simulator:
    DC motor, 6DOF
    Native Simtools 2.4 “third order” EMA Smoothing:

    • Like Like x 2
    • Winner Winner x 1
  2. Dirty

    Dirty Well-Known Member Gold Contributor

    Joined:
    Oct 15, 2017
    Messages:
    744
    Occupation:
    All the way up front.
    Location:
    Germany
    Balance:
    7,909Coins
    Ratings:
    +878 / 3 / -0
    True!!! Very true!!!

    I can also tell you where your butt out-performs your eyes:
    It's those moments where the "curvature-comb" pops out the graph. Where acceleration sets on. Hence "acceleration ONSET cueing". By choosing the right filters, you make a deliberate decision on exactly what to "show" your butt; In what way you present the onset of acceleration to your butt.

    Bildschirmfoto 2019-05-31 um 21.24.08.png Bildschirmfoto 2019-05-31 um 21.28.31.png
    In these pictures the magenta curve doesn't seem to look too different to the naked eye, does it? It looks just,... well,... curved :) But the curvature comb shows that the curvature onset (=acceleration onset) is very different. Those moments are what your butt notices a lot better than your eyes.

    I made a little comparison between two platforms.
    - One with 1st and 2nd order LP filters (graph has corners/radii)
    - Another with 2nd and 3rd order LP filters (graph has radii/curvature continuity)



    Important:
    Note how both platforms start and stop at the same time! However, see how one platform "explodes" into action in surge (corners in graph) while the other transitions more smoothly (radii).
    • Like Like x 1
    Last edited: Jun 1, 2019
  3. Dirty

    Dirty Well-Known Member Gold Contributor

    Joined:
    Oct 15, 2017
    Messages:
    744
    Occupation:
    All the way up front.
    Location:
    Germany
    Balance:
    7,909Coins
    Ratings:
    +878 / 3 / -0
    YAY-HOOORAY!!! COOL! Looks very nice.

    When you try it out and play around with it, could you do me the favour and see if it makes a difference of wether the CoR is near your neck vs. chest vs. belly? I could come up with good arguments for all. Maybe it even depends on personal preference.

    ...but certainly nice, smooth motion! Thank you, @yobuddy !!!
  4. Dirty

    Dirty Well-Known Member Gold Contributor

    Joined:
    Oct 15, 2017
    Messages:
    744
    Occupation:
    All the way up front.
    Location:
    Germany
    Balance:
    7,909Coins
    Ratings:
    +878 / 3 / -0
    I know, I'm kinda over-stressing this whole filter thing,.. but just for completeness' sake:
    IncreasingFilterVariable.png IncreasingFilterOrder.png

    Dirty :)
    • Agree Agree x 1
    • Informative Informative x 1
  5. Trip Rodriguez

    Trip Rodriguez VR Pilot

    Joined:
    May 8, 2016
    Messages:
    675
    Location:
    Lake Ariel, Pennsylvania
    Balance:
    3,922Coins
    Ratings:
    +330 / 6 / -0
    My Motion Simulator:
    6DOF
    Might be paranoia, but in the animation I feel like I still see the bump! that sudden upward movement looks too sudden to my eye. If you have this implementation though, I imagine I would be able to smooth the onset further?

    Ultimately what matters is that you guys are on the case! You are definitely focused here on addressing the single biggest complaint I've had. For a long time seemed like I was the only one bothered by this so I didn't have much hope of it getting fixed in the software. Ian at BFF seemed to think I was crazy when I tried to ask him about this problem. =P
    Last edited: Jun 2, 2019
  6. Trip Rodriguez

    Trip Rodriguez VR Pilot

    Joined:
    May 8, 2016
    Messages:
    675
    Location:
    Lake Ariel, Pennsylvania
    Balance:
    3,922Coins
    Ratings:
    +330 / 6 / -0
    My Motion Simulator:
    6DOF
    Dirty, In Ian's BFF simulation you can define the CoR as a value in mm above the upper joints.

    Now what I'm about to tell you may very well be unique to my sim, or unique to BFF, but I found that if I use this setting as intended for some reason the movement of the sim gets much less smooth. I wind up setting it to a very low value or even zero in the end for smoothness.

    A more direct answer though, I have been told that the CoR in most cases should be set approximately the height of your belly button or a couple inches above.
    Last edited: Jun 2, 2019
  7. Trip Rodriguez

    Trip Rodriguez VR Pilot

    Joined:
    May 8, 2016
    Messages:
    675
    Location:
    Lake Ariel, Pennsylvania
    Balance:
    3,922Coins
    Ratings:
    +330 / 6 / -0
    My Motion Simulator:
    6DOF
    By the way, you guys keep talking about 2.4 but I don't find any hints at just how "soon" we are talking about. Is it "soon", or is it "Soon™"? =P

    Wish me luck, I'm finally about to start installing these limit switches. Step one is finding exactly where they need to go. Once they are installed and tested next step is to set up SimTools and start testing and tuning motion!
  8. Dirty

    Dirty Well-Known Member Gold Contributor

    Joined:
    Oct 15, 2017
    Messages:
    744
    Occupation:
    All the way up front.
    Location:
    Germany
    Balance:
    7,909Coins
    Ratings:
    +878 / 3 / -0
    I would agree, and that is pretty much my approach as well. However, I can well understand the arguments for putting it near your neck (vestibular system) as well. I would love to do a blindfolded test, where someone changed the CoR without the occupant knowing where it is set. I'd love to know if someone could tell if he didn't know beforehand :)
    • Agree Agree x 1
  9. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    21,142
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    148,547Coins
    Ratings:
    +10,902 / 54 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
    The main functionality upgrades for 2.4 are complete, and there are a lot of them, but it only will be ready when the closed testing bugs are squashed, which there are only a small number of now, like tidying up the output order for the hexapod plugin.
    • Like Like x 1
  10. pmvcda

    pmvcda aka FlyPT

    Joined:
    Nov 3, 2010
    Messages:
    2,158
    Location:
    Portugal
    Balance:
    15,264Coins
    Ratings:
    +2,532 / 17 / -0
    My Motion Simulator:
    6DOF
    I'm implementing Butterworth filters, just for testing.
    Not sure if they are better.
    Need to make some speed tests.
    But here's some results in the new program.

    In gray, the signal received. A square wave.
    In red the filtered values.

    Here a result for a 2nd order Butterworth low pass:
    2.jpg

    And 4th order Butterworth low pass:
    4.jpg

    EMA LP(LP(LP)) vs Butterworth 4th order (arrows for Butterworth):
    Sem nome.jpg

    Edited: For better clarification...
    • Like Like x 2
    Last edited: Jun 2, 2019
  11. hexpod

    hexpod http://heXpod.xyz

    Joined:
    Apr 18, 2016
    Messages:
    1,185
    Location:
    berlin
    Balance:
    7,636Coins
    Ratings:
    +369 / 5 / -0
    My Motion Simulator:
    DC motor, 6DOF
    I am surprised to see the overshoots with your “second order” LPF

    Is it a “simple EMA” or a “double EMA” (DEMA) ?

    Normally, the overshoots comes from a DEMA math. Saying it because I don’t have any overshoots on a “simple EMA” even with second or third order.

    Could you maybe provide a pseudo-code of the math which are in use in your examples ?
  12. pmvcda

    pmvcda aka FlyPT

    Joined:
    Nov 3, 2010
    Messages:
    2,158
    Location:
    Portugal
    Balance:
    15,264Coins
    Ratings:
    +2,532 / 17 / -0
    My Motion Simulator:
    6DOF
    Overshoot is only for Butterworth, not EMA
    Maybe badly explained.
    Only the last graph has superimposed an EMA LP(LP(LP)) with a 4th order Butterworth.
    And the EMA as no overshoot.
  13. joe extraknow

    joe extraknow Member Gold Contributor

    Joined:
    Jan 4, 2017
    Messages:
    111
    Location:
    United States
    Balance:
    1,550Coins
    Ratings:
    +40 / 2 / -0
    My Motion Simulator:
    3DOF
    Great stuff, guys!!
    It seems a good time to consider building a 6dof flight sim,,,,,

    Thanks
    • Agree Agree x 1
  14. hexpod

    hexpod http://heXpod.xyz

    Joined:
    Apr 18, 2016
    Messages:
    1,185
    Location:
    berlin
    Balance:
    7,636Coins
    Ratings:
    +369 / 5 / -0
    My Motion Simulator:
    DC motor, 6DOF
    If I understand well, with second, third Butterworth order, you can reach the step destination sooner as with second, third order EMA, but you trade it with an overshoot.

    Complex math. Would certainly worth a try exploring its possibilities.
  15. BlazinH

    BlazinH Well-Known Member

    Joined:
    Oct 19, 2013
    Messages:
    2,145
    Location:
    Oklahoma City, USA
    Balance:
    16,621Coins
    Ratings:
    +1,835 / 32 / -1
    You can tell! I've tried cog above belly button and at seat bottom. The higher above seat bottom the smoother rotations feel since your upper body doesn't move as much. But you also now notice your butt rotating. It might be okay for flight depending on the model being flown but it doesn't feel correct at all when racing. It wasn't on a 6dof however.
    • Like Like x 1
  16. hexpod

    hexpod http://heXpod.xyz

    Joined:
    Apr 18, 2016
    Messages:
    1,185
    Location:
    berlin
    Balance:
    7,636Coins
    Ratings:
    +369 / 5 / -0
    My Motion Simulator:
    DC motor, 6DOF
    @Dirty, as you’re very familiar with excel, could you please in your spare time present a graph with two following scenarios:

    1.)
    first order EMA filtered with third order EMA
    2.)
    third order EMA filtered with first order EMA

    I am expecting a quiet different entry and exit curve.

    Thanks
    • Like Like x 1
  17. Dirty

    Dirty Well-Known Member Gold Contributor

    Joined:
    Oct 15, 2017
    Messages:
    744
    Occupation:
    All the way up front.
    Location:
    Germany
    Balance:
    7,909Coins
    Ratings:
    +878 / 3 / -0
    Oh, I am not an expert on filters. Only a "recreational user", so to speak. Maybe @Tim McGuire or @harwoodr can help out here with some background knowledge?

    My arguments:
    I'd be very surprised if there were a difference :). Let's call Ln = Lowpass Filter of n-th order (e.g. L3 = 3rd order Lowpass)

    You want to know if an L1 followed by an L3 is the same as an L3 followed by an L1. So, the question is:

    L1 + L3 = L3 +L1 Is this statement true?

    We already know that... L3 = L1 + L1 + L1 ...because that is how L3 is defined :) So, in the first statement we can substitute the L3 with L1 + L1 + L1 and get...

    L1 + L1 + L1 +L1 + L1 = L1 + L1 + L1 + L1 ...which is obviously true. Therefore...

    L1 + L3 = L3 +L1 must be true as well.

    Or in plain English:
    A third order lowpass filter is the same as three first order lowpass filters in sequence. If you want to add another identical first order lowpass filter, it doesn't make a difference whether you add it before (L1 + L3) or after (L3 + L1).

    Or in plain Math:
    EMAs are commutative! (I think)

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

    But are they still commutative when they have different filter variables?...

    Let's call L(x) = Lowpass filter with filter variable x (e.g. L(0.2) = 1st order lowpass filter with 20% adoption rate per frame)

    Commutativity1.png Commutativity2.png

    you can switch back and forth between the images to see the difference. The resulting (blue) output line does not only look identical, it actually is the same values. I've done the math, the difference is zero :)

    For all I can say:

    L(a) + L(b) = L(b) + L(a)

    Dirty :)


    Note: In this case "+" is not the addition operator. The filter outputs are not being added. I am not 100% sure, but I think "concatenation" or "convolution" are better terms. Maybe someone can clarify that.
    Last edited: Jun 4, 2019
  18. Dirty

    Dirty Well-Known Member Gold Contributor

    Joined:
    Oct 15, 2017
    Messages:
    744
    Occupation:
    All the way up front.
    Location:
    Germany
    Balance:
    7,909Coins
    Ratings:
    +878 / 3 / -0
    Oops,....

    You asked for a graph :) Commutativity3.png

    It doesn't make a difference whether you...
    ...take a 1st order filter (yellow) and then three more to reach the 4th order filter (red), or...
    ...take a 3rd order filter (green) and then another 1st order to reach the 4th order filter (red).

    What I learned about filters:
    -You want to turn corners into radii into transitions? --> Increase filter order.
    -You want to "shallow out" the graph and avoid steep gradients? --> Use lower filter variable.

    That pretty much sums it up :)
  19. Trip Rodriguez

    Trip Rodriguez VR Pilot

    Joined:
    May 8, 2016
    Messages:
    675
    Location:
    Lake Ariel, Pennsylvania
    Balance:
    3,922Coins
    Ratings:
    +330 / 6 / -0
    My Motion Simulator:
    6DOF
    Nice work Dirty. You have no idea how excited I am for the work you guys are doing. I'm finally going to get rid of the potholes (that's what we call big holes in the road in case that's unfamiliar to anyone) in my virtual air!
  20. hexpod

    hexpod http://heXpod.xyz

    Joined:
    Apr 18, 2016
    Messages:
    1,185
    Location:
    berlin
    Balance:
    7,636Coins
    Ratings:
    +369 / 5 / -0
    My Motion Simulator:
    DC motor, 6DOF
    Thanks @Dirty for your involvement !

    I did some more tests and yes, indeed, it seems that I started to think about the filtering superpositions with wrong assumptions.

    However… :)
    As It's time soon to decide what has to be behind SimTools sliders, I am drilling more into the topic:

    @yobuddy , what's in the vid can also catch your interest.



    You notice 1st order EMA (C-curve) followed by another 1st order EMA with 3 different weighting factor making the response more and more smooth going into the S-curve response.
    Last edited: Jun 4, 2019