Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Excavator simulation

Discussion in 'Made With Unity' started by Jean-Fabre, Nov 12, 2010.

  1. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    Hi Everyone,

    I am new to Unity and wanted to share with you my first project, a humble excavator simulation.

    http://www.fabrejean.net/projects/excavator

    The look and feel was not a priority, tho I made two different small worlds ( to support also streaming testing).

    -- first notice: No... I haven't yet tackled digging the ground, but you can pick up objects with the bucket fine. I found several scripts and solutions for terrain heights real time mods, but they are too "simple" for that need, as the interaction between the bucket and the ground is very complex and close to boolean computation. I realize I will have to compromise on that to balance the time spent on this versus the actual enjoyment and game play. But definitely on my list of things to do!

    -- I primarily focused on the physical simulation itself to achieve a stable rig and find ways to overcome some limitations of the physics joint system, mainly the fact that velocity drive is powerless at velocity 0 so all the joints that drive this excavator are wrapped with a system that switches from velocity to position drive when resting, this allow for a very stable and predictable solution. Using just position drive would cause problem as target angles gets further away from the current state, increasing energy and cause violent reactions. With my system, it is not happening. Very pleased with that.

    -- The tracks behavior and physics is weak, I am aware of this, I went the wrong way, but failed so far to achieve a proper tracks behavior, it's not really a wheel, that's the problem, and having each track pad a physical entity is out of the question ( or is it? ). So definitely more work needed here.

    -- I also wanted to fully grasp how the gui system was working, I extended the gui with a progress bar, radio button, and other little things like bindings gui sliders with user inputs. It's quite good but also quite limited, I simply do not understand why the same behavior principle is not applied for the gui. Adobe Director had ( yes "had" not "has"...) a great behavior system for 2d, and failed miserably to do the same when it introduced 3d, and Unity has done the opposite, great 3d behavior system, and what seems a hack for the 2d system ( tho I like the approach, it simply lacks the oop paradigm).

    -- User inputs was also a "problem" since the inputs are only available to users on standalone version ( something I really don't understand...), This is not a major issue as this proof of concept targets exhibitions shows and custom installs ( for example at a booth, to attracts customers). but for a web distribution, I appreciate that a proper input selection and management system is needed,

    -- The interface is multi lang, just to show it's possible, tho it's not tight with the supporting micro site yet, nothing difficult, but my trial license expired so can't make new builds...:-|

    -- I overdid visual effects... I aware of this, but coming from Adobe Director, I guess it was a compulsive reaction... I will try to control myself next time. But you can enabled disabled them individually to fit your taste and achieve good framerate. There is a little script that automatically disabled effects if the framerate is too low, all this is tunable via the interface of course.


    Feedback and critics eagerly welcomes, they are many areas to improve ( better frame rate, better handling, more consistent physics behavior between mac and pc, better, more original gui, better user feedback, etc etc). Your opinion will also help me gain objective view on this too.

    I would like to warmly thanks the unity community, specifically Unity Answers system. It greatly participate in making my first go at Unity a true enjoyment, and comfort me that Unity is the right choice, not just from a technical point of view, which is very important to me.

    Have a good day,

    Jean
     
  2. granada

    granada

    Joined:
    Oct 31, 2010
    Posts:
    135
    Great fun playing with this,i got quite involved with it.My cup of tea went cold.

    Dave
     
  3. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    Hi Dave,

    Cool that's the spirit yes :) cold tea cup happens to me too, it's scary how times flies in front of a computer...


    Bye,

    Jean
     
  4. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
    Hey this is fun! It would be great to also have the ability to dig into a landscape excavating dirt. Keep up the good work.

    I wonder how a real excavator works. Do you have 4 joysticks you move up and down or is there a more unified control system like an human arm?
     
  5. Taigo

    Taigo

    Joined:
    Feb 18, 2010
    Posts:
    128
    Damn, this is really awesome, i love this kind of machinery.
    I really hope to be able of doing something similar down the road.
     
    Last edited: Nov 12, 2010
  6. JRavey

    JRavey

    Joined:
    May 12, 2009
    Posts:
    2,377
    I used to love the Komatsu arcade game.

    I was able to pick up a few bricks with your project. The hydraulics looked really great.
     
  7. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    Hi Puppeteer,

    Digging is theoritically possible, but very complex ( as I want to do it in a realiystic way), so I will need to organise myself several days in a near future to code this, this is the big thing missing yes.

    It's usually two joysticks, so you can either plug two normal joystick or play with a game pad like the xbox game pad or the logitech gamepad, tho because I did not put up a custom input selector, you can only tuine this on the standalone versions, the web version is pre configured to work with the logitech one ( other compliant game pad will also work if they follow the same axis definition).

    bye,

    Jean
     
  8. StephenL

    StephenL

    Joined:
    Oct 18, 2010
    Posts:
    218
    This is really cool. :)
     
  9. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    This stuff brings out the little boy in us all...
     
  10. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    For feedback, physics are a little jerky (I don't mean the nice shake you get when you stop) - this is solved by enabling interpolation for your physical bodies.

    It's just timing interpolation as physics are updated at a different timestep to the main app.
     
  11. kin

    kin

    Joined:
    Nov 14, 2010
    Posts:
    2
    Neat stuff so far... I'm interested in what technique your thinking about using for the ground deformation? My first thought would be to use voxels! they could be made bigger or smaller depending on the users computer power. I really dislike the idea of using height mapping... You have an idea?
     
  12. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    Hi Hippocoder,



    Are you on mac or pc? and what frame rate do you achieve if you have no visual effects on?

    I have interpolation enabled on the physics bodies ( arm, bucket, body), and I have tweaked timing and solver iteration count. On mac it's perfect, but on pc I can't achieve a good balance as I can really increase the solver iteration value much or the whole physics computation slows down ( not the frame rate, just the physics).

    Bye,

    Jean
     
  13. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    Hi Kin,

    Voxels is out of the question isn't it as I have seen in posts that voxels is not supported in Unity.

    If I go with terrain height edited, it has obvious limitation like diggin concave holes and "cavern" in the ground right through a cliff. My opinion is that I don't think technic is available to allow complete digging freedom ( willing to learn if indeed there is:) ) so my approach is the following:

    1: Experiment with terrain height editing as this will enabled conventionnal use of diggers action ( dig verticaly in the ground), the transfert of matters from the ground to the bucket is my biggest concern and a strong algo is needed to compute how much of the earth the bucket is taking with itself as it lifts off, then there is the interaction between the ground and the bucket. for example if the bucket is flat on the ground and I turn left, I will move earth with the side of the bucket, I want this to happen, for this I need to find/ adapt code for terrain modeling tools as it's the same approach as when you design terrain with your mouse.

    2: make big rocks as mesh, and the rest as particles. I think this is the quickest solution, if the scenery is a mine or something, then I can get away with putting big rocks so that 4-5 can fit in the bucket ( more and it becomes a bit difficult for the physics engine to cope), then simulate smaller gravels and sand with particles.

    the other very important aspect of this is splat map editing, so that when the bucket releases its load, is actually shows on the ground that amount of debris with the right texture ( same with the tracks actually, I need to modify the splat so that the excavator leaves trails as it evolves around).

    Bye,

    Jean
     
  14. skycc

    skycc

    Joined:
    Oct 1, 2010
    Posts:
    11
    i just want to know how do you make the animation
     
  15. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    Hi,

    Could you be more explicit please? There are several animation going on in this simulation, I'll describe the one I think are interesting:

    -- arms: each arm is a physic object and they are each connected with a configurable joint ( even the wheels). The final movement is achieved by controlling the joints using forces. It's quite simple when there is only joint, but in our case, there are several AND they form a chain, which adds to the complexity and makes the whole thing a lot more unstable so the most difficult part is to tweak the settings to achieve a stable rig.

    -- tracks: each track pad is interpolated along a path. The difficulty is to allow for infinite looping and reversal. Since the excavator is fully controlled by physics, I simply match the angle of rotation of the hidden wheels to know by how much I have to animate the tracks. This allow for accurate representation of the excavator slipping on steep surfaces or trying to push objects.

    -- bucket linkage with piston. this one is using a custom inverse kinematics script so the various rod and linkages work together in a realistic manner.

    If you need more explanation on a particular aspect, ask, and I'll give more details. All in all, this is definitely not something I would recommend if you are starting with Unity, unless you like challenges. Try with a simplier rig like a front loader or a dumb truck.

    Bye,

    Jean
     
  16. lukos86

    lukos86

    Joined:
    Nov 19, 2010
    Posts:
    4
    Good stuff. Keep going
     
  17. wallen

    wallen

    Joined:
    Jul 29, 2010
    Posts:
    14
    really cool,and the link is gone.
     
  18. JRavey

    JRavey

    Joined:
    May 12, 2009
    Posts:
    2,377
    It is gone, I just tried it.
     
  19. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    Hi,
    Sorry.. yes, forgot to update credit card details.. d'oh!

    Thanks for watching :) much appreciated that this project is getting viewed so much, even tho it's like 2 years old made out during my learning phase of Unity :)

    It is back online now.
     
    Last edited: Feb 28, 2012
  20. wallen

    wallen

    Joined:
    Jul 29, 2010
    Posts:
    14
    nice ,nice.
    connecting arm with configurable joint.is there some tutorial on configurable joint ?
    thanks
     
  21. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    Hi,

    No tutorials on my end I am afraid, but I have a simple demo, nothing fancy but it features the script I am using in that excavator to control the joints. It's only part of the deal, but it will give you a head start.

    disclaimer. since the writing of these script, a lot has changed in the physcis implementation of Unity, and it nows has random crashes when joints are at their limits that before were never there. So you mgiht have to fiddle with the various properties to reach again a stable behavior. I had not time since to properly rebuild it for 3.5 :)

    simple joint demo package

    the demo is about 3 box jointed together with my system. And you use horizontal and vertical axis to control them.

    if you have any questions, comments, better code, do not hesitate!

    bye,

    Jean
     
    Last edited: Dec 11, 2017
  22. wallen

    wallen

    Joined:
    Jul 29, 2010
    Posts:
    14
    Jean,
    This gave me great help. i connected the arms with configurablejoint ,but it seems not to be steady.

    thanks a million. Next step,digging on the terrain...
     
  23. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    Hi,

    Yes, you'll need to fiddle with the physics and time settings to achieve a tight rig, else it wobbles isn't it. This really depends on your rigidbodies setting and the rig as a whole. If in trouble get back to me, we'll try to make it work.

    digging terrain: You'll need more than luck to get there :) very difficult if you want to get it right and believable.

    Bye,

    Jean
     
  24. lockbox

    lockbox

    Joined:
    Feb 10, 2012
    Posts:
    519
    I like it! Looks professional and works well! Good job!
     
  25. tasadar

    tasadar

    Joined:
    Nov 23, 2010
    Posts:
    290
    looks good but i think it is not possible to make a real simulator with ordinary physx joints. if this will be a game its ok but not for a simulator. the physx 3.x has an articulation joint but it also has some limitations.
     
  26. wallen

    wallen

    Joined:
    Jul 29, 2010
    Posts:
    14
    thanks Jean.
    yes,i am digging terrain with getheight/setheight,but the hole i did is very rough,may some interpolation needed.
     
  27. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    @lockBox: thanks :)

    @tasadar: This excavator solely relies on configurable joints, nothing else, even for the tracks. Indeed there are lots of limitations and weird undocumented stuff, the worse being not having any feedback on force and torque currently applied to a joint ( from external source and internal sources). So it's very difficult to implement some more complex systems. Apart form that, this simulation is perfectly valid for training I think, actually more than for a game, because for a game, it would have to be a lot more optimized for frameRate etc etc, but for a simulation, you just get a high spec machine and concentrate on making it behave like the real thing, which I think I am very close ( yet so far from it... :) ) When I demo this, I use two joysticks ( not a pad, two different joysticks) which is then how you actually control it for real, this really makes a difference and is much easier than by keyboard and far more precise.

    @LunHai: the actual terrain deforming is not what scares me, what really gives me headache is how to control the amount of gravel or ground going into the bucket and how the terrain deforms when the bucket is in the ground and you move it on the side, if bucket is too deep, you would not be able to move, else it would make a trench, etc etc. Using particle system or some dynamic boolean operation is likely the way to go, but seems like a beast to tackle for this purpose.

    Bye,

    Jean
     
  28. LS16BMX

    LS16BMX

    Joined:
    Nov 11, 2011
    Posts:
    94
    Hi Jean,
    Thanks so much for putting this out !
    It's very interesting how you have coded this and i'm sure it will be a great help to me once i've had time to go thought it.
    I'll post back my progress asap.

    Cheers
    Matt
     
  29. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    Hi Matt,

    Leeds!! I studied in Leeds back in the years, what a great town! I miss it. Used to gig every other day solid, great venues and people.

    I am planning on a release on the asset store, but the work involved is too much right now, maybe during the summer ( I have learned so much until then, that a rewrite is needed...)

    Bye,

    Jean
     
  30. omarzonex

    omarzonex

    Joined:
    Jan 16, 2012
    Posts:
    158
  31. BlackMantis

    BlackMantis

    Joined:
    Feb 7, 2010
    Posts:
    1,475
    Pretty cool, and looks real nice too.

    Take a look at my BackHoe Loader Just Click Here.
     
  32. muzel

    muzel

    Joined:
    May 8, 2012
    Posts:
    6
    hi
    thanks alot for that "simple joint demo package" it really helped me alot. since i am working on a project, with a robot arm simulator for my work. and i have only used unity for 2 week .and was able to create movements for my robor arm thanks to jeanfabre :)
    my next problem now is to add 4 more axis to my arm.
    im no good at scritps, so i have only manage to use the Horizontal and Vertical for my robot. how can i add support for the extra axis. and also support for 2x3axis or 3x2axis joysticks.
    link to comiled project so far
    http://muzel.snerk.biz/

    got it working as i wanted now. just some fine tuning left
     
    Last edited: May 10, 2012
  33. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
  34. Gherid_lacksGPS

    Gherid_lacksGPS

    Joined:
    Dec 3, 2011
    Posts:
    111
    Damn, I think my on site supervisor is going to fire me.....you don't win any friends when you dump it on it's side, lol.

    Well done and super fun. Is this really for some sort of worker training?
     
  35. dterbeest

    dterbeest

    Joined:
    Mar 23, 2012
    Posts:
    389
    This is very cool!
    Love this kind of simulators :)
    I feel a good game (though for a niche market) coming here!
     
  36. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    Yes, the theoretical purpose is for training, I wanted an accurate and realistic behavior down to the commands, I usually demonstrate this to clients with two joysticks, one on each hand, and it really is cool to control it this way :) if you have a dual pad that works too.
     
  37. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    This is currently under review in a university in Denmark ( or norway, can't remember) for a CAVE integration, can't wait to see the result :) will post when I have news.

    I developed it to demonstrate skill, and got contracted for other niche markets as a result, these kind of demos make sense when people can extrapolate on what can be done in a similar way, As for the excavator simulation market, I do need a soil control, with the ability to really dig and interact with sand in a realistic manner, which really becomes a nightmare just by thinking of it...

    I am not planning on making this as a game, tho the demand is very high for getting the code, so when I get time ( which unlikely for another century or two... :) ) I am planning on rewriting the messy bits ( I did this for learning... and I learned so much that it would not do any justice to my current skills to distribute the current code as is) and distribute it on the asset store as a complete project, It features a lot so it has potential.

    Bye,

    Jean
     
    Last edited: May 14, 2012
  38. tasadar

    tasadar

    Joined:
    Nov 23, 2010
    Posts:
    290
    nice one but lacks interaction with ground. Check this one : http://vimeo.com/38515372
    i worked on this at my previous job. It is really hard to do this with unity right now since it requires a different kind of joint system.
     
  39. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    Hi Tasadar,

    Nice simulation :)

    Also, I am not sure what you mean with "hard to do with unity", since I've done the same thing with the excavator, unless I am missing something from the video? my excavator can also take rocks ( the first level have funcky colorful cubes, but the second level has rocks, and actually one in its bucket as you starts).

    on what way the joints you are using are different? I did use solely configurable joints all over the excavator rig, nothing else is used to control it actually, and it's working ok ( lots of tweaking tho). Interested to learn about how you did Rig the back hoe on that video tho


    Bye,

    Jean
     
  40. tasadar

    tasadar

    Joined:
    Nov 23, 2010
    Posts:
    290
    Of course you can do the same, at least it will look the same but cant give enough stability for a simulator. ordinary joint solvers cant easily handle high mass ratios between bodies. for ex. if the vehicles body is 10 tonnes and the movable arms are 100 kg each, then you will likely get jittery behaviour like this one.

    When your digger hits a static object and you force the vehicle to move forward while your digger is obstructed, there will be some instability with the joints and either they move or jitter.

    Look for articulations in new physx 3.x versions. They have their own limitations of course but much cheaper then using high solver iteration counts.
    And about the model, it has a mixture of animations and manually tranformed bones. Im not an artist so i dont know about rigging.
     
    Last edited: May 15, 2012
  41. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    eh eh, good point, that's exactly where I tweaked my rig :) all arms have no mass, only the main body has a mass, and increase solver iteration.

    You know, to be fair, the most stable rig I have achieved was in Adobe Director. Before I did this excavator in Unity, I actually did it in Director, and it was unbelievable stable. the reason I did this in Unity is I wanted to make sure dropping Director ( cause Director is dead...) for Unity was sensible, so I gave myself 30 days ( the trial period ) to do the same in Unity, of course, I was blown away ba every thing but the physics implementation....

    This is odd, director also use physx, but the set up and the exposed api is not exactly the same, and I have to admit, Unity doesn't come anywhere close in terms of stability of such rig compared to Director. The final results, smoothness, woobliness is definitly better in director... sad, especially when it doesn't seem that Unity will implement physx 3.x before a long time...

    I am dreaming of true interactive IK/FK in Unity also.... I am amazed no one has released *anything" on this on the asset store!
     
  42. tasadar

    tasadar

    Joined:
    Nov 23, 2010
    Posts:
    290
    Games usually do not need that accuracy so even if unity starts using 3.x i dont think that they will include articulations. Nvidia states that it is an experimental feature and it also has some limitations like no spatial movement available yet. On the other hand i remember reading that Bullet will have such feature in the next versions.

    This is something usual actually, if you want something specific you need to do it yourself or buy something that only does that job. In this case there are some simulator engines available which are possibly expensive stuff...
     
    Last edited: May 15, 2012
  43. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429

    Indeed: issue is, Unity can do so much more than games! I haven't build a single game with Unity so far, I only do simulations, presentations, technical, scientifical projects... It's actually difficult sometimes because clients ( unaware of what Unity is) sees the Unity advertisement target, and thinks this is only for games and that it will not be able to cope with their projects, where it actually is 99% the case the perfect solution!
     
  44. muzel

    muzel

    Joined:
    May 8, 2012
    Posts:
    6
    hey thanks a gain for great script. i found out. but asking on irc. im totaly new to unity. and i was told to look in the drop down menu ->edit -> project settings --> input. i bought 2 joysticks and added their inputs to each axis. and fine tuned it all. i had also had to increase processor priority on the physics engine to avoid the sloppy "gay" like hand movement by the sturdu fully Titan robot arm. now im almost done with my program. and gonna have a show off on projector for up to 200 people on a marketing day, the 7th june at my work. so thank you very much jeanfabre for sharing this script
     
  45. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    Hello Muzel,

    I am glad the script was useful! good luck with your meeting!

    Bye,

    Jean,
     
  46. ThibaultD

    ThibaultD

    Joined:
    Jun 7, 2012
    Posts:
    10
    Hi all,

    I've asked the following question to Jean as I work on a similar simulator:

    And his answer, reposted here at his suggestion:

    Thanks again to Jean for his precious help!
     
  47. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    And here is the script in question attached to this post. It's basically a two way look at system, nothing more.

    Any questions or integration problems, let me know.

    Bye,

    Jean
     

    Attached Files:

    Last edited: Jun 7, 2012
  48. OrbitusII

    OrbitusII

    Joined:
    Jul 4, 2011
    Posts:
    175
    Very nice job, I'm just not too big of a fan of how the controls are set up. Maybe take a look into that...
     
  49. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    Hi,

    I made this with the will to make a real simulator of it, so yes, if you are using the keyboard... not a very good experience, I usually demo it with two joysticks, or if on the run, with a dual pad ( the one it is advertised with), and that is a totally different experience all together, because you have smooth controls and you can be very accurate.

    if I would make a game out of it, I would implement an inverse kinematic for the boom and arms so that with only two axis, I would control the bucket position, and with a third axis, the bucket angle, which then would be a lot easier, and more intuitive... but never got around making it...

    bye,

    Jean
     
  50. RohanB

    RohanB

    Joined:
    Jun 19, 2012
    Posts:
    1
    Hi everyone!

    I posted this question to Jean, and he urged me to post it on this thread to allow for an open discussion. So here it goes:

    I have to develop an excavator simulator. The purpose is training of operators.
    a) The input is to be from incoders attached to operator levers
    b) The operator cabin is to be mounted on some (not yet identified) support structure which will take force feedbacks from the visual terrain.

    I am a beginner to Visual Graphics. But I have spent enough time coding to understand a few simple things:

    a) I have to devise some way to allow the CAD models to be imported with its mass properties.
    b) The input from the DAQ will have to be linked to the visual interface for the arm and terrain motions.
    c) The interface should provide the force feedbacks which will be operating the cabin actuators.

    The first phase is to allow for the CAD models to be imported, and operate them with a joystick/keyboard. But I also have to ensure that whatever program I work with, I can integrate my hardware with it later.

    Kindly help me start this project!!