Skip to content

Gear simulation #687

@hazidh

Description

@hazidh

Hello, I have a problem. When I was simulating gears, I defined the two gear models and the PxArticulationLink of the gear shaft as eREVOLUTE type. When I connected the two PXArticulationLinks using PxGearJoint, When I drive one gear to turn but the other gear does not follow.

20251014_100729.mp4
PxArticulationLink inputGearlink = inputArticulationControl.createLink(inputShaftlink,
                inputGear.getWorldTransform(), inputGear, gMaterial, 1, null, true, true);
driveJoint = inputGearlink.getInboundJoint();
driveJoint.setJointType(PxArticulationJointTypeEnum.eREVOLUTE);
parentPose = PhysxMathUtil.getRelativeTransform(inputGear, inputShaft);
childPose = PhysxMathUtil.getRelativeTransform(inputGear, inputGear);
inputArticulationControl.setJointParentAndChildPose(driveJoint, parentPose, childPose);
driveJoint.setMotion(PxArticulationAxisEnum.eSWING2, PxArticulationMotionEnum.eFREE);
PxArticulationDrive drive = new PxArticulationDrive();
drive.setStiffness(1000f);      
drive.setDamping(10f);         
drive.setMaxForce(100000.0f);   
drive.setDriveType(PxArticulationDriveTypeEnum.eVELOCITY);
driveJoint.setDriveParams(PxArticulationAxisEnum.eSWING2, drive);

PxArticulationLink middle1Gearlink = middle1ArticulationControl.createLink(middle1Shaftlink,
                outputGear.getWorldTransform(), outputGear, gMaterial, 1, null, true, true);
joint = middle1Gearlink.getInboundJoint();
joint.setJointType(PxArticulationJointTypeEnum.eREVOLUTE);
parentPose = PhysxMathUtil.getRelativeTransform(outputGear, speedShaft);
childPose = PhysxMathUtil.getRelativeTransform(outputGear, outputGear);
middle1ArticulationControl.setJointParentAndChildPose(joint, parentPose, childPose);
joint.setMotion(PxArticulationAxisEnum.eSWING2, PxArticulationMotionEnum.eFREE);

parentPose = PhysxMathUtil.getRelativeTransform(outputGear, inputGear);
childPose = PhysxMathUtil.getRelativeTransform(outputGear, outputGear);
PxGearJoint gearJoint1 = PxTopLevelFunctions.GearJointCreate(physxAppState.getPhysics(), inputGearlink,
        PhysxMathUtil.updatePxTransform(parentPose, null),
        middle1Gearlink, PhysxMathUtil.updatePxTransform(childPose, null));
gearJoint1.setHinges(inputGearlink.getInboundJoint(), middle1Gearlink.getInboundJoint());
gearJoint1.setGearRatio(-14f / 45f);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions