Chrono Physics integrated into Unity3D

985 views
Skip to first unread message

Alan Weaver

unread,
Dec 10, 2019, 8:38:49 AM12/10/19
to ProjectChrono
Hi,

I have finally made some progress with the Unity3D integration of Chrono Physics, so far it's only partial, enough to set a chrono demo vehicle up.

What I have done is allow Chrono development to work as drag and drop assets within Unity, so all the suspension sub systems, powertrains, steering systems, brakes etc.  are pre-built visual 3D objects with the chrono scripts attached to them, all that has to be done is they are dragged into the scene, placed, and attach together, like shafts components to wheels, suspension revolute to chassis, or suspension to steering rack etc.  I have ported the RigidTire, Pac89 and TMeasy tire models directly into Unity.

This Demonstration video is basically the HMMWV vehicle demo, it's using shafts driveline and shafts powertrain.  Note, Unity uses like all game studios Y as up, I haven't managed to convert the code to allow for this yet, so everything is on it's side, and finally it's only running at 30fps because it's within unity and running as debug, it's 60fps on Release build.



Radu Serban

unread,
Dec 10, 2019, 9:47:10 AM12/10/19
to projec...@googlegroups.com

Hi Alan,

This is great work! 
Are you considering making this publicly available?

--Radu

--
You received this message because you are subscribed to the Google Groups "ProjectChrono" group.
To unsubscribe from this group and stop receiving emails from it, send an email to projectchron...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/projectchrono/71a19519-b880-4dcd-aed1-15b9cf8c29de%40googlegroups.com.

Alan Weaver

unread,
Dec 10, 2019, 10:02:21 AM12/10/19
to ser...@wisc.edu, 'Radu Serban' via ProjectChrono
Hi Radu,

Thank you, it was a lot of work to get this far.
It would depend on the demand, Unity is a very specific community and I'm not sure if there would be a large demand for it in the simulation world?  I just don't know yet.  Plus as it stands the vehicle side of it wouldn't be well received with the Z being up (ISO)  It's extremely cumbersome to navigate and work with within the Unity Editor, (building scenes and levels etc.) plus the other problems, all Assets and plugins for Unity which are tools written by the community Free and purchase are designed and written for Y being up, so they would be incompatible with Chrono vehicle physics applications.  So unless I can somehow overcome this problem, I doubt I'd take it any further.

Fingers crossed though.
Alan. 

Dan Negrut

unread,
Dec 10, 2019, 10:55:14 AM12/10/19
to Alan Weaver, ProjectChrono

This looks very impressive!!! Great work, Alan.

Dan

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

Mead Witter Foundation Professor

NVIDIA CUDA Fellow

Director, Wisconsin Applied Computing Center

Department of Mechanical Engineering

Department of Computer Science

University of Wisconsin - Madison

4150ME, 1513 University Avenue

Madison, WI 53706-1572

608 772 0914

608 265 2316 (Fax)

http://sbel.wisc.edu/

http://projectchrono.org/

http://homepages.cae.wisc.edu/~negrut

My calendar.

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

--

Alessandro Tasora

unread,
Dec 10, 2019, 4:30:15 PM12/10/19
to projec...@googlegroups.com

Hi Alan,

this is really interesting!

for the Y up issue: I have experience with Unreal API, and I just played with Unity for few hours. If it works like Unreal, my suggestion is that you put all the bodies in a "transformation node" (so you just have to update its rotation matrix, ie. optionally rotates all the contained stuff 90° if you want to switch from Y up to Z up or viceversa, depending on a flag. No need to change hundreds of lines of code to switch Z or Y coords through your code.)

Alessandro

Message has been deleted

Kristijonas Grigorovičius

unread,
Jan 10, 2020, 10:16:30 AM1/10/20
to ProjectChrono
Very interesting work, i am working on this too, are you planning to release it on Github any time soon ?

Alan Weaver

unread,
Jan 10, 2020, 10:22:05 AM1/10/20
to Kristijonas Grigorovičius, 'Dan Negrut' via ProjectChrono
Thank you, how are you integrating Chrono into Unity?  I might do, it's a slow complex process and if it looks promising, as in once I've tested Chrono for Game related projects I'll show case it on the Unity forums.  It needs to pass certain performance tests, stability tests, games are fast paced so Chrono needs to be stable in Unity.

On 10/01/2020 15:16:32, Kristijonas Grigorovičius <kristijonasg...@gmail.com> wrote:

