Page 1 of 1

MultiBody and RigidBody: architectural design of an application

Posted: Wed Mar 13, 2019 11:23 am
by Dox
Hello,

This is a general question in order to approach the development of an application using MultiBody and/or RigidBody.

Think to a vehicle and some different articulated actuators (excavator, shovel, etc...). I would like be able to model the vehicle physic and then add the actuators to this one, dynamically (at run-time) . I can think to these approaches:

1. Vehicle is a RigidBody and actuators are a chain of RigidBody (using constraints): I can attach the actuators to the vehicle at run-time using constraints. This works, but the constraints chain can be too long and we can have (in some cases, surely we have) solver convergence problem. So, we need another approach.

2. Vehicle is a MultiBody and actuators are MultiBody: can I atttach a MultiBody actuator base to the MultiBody vehicle base? If I think the overall system as a SINGLE MultiBody, ok, I can do that: only one base and a monolitic representation of vehicle and a single actuator. But what happens if I need modularity? I would like be able to load a kind of MultiBody actuator with its own "simulation" and then attach this one to the vehicle at run-time (so, I can exchange actuators dynamically). Can I "convert" the actuator base in a vehicle link and then rebuild the MultiBody?

3. Vehicle is a RigidBody and actuators are MultiBody: it would be a dream if I could to mix RigidBody and MultiBody, but I think this is not possible because they are two different physic representations. I'm right?

4. Vehicle is a MultiBody and actuators are a chain of RigidBody: useless solution, same problems as 1+3.

Can you enlighten me with some considerations to these points?

Best Regards,

Dario

Re: MultiBody and RigidBody: architectural design of an application

Posted: Fri Mar 15, 2019 4:18 am
by Erwin Coumans
You can attach btMultiBody and btMultiBody/btRigidBody using constraints. I would recommend checking out PyBullet to create a prototype, it uses btMultiBody by default under the hood. When using 'useMaximalCoordinates=True' it uses btRigidBody.

Re: MultiBody and RigidBody: architectural design of an application

Posted: Fri Mar 15, 2019 10:29 am
by Dox
Hello Erwin,

Can you tell me some more details about constraint between btMultiBody and btRigidBody?

For example, assuming I have (in true, I already have :D) a btRigidBody and a btMultiBody, can I use a 6dofconstraint to attach them? A typedConstraint take 2 btRigidBody as parameter. In case of btMultiBody I have the btMultiBodyLinkCollider of my base but I can't do an upcast to a btRigidBody because is an incomplete object. Do I need to "rebuild" a complete btRigidBody from the btMultiBodyCollider base? Which is the correct way?

Best regards,

Bye

Re: MultiBody and RigidBody: architectural design of an application

Posted: Fri Mar 15, 2019 5:47 pm
by Dox
Hello,

ok, I found some MultiBodyConstraint (Fixed and Slider) that allow to use the btRigidBody as parameter. I tried a FixedMultiBodyConstraint and I can see 2 problems. One lead to a question that I wanted to do sometime ago.

I would like to focus on this. I often need to connect a btRigidBody A to a btRigidBody B (with a constraint). Normally, I need to set the btRigidBody B as static (mass 0) and setup the correct mass after the attach is done. If I don't do that, the btRigidBody B apply a huge force on A (because constraint), moving A in an uncontrollable manner.

In the case posted (btMultiBody attached to a btRigidBody), I do the same thing (mass = 0 for the btRigidBody) and then I attach the btMultiBody. In this case I have this segmentation fault.

Is there a correct way to do this kind of operation (avoiding the mass = 0)?

Code: Select all

0x00007ffff6912f51 in btMultiBodyConstraint::fillMultiBodyConstraint(btMultiBodySolverConstraint&, btMultiBodyJacobianData&, double*, double*, btVector3 const&, btVector3 const&, btVector3 const&, btVector3 const&, double, btContactSolverInfo const&, double, double, bool, double, bool, double, double) ()
   from /usr/local/lib/libBulletDynamics.so.2.88
(gdb) bt
#0  0x00007ffff6912f51 in btMultiBodyConstraint::fillMultiBodyConstraint(btMultiBodySolverConstraint&, btMultiBodyJacobianData&, double*, double*, btVector3 const&, btVector3 const&, btVector3 const&, btVector3 const&, double, btContactSolverInfo const&, double, double, bool, double, bool, double, double) ()
   from /usr/local/lib/libBulletDynamics.so.2.88
#1  0x00007ffff692a242 in btMultiBodyFixedConstraint::createConstraintRows(btAlignedObjectArray<btMultiBodySolverConstraint>&, btMultiBodyJacobianData&, btContactSolverInfo const&) () from /usr/local/lib/libBulletDynamics.so.2.88
#2  0x00007ffff691a61d in btMultiBodyConstraintSolver::convertContacts(btPersistentManifold**, int, btContactSolverInfo const&) ()
   from /usr/local/lib/libBulletDynamics.so.2.88
#3  0x00007ffff68c93e6 in btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup(btCollisionObject**, int, btPersistentManifold**, int, btTypedConstraint**, int, btContactSolverInfo const&, btIDebugDraw*) () from /usr/local/lib/libBulletDynamics.so.2.88
#4  0x00007ffff6932cd6 in btMultiBodyMLCPConstraintSolver::solveGroupCacheFriendlySetup(btCollisionObject**, int, btPersistentManifold**, int, btTypedConstraint**, int, btContactSolverInfo const&, btIDebugDraw*) () from /usr/local/lib/libBulletDynamics.so.2.88
#5  0x00007ffff68c2579 in btSequentialImpulseConstraintSolver::solveGroup(btCollisionObject**, int, btPersistentManifold**, int, btTypedConstraint**, int, btContactSolverInfo const&, btIDebugDraw*, btDispatcher*) () from /usr/local/lib/libBulletDynamics.so.2.88
#6  0x00007ffff691b680 in btMultiBodyConstraintSolver::solveMultiBodyGroup(btCollisionObject**, int, btPersistentManifold**, int, btTypedConstraint**, int, btMultiBodyConstraint**, int, btContactSolverInfo const&, btIDebugDraw*, btDispatcher*) () from /usr/local/lib/libBulletDynamics.so.2.88
#7  0x00007ffff692858e in MultiBodyInplaceSolverIslandCallback::processIsland(btCollisionObject**, int, btPersistentManifold**, int, int) ()
   from /usr/local/lib/libBulletDynamics.so.2.88
#8  0x00007ffff65e66c8 in btSimulationIslandManager::buildAndProcessIslands(btDispatcher*, btCollisionWorld*, btSimulationIslandManager::IslandCallback*) ()
   from /usr/local/lib/libBulletCollision.so.2.88
#9  0x00007ffff691e62b in btMultiBodyDynamicsWorld::solveConstraints(btContactSolverInfo&) () from /usr/local/lib/libBulletDynamics.so.2.88
#10 0x00007ffff68e93b5 in btDiscreteDynamicsWorld::internalSingleStepSimulation(double) () from /usr/local/lib/libBulletDynamics.so.2.88
#11 0x00007ffff68ea146 in btDiscreteDynamicsWorld::stepSimulation(double, int, double) () from /usr/local/lib/libBulletDynamics.so.2.88

Re: MultiBody and RigidBody: architectural design of an application

Posted: Tue Mar 19, 2019 2:19 am
by steven
Dox wrote: Fri Mar 15, 2019 5:47 pm
I would like to focus on this. I often need to connect a btRigidBody A to a btRigidBody B (with a constraint). Normally, I need to set the btRigidBody B as static (mass 0) and setup the correct mass after the attach is done. If I don't do that, the btRigidBody B apply a huge force on A (because constraint), moving A in an uncontrollable manner.
Could you provide some code snippet of how do you implement this? it seems that you create the constraint dynamically.