OneBodyLinearServo does not seem to pull Body all the way to Target

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
abego
Posts: 7
Joined: Fri May 31, 2019 7:57 pm

OneBodyLinearServo does not seem to pull Body all the way to Target

Post by abego »

Hello!

I am trying to get a Ragdoll to stand upright, and to do that I am using a OneBodyLinearServo for the head, chest & hips of the Ragdoll, with each Target set to the desired positions of the bodies above ground. The Servos are affecting the bodies and keeping the upright, but not all the way to the Target posititions.

How I add the Servo:

Code: Select all

SpringSettings defaultSpring = new SpringSettings (5, 0);

force = 250

LinearHandle = simulation.Solver.Add (body, new OneBodyLinearServo ()
            {
                Target = target,
                ServoSettings = new ServoSettings (float.MaxValue, 0, force),
                SpringSettings = defaultSpring
            });
How the ragdoll looks in-game:
Image

The simulation is run server-side, and only the position of the hips and the rotations of all bodyparts are synchronized. The hands and feet are not yet synchronized properly, but that should not influence the position of the hips, as that is sent directly.

I have tried messing around with the maxiumForce of the ServoSettings, but maximumForce only seems to affect the speed at which the Body is pulled to the Target, and not how close it gets. Much of my code is taken from the Grapper class in the demos, and it also seems as if objects are not dragged all the way to the cursor when pulled around in the demos (Which is most likely on purpose, but I am not aiming for that kind of behavior here).

Any help is highly appreciated :D
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: OneBodyLinearServo does not seem to pull Body all the way to Target

Post by Norbo »

For greater stiffness, you'll need to use a higher frequency on the SpringSettings. Try using spring settings of 30hz frequency and a damping ratio of 1. Higher frequencies make the spring more rigid, but be careful about pushing it higher than ~half your timestepping rate. (For example, a time step duration of 1/60 would imply a safe upper bound of 30hz. This isn't a hard upper limit- you can often get away with isolated higher stiffnesses without any issues, but complex articulations with excessive stiffness can be near impossible to solve in a reasonable number of solver iterations.)

The ServoSettings are just additional forms of control on top of the SpringSettings. MaximumForce stops the constraint from applying more than a certain amount of force, but the spring settings might result in forces below that threshold.
abego
Posts: 7
Joined: Fri May 31, 2019 7:57 pm

Re: OneBodyLinearServo does not seem to pull Body all the way to Target

Post by abego »

Thank you :D , that seemed to do the trick. I did try to change the damping ratio before, but that was with the frequency still at 5hz, and that just made the ragdoll behave like crazy. I have also increased my simulation frequency from 60 hz to 120 hz, so I am now using a spring frequency of 60 hz.
Post Reply