Correct COM positioning using Compound and Constraint

Post Reply
Dr. DOX
Posts: 14
Joined: Sun Jul 10, 2016 11:51 am

Correct COM positioning using Compound and Constraint

Post by Dr. DOX »

Hi, sorry for noob question but trying some tests, I see a thing that I do not understand.

If I run next code, the result is obvious and correct: looking for constraint / axis position, they are in the centroid. Image 1.

Code: Select all

        
btCollisionShape* link1 = new btBoxShape(btVector3(5,5,10));
        btCompoundShape* link1comp = new btCompoundShape();
        btVector3 l_com_phy1 = btVector3(0,0,0);
        btTransform l_com_trf_phy1;
        l_com_trf_phy1.setIdentity();
        l_com_trf_phy1.setOrigin(l_com_phy1);  
        link1comp->addChildShape(l_com_trf_phy1, link1);

        btVector3 pivotG1(0,0,0.0);
        btVector3 axisG1(1,0,0);

        btScalar mass1 = 5;
        btVector3 localInertia1;
        link1comp->calculateLocalInertia(mass1,localInertia1);

        btRigidBody::btRigidBodyConstructionInfo ci1(mass1,0,link1comp,localInertia1);
        ci1.m_startWorldTransform.setOrigin(btVector3(15,10,10));
        ci1.m_angularDamping = 0;
        ci1.m_linearDamping = 0;
        
        btRigidBody* body1 = new btRigidBody(ci1);
        body1->setActivationState(DISABLE_DEACTIVATION);
        m_dynamicsWorld->addRigidBody(body1);
        
        btHingeConstraint* hingeT1 = new btHingeConstraint(*body1,pivotG1,axisG1);
        //hingeT1->setLimit(0,0);
        m_dynamicsWorld->addConstraint(hingeT1,true); //0
Now, I change previous btCompoundShape origin (this corresponds to change the COM) :

Code: Select all

 btVector3 l_com_phy1 btVector3 = (0,0,5); [/ code]

Because the cuboid is 10 unit length, I aspect the axis on the outer face (because I suppose that the offset is relative to the cuboid origin). Instead, they are at half position. Image 2.

Setting the overall "length" as COM offset, we have the axis on the outer face (Image 3), but I'm aspect they are "outer" the shape.

[Code] = btVector3 l_com_phy1 btVector3 (0,0,10); [/ code]

Seems like when The btCompoundShape origin is different to (0,0,0), the COM movement is relative to a "base face" and not from centroid. This is correct?

Many thanks, bye
Attachments
3.png
3.png (57.53 KiB) Viewed 3103 times
2.png
2.png (52.86 KiB) Viewed 3103 times
1.png
1.png (70.62 KiB) Viewed 3103 times
Post Reply