[SOLVED] issue with dCustomBallAndSocket limits

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

[SOLVED] issue with dCustomBallAndSocket limits

Postby blackbird_dream » Fri Nov 20, 2020 9:38 am

I'd like to use limits on a dCustomBallAndSocket Joint.
Here I limited the twist angle only. It's difficult to see but it works . The twist angle (vertical axis) is bounded between -30° and +30° as desired and the other angles are free:

Here I also limited the cone angle to 30°:

But it behaves like the cone angle were limited to 0°. I mean, only the twist dof is free.

my code :
Code: Select all
   Low_Leg_L = new GeomNewton(m_winManager->aManager);
   Low_Leg_L->SetBodyType(adtKinematic);
   Low_Leg_L->SetTexture0(&tex[0], "Tex0");
   Low_Leg_L->SetDiffuseColor(0.7f, 0.7f, 0.7f);
   Low_Leg_L->SetRollAngle(90.0f ,false);
   Low_Leg_L->SetPosition(_Pos.x, _Pos.y, _Pos.z);
   Low_Leg_L->InitNewton(atCapsule, Scale*r_bones, Scale*r_bones, Scale* l_Low_Leg, 10.0f*Scale);
   m_body = Low_Leg_L->GetBody();
   NewtonBodySetTransformCallback(m_body, NULL);
   NewtonBody* const parentBody = GetBody();
   dMatrix aParenMatrix(dGetIdentityMatrix());
   NewtonBodyGetMatrix(parentBody, &aParenMatrix[0][0]);


   Plantar_L = new GeomNewton(m_winManager->aManager);
   Plantar_L->SetBodyType(adtDynamic);
   Plantar_L->SetParent(Low_Leg_L);
   Plantar_L->SetTexture0(&tex[0], "Tex0");
   Plantar_L->SetDiffuseColor(1.0f, 1.0f, 1.0f);
   Plantar_L->SetPitchAngle(90.0f, false);
   Plantar_L->SetPosition (0,-Scale * (l_Low_Leg) / 2 - 2* Scale* r_bones, -Scale * (l_foot / 4));
   Plantar_L->InitNewton(atBox, Scale*  0.1f, Scale*  l_foot, Scale* w_foot, 10.0f * Scale);
   NewtonBodySetTransformCallback(Plantar_L->GetBody(), NULL);
   Plantar_LNode = new dModelNode(Plantar_L->GetBody(), dGetIdentityMatrix(), this);



   dMatrix Ankle_LPinMatrix(dGetIdentityMatrix()); //flexion twist
   Ankle_LPinMatrix = Ankle_LPinMatrix * dRollMatrix(90.0f * dDegreeToRad);//torsion twist
   Ankle_LPinMatrix.m_posit = dVector(Low_Leg_L->GetPosition().m_x, Low_Leg_L->GetPosition().m_y - Scale * l_Low_Leg / 2- Scale*r_bones, Low_Leg_L->GetPosition().m_z);
   Ankle_L = new dCustomBallAndSocket(Ankle_LPinMatrix,  Plantar_L->GetBody(),Low_Leg_L->GetBody());
   Ankle_L->EnableTwist(true);
   Ankle_L->SetTwistLimits(-30.f * dDegreeToRad,30.f * dDegreeToRad);
   Ankle_L->EnableCone(true);
   Ankle_L->SetConeLimits(30.f * dDegreeToRad );
   m_winManager->aManager->vJointList.push_back(Ankle_L);
Last edited by blackbird_dream on Mon Nov 23, 2020 11:07 am, edited 2 times in total.
User avatar
blackbird_dream
 
Posts: 354
Joined: Wed Jun 07, 2006 3:08 pm
Location: France

Re: issue with dCustomBallAndSocket limits

Postby blackbird_dream » Fri Nov 20, 2020 9:51 am

Here is close to what I expected, setting the stiffness to 0.999:



But it's not very clean as sometimes it gets stuck at mid-flexion and sometimes not.
with lower stiffness values, the pinpoint can move too so the joint is loose, with higher values the cone angles keep frozen.
Last edited by blackbird_dream on Sun Nov 22, 2020 7:37 pm, edited 1 time in total.
User avatar
blackbird_dream
 
Posts: 354
Joined: Wed Jun 07, 2006 3:08 pm
Location: France

Re: issue with dCustomBallAndSocket limits

Postby Julio Jerez » Fri Nov 20, 2020 2:00 pm

are you setting this in the SDK demos sandbox. or is that some other app?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: issue with dCustomBallAndSocket limits

Postby blackbird_dream » Fri Nov 20, 2020 2:42 pm

in my app. It's a Demo Template from Koom.
User avatar
blackbird_dream
 
Posts: 354
Joined: Wed Jun 07, 2006 3:08 pm
Location: France

Re: issue with dCustomBallAndSocket limits

Postby Julio Jerez » Fri Nov 20, 2020 4:14 pm

can you run the demos from the SDK?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: issue with dCustomBallAndSocket limits

Postby blackbird_dream » Fri Nov 20, 2020 4:33 pm

what do you mean ? Yes I can run the sandbox demos. But these are other demos built with the sdk. I don't know if this answers your question :?
I can send you the files if you want.
User avatar
blackbird_dream
 
Posts: 354
Joined: Wed Jun 07, 2006 3:08 pm
Location: France

Re: issue with dCustomBallAndSocket limits

Postby Julio Jerez » Sat Nov 21, 2020 10:37 am

what I mean is that you are are doing is complex. and is hard to work with just pieces of code here and there.
most demos in the demos sand box start by some user trying something they want to do and I make a black demo where stuff can be added and after that is easier to make repro for particular test cases.

I am trying to remedy that by adding xml serialization but that's only for the new version of newton which is not has nay joints yet.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: issue with dCustomBallAndSocket limits

Postby blackbird_dream » Sat Nov 21, 2020 12:30 pm

ok I'll try to make a demo in the sandbox then.
User avatar
blackbird_dream
 
Posts: 354
Joined: Wed Jun 07, 2006 3:08 pm
Location: France

Re: issue with dCustomBallAndSocket limits

Postby Julio Jerez » Sat Nov 21, 2020 2:32 pm

Yes that will be probably the best.
From ther we have a common test bench to try things.

The I can move it to the newton 4 for trying some new ideas I have about the biped locomotion.

This will be my third try at this. I halear few thing over the years that might be of some help.

Any try to set up a test and we can go from there.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: issue with dCustomBallAndSocket limits

Postby blackbird_dream » Sun Nov 22, 2020 11:02 am

Here I duplicated my demo in the sandbox collection.
I modified FlatLandGame demo (2 methods changed only. AttachLimbBody & AddRagdollBodies) to model the 2 bodies connected with eachother by means of a dCustomBallAndSocket with angle limits of 30°. Only the twistlimits are active. The other axes are frozen.
Code: Select all
static void AttachLimbBody (DemoEntityManager* const scene, const dVector& dir, NewtonBody* const parent, float masse)
{
   NewtonWorld* const world = scene->GetNewton();
   dVector size(0.4f, 0.25f, 0.75f, 0.0f);

   NewtonCollision* const collision = CreateConvexCollision(world, dGetIdentityMatrix(), size, _BOX_PRIMITIVE, 0);
   DemoMesh* const geometry = new DemoMesh("box", scene->GetShaderCache(), collision, "smilli.tga", "logo_php.tga", "frowny.tga");

   dMatrix location;
   dVector ppoint;
   NewtonBodyGetMatrix(parent, &location[0][0]);

   location.m_posit += dir.Scale(0.5f);
   location.m_posit.m_y -= 0.5f;

   // make a root body attached to the world
   NewtonBody* const rootBody = CreateSimpleSolid(scene, geometry, masse, location, collision, 0);

   location.m_posit -= dir.Scale(0.5f);
   ppoint = location.m_posit;
   location = dGetIdentityMatrix() * dRollMatrix(90.0f * dDegreeToRad);
   location.m_posit = ppoint;

   dCustomBallAndSocket* const joint = new dCustomBallAndSocket(location, rootBody, parent);
   //hinge->EnableLimits(true);
   joint->EnableTwist(true);
   joint->SetTwistLimits(-30.f * dDegreeToRad, 30.f * dDegreeToRad);
   joint->EnableCone(true);
   joint->SetConeLimits(30.f * dDegreeToRad);


   geometry->Release();
   NewtonDestroyCollision(collision);
}

static void AddRagdollBodies(DemoEntityManager* const scene, NewtonBody* const floor)
{
   NewtonWorld* const world = scene->GetNewton();
   dVector size(0.2f, 1.0f, 0.2f, 0.0f);

   dMatrix location(dGetIdentityMatrix());

   location.m_posit.m_y = 4.0f;

   NewtonCollision* const collision = CreateConvexCollision(world, dGetIdentityMatrix(), size, _BOX_PRIMITIVE, 0);
   DemoMesh* const geometry = new DemoMesh("box", scene->GetShaderCache(), collision, "smilli.tga", "logo_php.tga", "frowny.tga");

   location.m_posit.m_z = 5.0f;
   float rootmass = 0.f;


      NewtonBody* const rootBody = CreateSimpleSolid(scene, geometry, rootmass, location, collision, 0);

      // constrain these object to motion on the plane only
      dMatrix matrix;
      NewtonBodyGetMatrix(rootBody, &matrix[0][0]);
   //   new dCustomPlane(matrix.m_posit, matrix.m_front, rootBody);

      // now make some limb body and attach them to the root body
   //   AttachLimbBody (scene, matrix.m_right.Scale ( 1.0f), rootBody);
      AttachLimbBody(scene, matrix.m_right.Scale(-1.0f), rootBody, 1.f);
   //   AttachLimbBody(scene, matrix.m_right.Scale(-1.0f), rootBody, 0.01f);

      location.m_posit.m_z += 2.5f;
   

   geometry->Release();
   NewtonDestroyCollision(collision);
}


the video capture here:
Last edited by blackbird_dream on Sun Nov 22, 2020 7:38 pm, edited 1 time in total.
User avatar
blackbird_dream
 
Posts: 354
Joined: Wed Jun 07, 2006 3:08 pm
Location: France

Re: issue with dCustomBallAndSocket limits

Postby Julio Jerez » Sun Nov 22, 2020 2:49 pm

ok I added a new demo BlackbirdDreamTest
and pasted the tow method that you added, and cleanup of the other stuff.
I think It play like is the video.
after you get it and see if I what you did, tell me what it is you seek?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: issue with dCustomBallAndSocket limits

Postby blackbird_dream » Sun Nov 22, 2020 3:32 pm

Perfect. That's it. As you can see the horizontal box can rotate along one axis only (the vertical axis) although it should rotate along the 3 axis.
I set the 2 other axis with:

Code: Select all
   joint->EnableCone(true);
   joint->SetConeLimits(30.f * dDegreeToRad);

and it just acts like if the conelimits were 0.
User avatar
blackbird_dream
 
Posts: 354
Joined: Wed Jun 07, 2006 3:08 pm
Location: France

Re: issue with dCustomBallAndSocket limits

Postby Julio Jerez » Mon Nov 23, 2020 10:22 am

oh, I see.
there was bug there, whe the control axis is with is a very small limit the the joint threat the angles as cartesian values, because small angles commute and use Euler decomposition lead to weak joint.
this is the case when teh joint lock some angles.

but there was a bug the the Cartesian cone angles projection were check against the small value but never again the actual cone angle. adding the check fixes the bug.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: issue with dCustomBallAndSocket limits

Postby blackbird_dream » Mon Nov 23, 2020 11:02 am

Excellent. Tks for your prompt reply.
User avatar
blackbird_dream
 
Posts: 354
Joined: Wed Jun 07, 2006 3:08 pm
Location: France


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 49 guests