Very interesting work, i am working on this too, are you planning to release it on Github any time soon ?

--
You received this message because you are subscribed to the Google Groups "ProjectChrono" group.
To unsubscribe from this group and stop receiving emails from it, send an email to projectchron...@googlegroups.com.

Kristijonas Grigorovičius

unread,
Jan 10, 2020, 10:36:36 AM1/10/20
to ProjectChrono
i use separate thread with pInvoke (unmanaged c++ dll) to integrate with unity ,but for now it's less than bare bones implementation on my side.


On Friday, January 10, 2020 at 5:22:05 PM UTC+2, Alan Weaver wrote:
Thank you, how are you integrating Chrono into Unity?  I might do, it's a slow complex process and if it looks promising, as in once I've tested Chrono for Game related projects I'll show case it on the Unity forums.  It needs to pass certain performance tests, stability tests, games are fast paced so Chrono needs to be stable in Unity.

On 10/01/2020 15:16:32, Kristijonas Grigorovičius <kristijonasg...@gmail.com> wrote:

Very interesting work, i am working on this too, are you planning to release it on Github any time soon ?

--
You received this message because you are subscribed to the Google Groups "ProjectChrono" group.
To unsubscribe from this group and stop receiving emails from it, send an email to projec...@googlegroups.com.

Alan Weaver

unread,
Jan 10, 2020, 10:50:11 AM1/10/20
to Kristijonas Grigorovičius, 'Dan Negrut' via ProjectChrono
Same as me, I've got quite a bit done so far.  At first I tried to convert the c++ code to c# but there are a few techniques I don't know how to convert, so I will get back to it once I've tested it using the pInvoke technique.  What classes are you pInvoking so far?
To unsubscribe from this group and stop receiving emails from it, send an email to projectchron...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/projectchrono/3373227e-7e31-4a62-b447-a90990694132%40googlegroups.com.

David Lario

unread,
Jan 16, 2020, 2:57:31 PM1/16/20
to ProjectChrono
This application looks amazing!  I been hoping this could work as i been learning both these programs. The visualization and variable control is exactly what this project chrono needs.  I spent a pile of time trying to get the python version working closer to what unity does but this blows my work out of the water.  Anxiously waiting for something to see what you do next.

Alan Weaver

unread,
Jan 17, 2020, 6:14:41 AM1/17/20
to David Lario, 'Radu Serban' via ProjectChrono
Thank you, I really appreciate it.  It makes the hard work worth it.  I will post a quick video today of it running on a build, but the vehicles aren't stable yet in SystemSMC, the suspension components shake and fall apart on tight corners, and also the vehicle flips when the friction is increased for higher speeds.  But getting there, hopefully these problems can be ironed out, oh and also I need to convert the code so that it's not ISO frame, Y needs to be up, this would not be accepted in the Unity community.

On 16/01/2020 19:57:33, David Lario <larioe...@gmail.com> wrote:

This application looks amazing!  I been hoping this could work as i been learning both these programs. The visualization and variable control is exactly what this project chrono needs.  I spent a pile of time trying to get the python version working closer to what unity does but this blows my work out of the water.  Anxiously waiting for something to see what you do next.

--
You received this message because you are subscribed to the Google Groups "ProjectChrono" group.
To unsubscribe from this group and stop receiving emails from it, send an email to projectchron...@googlegroups.com.

Alan Weaver

unread,
Jan 17, 2020, 12:37:01 PM1/17/20
to David Lario, 'Radu Serban' via ProjectChrono
Hi, 

Okay here is the latest video, this is using ChSystemNSC for stability, as you can see the ground friction still isn't set high enough and the vehicle still spins over, so I'm not sure what's wrong there, maybe Fiala tire tweeking is needed.

Alan

Dan Negrut

unread,
Jan 18, 2020, 11:50:51 AM1/18/20
to ProjectChrono

Really nice work, Alan!!!

Dan

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

Mead Witter Foundation Professor

NVIDIA CUDA Fellow

Co-Director, Wisconsin Applied Computing Center

Department of Mechanical Engineering

Department of Computer Science

University of Wisconsin - Madison

4150ME, 1513 University Avenue

Madison, WI 53706-1572

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

 

From: projec...@googlegroups.com <projec...@googlegroups.com> On Behalf Of Alan Weaver

Reply all
Reply to author
Forward
0 new messages