Search Unity

  1. New Unity Live Help updates. Check them out here!

    Dismiss Notice

Assets Filo: cable system simulator

Discussion in 'Works In Progress' started by arkano22, Nov 14, 2018.

  1. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    658
    Hi guys,

    I've been writing a cable simulator asset based on this paper:

    http://matthias-mueller-fischer.ch/publications/cableJoints.pdf

    Here's it running inside Unity:



    It allows to simulate arbitrarily complex cable-driven machines with pulleys, spools, pinhole sliders, and concave/convex objects, both in 2D and 3D. You can have both open and closed cables, and supports extremely involved setups.

    You simply specify a list of objects that should be part of the cable path, what side should the cable pass trough, how it is linked to the objects (pinhole, attachment, free rolling) and voilà.

    The key idea here is not to simulate the cable itself (using a chain of rigidbodies/joints or particles/constraints) but to simulate the effects the cable would have on the objects it touches, by linking them using a custom type of joint. This results in dirt cheap, very stable results. The cables support extremely high tension and mass ratios. The cost does not scale with the length of the cable, but with the number of objects it affects. You can easily have a perfectly working setup with +200 pulleys.

    The downsides are: it cannot simulate free cables (cables with one or both ends free) it will not collide with objects (despite what it looks, no collision detection / response is taking place, at all), it cannot be torn/cut and does not model torsion/twisting effects.

    I'm thinking about making it available in the store for a moderate price (around 20-30 bucks).

    Thoughts on this one?
     
    Last edited: Nov 14, 2018
    olix4242 and Antypodish like this.
  2. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    658
    Another video:



    In this scene, the mass ratio between the platform and the cable is 1:1000. It takes less than a millisecond to simulate each frame.
     
    Antypodish, witson and Mark_01 like this.
  3. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    658
  4. ceebeee

    ceebeee

    Joined:
    Mar 7, 2017
    Posts:
    397
    So I understand this can't do some things that Obi Rope can do, but I have to ask, what can this do that Obi Rope can't do?
     
  5. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    658
    Any of the scenes shown in Filo's promotional video, would have been near impossible to achieve using Obi.

    We're working in a comparison table for both, as they use very different approaches but since both are rope/cable simulators, it can be quite confusing.

    Obi uses the "traditional" approach to rope simulation: small mass lumps (particles) linked together by constraints. This works fine for relatively short ropes, you can get collisions and self collisions, free rope physics (ropes not attached to anything), frictional contacts....anything you'd expect from a real rope.

    However, it scales quite bad: long ropes mean more particles --> more constraints, high mass ratios can destabilize the simulation, complex contact setups can become unreliable... the only fix to these is cranking up quality settings in the solver to achieve acceptable results. These issues are common to all iterative physics solvers, Obi is no exception.

    Filo does not simulate the cable itself, at all. It only simulates the effect of the cable on objects touched by or attached to it. So the cost of simulation does not increase with the length of the cable (for Obi, more cable = more particles = costlier simulation) but with the amount of objects involved in the cable system. This means you can simulate a perfectly stable system of 100 pulleys and 1 kilometer of cable at extremely low cost (comparable to having a 100 particles long cable in Obi) something that is well beyond the capabilities of any other traditional rope solver.

    The downside is that cable can only exist as part of a system (that is, a list of predefined objects), and will only react to objects in that system.

    Trying to sum up:
    Obi
    Can simulate free cables, frictional contacts, collisions with any object in the scene, self-colliding cables, but it is not very good at large scenes with very long cables or many objects affecting the cable, as this increases the solver cost considerably.

    Filo
    Cannot simulate free cables, frictional contacts, or self-collisions. Cable will only collide with a list of predefined objects. However it can be as long as needed, it is very resilient to large mass ratios, extremely stable when dealing with complex contacts against lots of objects, and is much cheaper performance-wise.

    The moral of the story is: Filo is tailored for complex cable setups (machines, pulley systems, cranes, etc). These usually operate under high tensions, using large weights and lots of contacts. Obi is better for relatively simple ropes that don't have to resist a lot of tension, don't need to support large weights, and don't have lots of contacts.
     
    Last edited: Dec 12, 2018
    DragonShadow, web76 and ceebeee like this.
  6. ceebeee

    ceebeee

    Joined:
    Mar 7, 2017
    Posts:
    397
    I see, thanks for the detailed explanation. :)
     
  7. TonicMind

    TonicMind

    Joined:
    Nov 9, 2014
    Posts:
    1,197
    Hey, this is really cool!!

    I can't wait though to implement my 10 square km string-can communication network simulation!!
     
  8. pelesrelewot

    pelesrelewot

    Joined:
    Sep 13, 2017
    Posts:
    1
    Nice! So the rope is part of a closed simulation system but i can afect that same spool with rigidbody, collider and fixed joint, have it on a driveable vehicle for example as a winch is that right?
     
  9. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    658
    Yep.

    Spools/pulleys must be rigidbodies in order to be part of the cable system. You can choose to freeze rotation on all axes except the one they're supposed to roll around for convenience. You can freeze their position, or you can let gravity affect them. You can parent them to other objects, add all kinds of joints on them, and add colliders to them.

    So they can be mounted on top of a vehicle or any other device/machine, that's precisely the intended use case for Filo.
     
  10. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,034
    How hard was it to implement this? Could you give some more insight on the process of the implementation, like what were the hardest parts and how long it took you.
     
  11. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    658
    Hi!

    It took around a month, on and off. The basic implementation is quite straightforward, but the devil is in the details.

    The basic algorithm (disc - disc joints) is really easy to get working. Arbitrary shapes are a bit more work since you need to find the convex hull of the 2D intersection of the mesh with a plane, which involves a bit of tedious mathwork, but still quite manageable.

    Adding pinhole links and attachments is fairly easy too (simply follow the code in the original paper).

    Rendering however is not covered at all in the article, and getting it to work correctly in all cases took a good deal of work. Spool rendering in particular was difficult to achieve and required a few modifications to the core algorithm, so that the tangent point of the joint would displace along the spool's rotation axis depending on how much stored cable was left in the spool.
     
    Last edited: Dec 27, 2018
    alexanderameye likes this.
  12. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    658
    Hi there!

    Just uploaded Filo 1.1 to the store, should be available in a few days. The biggest addition in this *free* update is the dynamic split/merge system for joints. This enhances cables by allowing them to dynamically enter/leave contact with new bodies at runtime, opening up a lot of new possibilities. There's no need for these bodies to be listed beforehand, you can spawn/remove them at runtime also.

    Simply enable the "Dynamic Split/Merge" checkbox in your cable, and it's done. Hope you find it useful, and fun!

     
    Last edited: Feb 1, 2019
    Antypodish and ceebeee like this.
  13. web76

    web76

    Joined:
    Nov 4, 2009
    Posts:
    141
    Hi, thank you for this great asset, I have been looking for something like this a long time. Overall the performance is great, with all combinations of the asset, except when I use the spooling system the "cable renderer" takes a LOT of resources.. goes fror 150 fps to 50 fps if you have 25m cable on the spool... Is there a way that you can simplify that?
    The simulation is still fast, and when I swap out the hybrid link with attachment it is also fast..
     
  14. JohnnyRey

    JohnnyRey

    Joined:
    Jan 26, 2013
    Posts:
    16
    Would this be the best to simulate a fishing line? I haven't been able to find a good solution yet.

    Thanks!
     
  15. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    658
    Hi!

    No. Filo cannot simulate free cables and will only perform accurate simulation for completely tense cables (cables with some slack are only procedurally rendered using a catenary curve). Fishing lines are both free cables, and rarely completely tense.

    I'd use our other rope solution, ObiRope. However it is a much more complex system, and not compatible with consoles.
    https://assetstore.unity.com/packages/tools/physics/obi-rope-55579
     
  16. Juanola_

    Juanola_

    Joined:
    Sep 29, 2015
    Posts:
    8
    Hey Arkano!

    How are you? I m working with Filo, wonderful asset!

    I wanted to ask you. I have to make a really big spool, with 230 mts of rope stored. Once the rope is consumed, a new spool appears, which is insider the bigger spool; and then it repeats again.

    I wanted to ask you, what is the best approach to do this? I am working with one big spool, and I get some performance issues.

    Thanks!

    Juan
     
  17. MichiW1987

    MichiW1987

    Joined:
    Sep 24, 2013
    Posts:
    1
    Hi,
    Is it possible to transport a rigid body from A to B via the Filo Cable Simulator ?
    Like a cable rail (funicular, lift).
    funicularq.jpg

    At the moment it doesn't work , maybe the reason is that I am a newbie programming.
    I love Filo cable simulator and OBI Rope as well.
    Friendly Greetings Michi !:)
     
  18. sjm-tech

    sjm-tech

    Joined:
    Sep 23, 2010
    Posts:
    695
    Hey Arkano!
    I would like to replace my static ropes (my last ancient ship project) with Filo and Obi Rope and now I'm playing with it.
    With Filo I will try to replace the maneuvers of the ships that are actually pulleys and with ObiRope all the free ropes and knots.
    Do you think it's something doable?

    ship.jpg


    Filo feature request:
    - I'm looking at the Filo cable generation and i see that Filo does a vable mesh optimization adding subdivision only when needed (which is cool) but would be nice to have the option to swich to a constant subdivision option(like ObiRope) useful especially for tessellation shaders.

    filoTess.jpg
    Filo with tessellation shader (wrong result)

    OBITess.jpg
    Obi with tessellation shader (good result)

    Best
    Max
     
    MostHated likes this.
  19. faizananjum2u1

    faizananjum2u1

    Joined:
    May 28, 2018
    Posts:
    1
    Hi Arkano22
    I am trying to make a weight machine using Obi Ropes. But OBI ropes are quite stretchable. My goal was to make them less stretchable so i increased its constraints. But on increasing constraints its becomes slow and starts hanging on mobile build.
    My question is should i use OBI Rope for this purpose or Purchase Filo-The Cable Simulator ? I need something fast and less stretchable.
     
  20. edvin1989

    edvin1989

    Joined:
    Nov 28, 2019
    Posts:
    6
    When I hit play in unity, the spool automatically starts transferring the cable into the spool. Any idea why? Spawn speed is set at "0".
     
  21. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    658
    Hi,

    Without taking a look at your setup, I can't know for sure.
     
  22. edvin1989

    edvin1989

    Joined:
    Nov 28, 2019
    Posts:
    6
    Hi

    How do you change stiffness of the cable?

    Regards
    Edvin


     
  23. technomar

    technomar

    Joined:
    Nov 24, 2016
    Posts:
    2
    Good afternoon Arkano!
    I've been tinkering with your code trying to change the length of the cable by code. Maybe you can shine some light on this matter.

    Regards!
     
  24. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    658
    Hi!

    You can either use a hybrid link/spool (the actual physical length of the cable does not change, it is just reeled in/out) and control it via a motorized joint (built-in unity component), or you can use an attachment link.

    There's many samples included in the asset of the spool method. To change the length using an attachment link, simply set its cableSpawnSpeed (expressed in meters/second). Like this:

    Code (csharp):
    1.  
    2. public Cable cable;
    3.  
    4.  
    5.     void Update () {
    6.      
    7.         if (cable != null){
    8.  
    9.             var link = cable.links[0];
    10.  
    11.             if (Input.GetKey(KeyCode.UpArrow)){
    12.                 link.cableSpawnSpeed = -0.02f;
    13.             }else if (Input.GetKey(KeyCode.DownArrow)){
    14.                 link.cableSpawnSpeed = 0.02f;
    15.             }else{
    16.                 link.cableSpawnSpeed = 0;
    17.             }
    18.  
    19.             cable.links[0] = link;
    20.         }
    21.     }
    22.  
     
unityunity