Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Assets Filo: cable system simulator

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

  1. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,663
    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:
    1,663
    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:
    1,663
  4. ceebeee

    ceebeee

    Joined:
    Mar 7, 2017
    Posts:
    395
    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:
    1,663
    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
    Aetherial87, web76 and ceebeee like this.
  6. ceebeee

    ceebeee

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

    Braineeee

    Joined:
    Nov 9, 2014
    Posts:
    1,211
    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:
    1,663
    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,383
    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:
    1,663
    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:
    1,663
    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:
    148
    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:
    1,663
    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:
    38
    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:
    729
    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:
    1,663
    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:
    1,663
    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.  
     
  25. FizzyAtWork

    FizzyAtWork

    Joined:
    Oct 27, 2016
    Posts:
    3
    Hi Arkano,

    I've got a problem with the filoropes setup shown below; the spool and endpoint are both fixed to the world, the load is suspended beneath the sheave, connected via a hinge joint.

    upload_2020-4-16_18-40-39.png

    At low speeds everything works fine, but when I lower the block at a higher speed the the wire on the spool side of the sheave goes slack and the block lowering speed is capped (to a much lower speed than freefall)
    When I hoist the block the wire on the other side of the spool goes slack, the sheave doesn't move and the block is launched upwards, eventually causing the rope on the spool side to go slack as well.

    This behavior seems to occur irrespective of the mass of the load and sheave used. Tried with different drum sizes too, looks like the wire speed is the culprit, not the drum rotation speed.

    upload_2020-4-16_18-38-32.png upload_2020-4-16_18-43-26.png
    Left - lowering with spool speed 1000 deg/s, right - hoisting with spool speed 1000 deg/s

    I've checked the sheave - there is no angular drag set, no spring or motor or limit set, the mass is low so I doubt inertia is to blame. Tried different physics materials but no change.

    Can you please tell me what I do wrong and how to solve this?
    Thanks!

    Kind regards,
    Jeroen
     
    Last edited: Apr 20, 2020
    Jimibog likes this.
  26. FizzyAtWork

    FizzyAtWork

    Joined:
    Oct 27, 2016
    Posts:
    3
    Hi Michi,

    I don't know if you're still looking for a solution, but I think what you could do is to basically use 2 cables..The 1st cable starts at spool 1 and ends at the (left side of) the object you're trying to transport. The 2nd cable starts at the (right side of) your object and ends at spool 2. If you want to transport more objects you just add new cables to chain the objects, with the ends of the chain hooked up to the spools.

    Good luck!

    Kind regards,
    Jeroen
     
  27. DrViJ

    DrViJ

    Joined:
    Feb 9, 2013
    Posts:
    154
    Hi, I tried to setup a simulation of moving pulley with your solution, the simulated objects are small. About 0.05 units, and ropes are stretching when I change the mass. Is there any way to stop them from stretching? I tried different settings from manual, but maybe I can change something inside to make it work with small sizes?
     
  28. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,663
    Object size does not have an impact on simulation, but mass does, and big time. All iterative physics engines (read: 99% of realtime engines) will lose some convergence speed when mass ratios are high (heavy objects being simulated together with light ones). While Filo minimizes this, you still have to deal with a baseline convergence speed, set by Unity's own physics engine.

    You could reduce your fixed timestep (found in Unity's time manager) or increase Filo's solver iteration count. Both will help convergence, allowing you to use larger mass ratios.
     
    DrViJ likes this.
  29. DrViJ

    DrViJ

    Joined:
    Feb 9, 2013
    Posts:
    154
    Thank you for your answer, I will experiment with it more
     
  30. DrViJ

    DrViJ

    Joined:
    Feb 9, 2013
    Posts:
    154
    Hi, could you tell how to make cicled ropes? like a belt on pulleys?
     
  31. FizzyAtWork

    FizzyAtWork

    Joined:
    Oct 27, 2016
    Posts:
    3
    Hi DrVIJ,

    I'm not sure if this would work, but perhaps you can use the same attachment point at both the start and the end of the rope? That should link them together I think. If that's not allowed/possible you can create 2 endpoints both linked to the same rigid body, like a clasp closing the loop.

    Good luck!

    Kind regards,
    Jeroen