Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring/damper has no effect in driving articulation joint #202

Closed
mlp1802 opened this issue Jul 6, 2023 · 10 comments
Closed

Spring/damper has no effect in driving articulation joint #202

mlp1802 opened this issue Jul 6, 2023 · 10 comments
Labels
bug Something isn't working

Comments

@mlp1802
Copy link

mlp1802 commented Jul 6, 2023

It seems that no matter what value I use for spring or damper, it has no effect on the simulation. I can set these values to whatever, zero or a billion, it has no effect. I'm trying to drive a joint towards an orientation. The ragdoll is very unstable since there is zero damping, the only parameter that seems to have an effect is max_force. I'm thinking there might be something wrong with the binding for this function "PxArticulationJointReducedCoordinate_setDriveParams_mut(joint, axis, &drive)" or something like that? unless I completely misunderstood something.

pub fn set_articulation_joint_reduced_target(
    joint: PtrArticulationJointReducedCoordinate,
    axis: PxArticulationAxis,
    max_force: f32,
    spring: f32,
    damper: f32,
    target: f32,
) {
    unsafe {
        println!("Spring/damper {} {}", spring, damper);
        let drive = PS::PxArticulationDrive_new_1(
            spring,
            damper,
            max_force,
            PS::PxArticulationDriveType::Target,
        );

        PS::PxArticulationJointReducedCoordinate_setDriveParams_mut(joint, axis, &drive);
        PS::PxArticulationJointReducedCoordinate_setDriveTarget_mut(joint, axis, target, true);
        PS::PxArticulationJointReducedCoordinate_setFrictionCoefficient_mut(joint, 2.0);
    }
}
@mlp1802 mlp1802 added the bug Something isn't working label Jul 6, 2023
@tgolsson
Copy link
Member

tgolsson commented Jul 7, 2023

How is the joint configured?

@mlp1802
Copy link
Author

mlp1802 commented Jul 7, 2023

How is the joint configured?

All Spherical joints, with limits but rather large limits. EDIT..set motion type to FREE

@tgolsson
Copy link
Member

tgolsson commented Jul 7, 2023

Are you setting motion type per axis?

@mlp1802
Copy link
Author

mlp1802 commented Jul 7, 2023

Yes like this:

                    PX::set_articulation_joint_type(
                        joint_ptr as PtrArticulationJointReducedCoordinate,
                        PS::PxArticulationJointType::Spherical,
                    );
                    PX::set_articulation_joint_reduced_motion(
                        joint_ptr as PtrArticulationJointReducedCoordinate,
                        PS::PxArticulationAxis::Swing1,
                        PS::PxArticulationMotion::Free,
                    );
                    PX::set_articulation_joint_reduced_motion(
                        joint_ptr as PtrArticulationJointReducedCoordinate,
                        PS::PxArticulationAxis::Swing2,
                        PS::PxArticulationMotion::Free,
                    );
                    PX::set_articulation_joint_reduced_motion(
                        joint_ptr as PtrArticulationJointReducedCoordinate,
                        PS::PxArticulationAxis::Twist,
                        PS::PxArticulationMotion::Free,
                    );

@tgolsson
Copy link
Member

tgolsson commented Jul 7, 2023

Hmm. I'd narrow it down a bit by using a limited spherical joint, and probably using a Force drive type rather than Target. That'd be a more regular setup I think. This seems like a configuration issue, more so than a binding problem until we can prove the opposite. Articulation joints and drives are a lot less forgiving for configuration errors than their regular variants.

Just to double-check though; @blunzn or @bpaberg -- you've both looked at the articulations recently; did you notice any issues with drives?

@mlp1802
Copy link
Author

mlp1802 commented Jul 7, 2023

I could try to use velocity drive to see if it makes a difference, it should be possible to drive towards an orientation using velocity as well, by setting velocity to zero when target is reached.

@mlp1802
Copy link
Author

mlp1802 commented Jul 7, 2023

I'm not sure why force drive would work better?

@mlp1802
Copy link
Author

mlp1802 commented Jul 7, 2023

Ok once I'm home I'll make a minimal example to try to reproduce it.

@mlp1802
Copy link
Author

mlp1802 commented Jul 10, 2023

My bad, I should've use FORCE joint drive type instead of TARGET.

@mlp1802 mlp1802 closed this as completed Jul 10, 2023
@tgolsson
Copy link
Member

Thanks for the follow-up @mlp1802!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants