# D6Joint setLimit Problem

Hello, I am using D6 joint and assign it to limits on the movement of the Z-axis, the problem lies in the fact that the limits have the same value in both directions, but different signs, as you can give different values for limits?

PxPrismaticJoint limit setLimit PxJointLinearLimitPair which just has a upper limit and lower limit, but it is not suitable, as there is no limit on the Z axis.

Could you explain what you are trying to achieve? I’m afraid I don’t understand your problem.

Cheers,

Gordon

I am creating a suspension for the car, and I need to restrict wheel travel up and down the different values (eg down limit -10.0, up Limit 25.0)

PxPrismaticJoint limit setLimit PxJointLinearLimitPair which just has a upper limit and lower limit, but it is not suitable, as there is no limit on the Z axis.

Here it is possible to assign the upper and lower limit:

PxReal lowerLimit;
PxReal upperLimit;

``````PxJointLinearLimitPair(const PxTolerancesScale& scale, PxReal lowerLimit, PxReal upperLimit, PxReal contactDist = -1)
: upper(upperLimit)
, lower(lowerLimit)
{
PxJointLimitParameters::contactDistance = contactDist == -1 ? PxMin(scale.length * 0.01f, (upperLimit*0.49f-lowerLimit*0.49f)) : contactDist;
bounceThreshold = 2*scale.length;
}
``````

There is no such possibility:
PxReal extent;

``````PxJointLinearLimit(const PxTolerancesScale& scale, PxReal extent, PxReal contactDist = -1)
: value(extent)
{
PxJointLimitParameters::contactDistance = contactDist == -1 ? 0.01f*scale.length : contactDist;
}
``````

I’m fairly certain you want to use a PxPrismaticJoint to model a suspension. A prismatic joint only allows motion along a single axis so when you set the limits you are setting the limits on that axis. You choose the axis by specifying a local space transform when instantiating the joint. I can’t remember the details but I think that it uses the x-axis as the default axis of motion. You just need to set a local transform that results in motion along your desired axis.

As an example, here is some code that results in a spring constraint along the y-axis.

``````PxRigidDynamic* boxRD = getPhysics().createRigidDynamic(PxTransform(PxVec3(0.0f, 5.0f, 0.0f), PxQuat(PxIdentity)));
PxBoxGeometry boxGeom(2, 1, 5);
PxShape* boxShape = getPhysics().createShape(boxGeom, getDefaultMaterial(), true, PxShapeFlag::eSIMULATION_SHAPE);
boxRD->attachShape(*boxShape);
PxRigidBodyExt::setMassAndUpdateInertia(*boxRD, 1500.0f);

PxQuat q(PxPi*0.5f, PxVec3(0, 0, 1));
PxPrismaticJoint* joint = PxPrismaticJointCreate(getPhysics(), boxRD, PxTransform(PxVec3(0, 0, 0), q), NULL, PxTransform(PxVec3(0, 2, 0), q));
PxJointLinearLimitPair limit(-0.001f, 0.001f, PxSpring(10000.0f, 1000.0f));
joint->setLimit(limit);
joint->setPrismaticJointFlag(PxPrismaticJointFlag::eLIMIT_ENABLED, true);
``````

Note the quaternion q in the above code.

Cheers,

Gordon

How, then, can make the rotation of the wheels?

So I did, and everything was fine except for the upper and lower limit

``````PxD6Joint* PD6Joint = PxD6JointCreate(*GPhysXSDK, Body, PxTransform(PLocalPose.p, Wheels->getGlobalPose().q.createIdentity()), Wheels, PxTransform(PxVec3(0.0)));

PxJointLinearLimit PLinearLimit(GPhysXSDK->getTolerancesScale(), LinLimit, 0.05f * GPhysXSDK->getTolerancesScale().length);

PD6Joint->setMotion(PxD6Axis::eZ, PxD6Motion::eLIMITED);
PD6Joint->setMotion(PxD6Axis::eSWING1, PxD6Motion::eFREE);
PD6Joint->setLinearLimit(PLinearLimit);
``````

Now I have to create two joint and they are not securely connected to each other, and constantly break under vygledit very wrong, is not it possible that there is no way in d6joint specify the upper and lower limit

If you want to make a vehicle with jointed wheels you will need to make a rigid body for each wheel and a rigid body for the chassis of the vehicle. In practice, you might have multiple jointed rigid bodies for the chassis because you might want to have a chassis jointed to doors and other parts such as the lid of the trunk and the bonnet.

Let’s look at the joint between the rigid body and the wheel. In the code I posted, the chassis of the car is jointed to the world. If you add a wheel then you will need to joint the chassis to the wheel instead of the world. You will end up with N joints for N wheels.

Now, how will the wheels rotate? Well, that depends on what you want to achieve. You could try to make them rotate using friction. If you attach a convex shape to the wheel’s rigid body actor and make that convex shape approximate a cylinder, the wheel will naturally start rolling from the friction of the rigid body contact between the wheel and the ground. I don’t think this will be terribly successful, though, because the approximation of a real wheel will be quite poor. In short, the edges of the convex will make it hard to generate the smooth rolling of a perfectly round cylinder. Even if you solve that problem by introducing a lot of expensive vertices to your convex, you still have the problem that rigid body contact is a poor approximation for the complexity of a stretchy tire developing a contact patch with the ground. This probably isn’t the way to go. You will want some sort of tire model that generates forces based on the spring force and the longitudinal and lateral slips of the wheel.

Personally, I’d recommend looking at PhysX Vehicles if you want to simulate a car. I’d be interested to know what features you require that aren’t satisfied by the vehicles component. It already solves a number of problems that you are trying to solve eg suspension limits, rolling forces etc. If there is something missing it would be useful to know so that we could add it for later releases.

Cheers,

Gordon

Thank you for your detailed answer, I create a tank, and the use of the vehicle PhysX not suitable as the wheel does not have a collision, suspension raycast does not suit me, the tank in my project overcomes different obstacles, and should clearly respond to the objects under each wheel. Maybe it is possible around the PhysX vehicle wheels create physical tracks for the tank, then the tracks will be involved in a collision.But I do not know how to do it.
The SDK 2.8 has the ability to use different types of suspension.

Game ARMA 3, it PxDriveTank tanks are built on and not look very natural

Still, I wanted to know how I can assign PxJointLinearLimitPair D6Joint SetLimit that need to be corrected in the source code

As can be assigned dynamically SetLimit D6Djoint?