bullet collision detection - multi thread

298 views
Skip to first unread message

Nachshon Peled

unread,
Apr 20, 2020, 1:46:45 AM4/20/20
to ProjectChrono
Hi
I'm trying to reach soft real time performance with a vehicle on rigid terrain
It seems like most of the time is being consumed by collision detection in bullet
There is a multi thread dispatcher support on bullet current version
 ?Would it be relevant to use it to enhance performance
Thanks
Nachshon

Radu Serban

unread,
Apr 20, 2020, 2:01:43 AM4/20/20
to projec...@googlegroups.com

Hi Nachshon,

The Bullet collision detection is modified and adapted for use within Chrono, so it's not enough to simply drop it the latest version.  We did try to update to a newer Bullet version a while ago (among others to take advantage of multi threading) but we actually noticed degraded performance, so we put that on the back burner for now.  When time permits, we may revisit that.

Regarding your vehicle simulation, is that a wheeled or a tracked vehicle?  If the former, what tire model do you use?  How is the terrain represented? Is it a mesh?

--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/5bb4b858-5608-46da-a2de-ab756ca42f1b%40googlegroups.com.

Nachshon Peled

unread,
Apr 20, 2020, 2:34:19 AM4/20/20
to ProjectChrono
 
Hi Radu
I tried both M113 and HMMWV with real terrain mesh from obj file with about 30 cm resolution. 
As for bullet it seems that the only reason, not to use mutithread for alien pairs in "btHashedOverlappingPairCache::processAllOverlappingPairs" (80% cpu time)
is some inner design of bullet.

בתאריך יום שני, 20 באפריל 2020 בשעה 09:01:43 UTC+3, מאת Radu Serban:

Hi Nachshon,

The Bullet collision detection is modified and adapted for use within Chrono, so it's not enough to simply drop it the latest version.  We did try to update to a newer Bullet version a while ago (among others to take advantage of multi threading) but we actually noticed degraded performance, so we put that on the back burner for now.  When time permits, we may revisit that.

Regarding your vehicle simulation, is that a wheeled or a tracked vehicle?  If the former, what tire model do you use?  How is the terrain represented? Is it a mesh?

--Radu


On 4/20/2020 7:46 AM, nachsh...@gmail.com wrote:
Hi
I'm trying to reach soft real time performance with a vehicle on rigid terrain
It seems like most of the time is being consumed by collision detection in bullet
There is a multi thread dispatcher support on bullet current version
 ?Would it be relevant to use it to enhance performance
Thanks
Nachshon
--
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.

Radu Serban

unread,
Apr 20, 2020, 3:12:16 AM4/20/20
to projec...@googlegroups.com

Hi Nachshon,

Indeed, that issue will hopefully be addressed if/when we embed a newer version of the Bullet collision detection (or roll out our own collision detection system).

For the tracked vehicle, there's not much that can be done -- the vehicle-terrain interaction is always based on rigid body contact (in addition to the other contacts internal to the track assembly).
For wheeled vehicle, I am guessing you use rigid tires, correct?  One thing to try is a different tire model (TMeasy, Fiala, Pac89, or Pac02).  These not only will give you more appropriate tire behavior, but they also do not use the Bullet collision detection.  Instead, these tire models use a custom collision detection that only queries the terrain for height and normal information below a given point.  This falls back on ray casting in the terrain collision model (also done with Bullet).  For best performance, also make sure to set the tire collision detection mode to "SINGLE_POINT" (which is in fact the default).

--Radu

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/8c9c31cd-311c-4fb0-adb0-461f9518dd23%40googlegroups.com.

Nachshon Peled

unread,
Apr 20, 2020, 4:14:22 AM4/20/20
to ProjectChrono
Thanks
Im using the TMeasy
It's based on the demo_VEH_HMMWV example

בתאריך יום שני, 20 באפריל 2020 בשעה 10:12:16 UTC+3, מאת Radu Serban:

Hi Nachshon,

Indeed, that issue will hopefully be addressed if/when we embed a newer version of the Bullet collision detection (or roll out our own collision detection system).

For the tracked vehicle, there's not much that can be done -- the vehicle-terrain interaction is always based on rigid body contact (in addition to the other contacts internal to the track assembly).
For wheeled vehicle, I am guessing you use rigid tires, correct?  One thing to try is a different tire model (TMeasy, Fiala, Pac89, or Pac02).  These not only will give you more appropriate tire behavior, but they also do not use the Bullet collision detection.  Instead, these tire models use a custom collision detection that only queries the terrain for height and normal information below a given point.  This falls back on ray casting in the terrain collision model (also done with Bullet).  For best performance, also make sure to set the tire collision detection mode to "SINGLE_POINT" (which is in fact the default).

--Radu


Nachshon Peled

unread,
Apr 23, 2020, 3:39:46 AM4/23/20
to ProjectChrono
would it be possible to create collision system for each wheel and run with separate threads ?

בתאריך יום שני, 20 באפריל 2020 בשעה 11:14:22 UTC+3, מאת Nachshon Peled:

Radu Serban

unread,
Apr 23, 2020, 5:13:50 AM4/23/20
to projec...@googlegroups.com

Nachshon,

That is not really possible.  A collision system is associated with a Chrono ChSystem. 

What I don't understand however is why a simulation of a wheeled vehicle with TMeasy tires would have a bottleneck in the bullet collision detection.   As I mentioned before, the tire-terrain interaction in that case does not use the underlying collision system.  Does your simulation include anything else besides the vehicle?

Radu

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/c9788e07-1171-46d3-ad4c-4df7ac5254e9%40googlegroups.com.

Nachshon Peled

unread,
Apr 23, 2020, 6:34:32 AM4/23/20
to ProjectChrono
The terrain built from 4 tiles each in obj file added with addpatch. 
I can see now that using only one tile is much faster. 

בתאריך יום חמישי, 23 באפריל 2020 בשעה 12:13:50 UTC+3, מאת Radu Serban:

Nachshon,

That is not really possible.  A collision system is associated with a Chrono ChSystem. 

What I don't understand however is why a simulation of a wheeled vehicle with TMeasy tires would have a bottleneck in the bullet collision detection.   As I mentioned before, the tire-terrain interaction in that case does not use the underlying collision system.  Does your simulation include anything else besides the vehicle?

Radu

Radu Serban

unread,
Apr 23, 2020, 7:18:12 AM4/23/20
to projec...@googlegroups.com

Ok, now I understand what's happening.  

There is an optimization for RigidTerrain with multiple patches that I have to do but didn't get to yet (and which was only made possible by some recent refactoring I did in Chrono related to collision shapes and contact materials). 
Until I get a chance to put that in, you have 2 options:

  1. use a single patch (if that is easy and straightforward for your particular setup)

  2. use multiple patches, but ensure that collision detection is disabled between all patch collision shapes.  You can do this by adding the following two lines after you set up each patch:
         patch->GetGroundBody()->GetCollisionModel()->SetFamily(7);
         patch->GetGroundBody()->GetCollisionModel()->SetFamilyMaskNoCollisionWithFamily(7);
    Here I picked family 7 arbitrarily. But beware that some collision family values are already "reserved" for Chrono::Vehicle simulation.  Any value above 5 is fine.  Just make sure you use the same one for all terrain patches.

    In other words, your RigidTerrain setup code should be something like:
      
      RigidTerrain terrain(my_sys);
      int terrain_coll_family = 7;

      auto patch1 = terrain.AddPatch(patch1_mat, ...);

      ...
      patch1->GetGroundBody()->GetCollisionModel()->SetFamily(terrain_coll_family);
      patch1->GetGroundBody()->GetCollisionModel()->SetFamilyMaskNoCollisionWithFamily(terrain_coll_family);

      auto patch2 = terrain.AddPatch(patch2_mat, ...);
      ...
      patch2->GetGroundBody()->GetCollisionModel()->SetFamily(terrain_coll_family);
      patch2->GetGroundBody()->GetCollisionModel()->SetFamilyMaskNoCollisionWithFamily(
    terrain_coll_family);

      auto patch3 = terrain.AddPatch(patch3_mat, ...);
      ...
      patch3->GetGroundBody()->GetCollisionModel()->SetFamily(
    terrain_coll_family);
      patch3->GetGroundBody()->GetCollisionModel()->SetFamilyMaskNoCollisionWithFamily(
    terrain_coll_family);

Please let me know if this resolves your issue.   I'll post here once I implement the optimization I mentioned.

--Radu

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/bb6717f8-9857-4c71-9153-626dd279bd4a%40googlegroups.com.

Nachshon Peled

unread,
Apr 23, 2020, 8:30:53 AM4/23/20
to ProjectChrono
Thanks
It's working  fine now

בתאריך יום חמישי, 23 באפריל 2020 בשעה 14:18:12 UTC+3, מאת Radu Serban:
Reply all
Reply to author
Forward
0 new messages