Ragdoll wobbeling
Posted: Mon Sep 30, 2013 4:02 pm
				
				Hi,
I stated playing with ragdolls I set one up based on the actionfiguredemo and unfortunateguydemo but I put the angularmotors of the joints into servo mode to make the limbs controllable by setting a goal, now when the ragdoll tips over and falls onto the ground it starts wobbeling and shaking, the limbs are twisting and turning which can not be right.
how can i prevent such behaviour?
thx Grobi
			I stated playing with ragdolls I set one up based on the actionfiguredemo and unfortunateguydemo but I put the angularmotors of the joints into servo mode to make the limbs controllable by setting a goal, now when the ragdoll tips over and falls onto the ground it starts wobbeling and shaking, the limbs are twisting and turning which can not be right.
Code: Select all
            #region body
	    body = new Box(new Vector3(0, -4.5f, 0), 1.5f, 2, 1, 10);
            space.Add(body);
            #endregion
            
            #region head
            head = new Sphere(body.Position + new Vector3(0, 2, 0), .5f, 5);
            space.Add(head);
            
            //Connect the head to the body.
            space.Add(new BallSocketJoint(body, head, head.Position + new Vector3(0, -.9f, 0)));
            //Angular motors can be used to simulate friction when their goal velocity is 0.
            var angularMotor = new AngularMotor(body, head);
            angularMotor.Settings.MaximumForce = 150; //The maximum force of 'friction' in this joint.
            space.Add(angularMotor);
			#endregion
			
            #region left arm
            //Make the first arm.
            upperArmLeft = new Box(body.Position + new Vector3(-1.6f, .8f, 0), 1, .5f, .5f, 5);
            space.Add(upperArmLeft);
            
            lowerArmLeft = new Box(upperArmLeft.Position + new Vector3(-1.4f, 0, 0), 1, .5f, .5f, 5);
            space.Add(lowerArmLeft);
            //Connect the body to the upper arm.
            space.Add(new BallSocketJoint(body, upperArmLeft, upperArmLeft.Position + new Vector3(.7f, 0, 0)));
            space.Add(new EllipseSwingLimit(body, upperArmLeft, Vector3.Up, MathHelper.PiOver2, MathHelper.PiOver4 * 3));
 			var twistLimit = new TwistLimit(body, upperArmLeft, Vector3.Up, Vector3.Up, -MathHelper.PiOver4 / 2, MathHelper.PiOver4);
			twistLimit.SpringSettings.StiffnessConstant = 100;
			twistLimit.SpringSettings.DampingConstant = 100;
			space.Add(twistLimit);
			
            shoulderLeftMotor = new AngularMotor(body, upperArmLeft);
            shoulderLeftMotor.Settings.MaximumForce = 250;
            shoulderLeftMotor.Settings.Mode = MotorMode.Servomechanism;
            space.Add(shoulderLeftMotor);
            BEPUphysics.CollisionRuleManagement.CollisionRules.AddRule(body, upperArmLeft, BEPUphysics.CollisionRuleManagement.CollisionRule.NoBroadPhase);
            
            //Connect the upper arm to the lower arm.
            //space.Add(new BallSocketJoint(upperArmLeft, lowerArmLeft, upperArmLeft.Position + new Vector3(-.7f, 0, 0)));
            var elbow = new SwivelHingeJoint(upperArmLeft, lowerArmLeft, upperArmLeft.Position + new Vector3(-.7f, 0, 0), Vector3.ForwardRH);
			//Forearm can twist a little.
			elbow.TwistLimit.IsActive = true;
			elbow.TwistLimit.MinimumAngle = -MathHelper.PiOver4 / 2;
			elbow.TwistLimit.MaximumAngle = MathHelper.PiOver4 / 2;
			elbow.TwistLimit.SpringSettings.DampingConstant = 100;
			elbow.TwistLimit.SpringSettings.StiffnessConstant = 100;
			//The elbow is like a hinge, but it can't hyperflex.
			elbow.HingeLimit.IsActive = true;
			elbow.HingeLimit.MinimumAngle = 0;
			elbow.HingeLimit.MaximumAngle = MathHelper.Pi * .7f;
			space.Add(elbow);
            
            elbowLeftMotor = new AngularMotor(upperArmLeft, lowerArmLeft);
            elbowLeftMotor.Settings.MaximumForce = 150;
            elbowLeftMotor.Settings.Mode = MotorMode.Servomechanism;
            space.Add(elbowLeftMotor);
            BEPUphysics.CollisionRuleManagement.CollisionRules.AddRule(upperArmLeft, lowerArmLeft, BEPUphysics.CollisionRuleManagement.CollisionRule.NoBroadPhase);
			#endregion
			
			#region right arm
            //Make the second arm.
            upperArmRight = new Box(body.Position + new Vector3(1.6f, .8f, 0), 1, .5f, .5f, 5);
            space.Add(upperArmRight);
            lowerArmRight = new Box(upperArmRight.Position + new Vector3(1.4f, 0, 0), 1, .5f, .5f, 5);
            space.Add(lowerArmRight);
            //Connect the body to the upper arm.
            space.Add(new BallSocketJoint(body, upperArmRight, upperArmRight.Position + new Vector3(-.7f, 0, 0)));
            space.Add(new EllipseSwingLimit(body, upperArmRight, Vector3.Up, MathHelper.PiOver2, MathHelper.PiOver4 * 3));
 			var twistLimit = new TwistLimit(body, upperArmRight, Vector3.Up, Vector3.Up, -MathHelper.PiOver4 / 2, MathHelper.PiOver4);
			twistLimit.SpringSettings.StiffnessConstant = 100;
			twistLimit.SpringSettings.DampingConstant = 100;
			space.Add(twistLimit);
            //Angular motors can be used to simulate friction when their goal velocity is 0.
            shoulderRightMotor = new AngularMotor(body, upperArmRight);
            shoulderRightMotor.Settings.MaximumForce = 250; //The maximum force of 'friction' in this joint.
            shoulderRightMotor.Settings.Mode = MotorMode.Servomechanism;
            space.Add(shoulderRightMotor);
			BEPUphysics.CollisionRuleManagement.CollisionRules.AddRule(body, upperArmRight, BEPUphysics.CollisionRuleManagement.CollisionRule.NoBroadPhase);
			
            //Connect the upper arm to the lower arm.
            //space.Add(new BallSocketJoint(upperArmRight, lowerArmRight, upperArmRight.Position + new Vector3(.7f, 0, 0)));
            var elbow = new SwivelHingeJoint(upperArmRight, lowerArmRight, upperArmRight.Position + new Vector3(.7f, 0, 0), Vector3.ForwardRH);
			//Forearm can twist a little.
			elbow.TwistLimit.IsActive = true;
			elbow.TwistLimit.MinimumAngle = -MathHelper.PiOver4 / 2;
			elbow.TwistLimit.MaximumAngle = MathHelper.PiOver4 / 2;
			elbow.TwistLimit.SpringSettings.DampingConstant = 100;
			elbow.TwistLimit.SpringSettings.StiffnessConstant = 100;
			//The elbow is like a hinge, but it can't hyperflex.
			elbow.HingeLimit.IsActive = true;
			elbow.HingeLimit.MinimumAngle = 0;
			elbow.HingeLimit.MaximumAngle = MathHelper.Pi * .7f;
			space.Add(elbow);
            
            elbowRightMotor = new AngularMotor(upperArmRight, lowerArmRight);
            elbowRightMotor.Settings.MaximumForce = 150;
            elbowRightMotor.Settings.Mode = MotorMode.Servomechanism;
            space.Add(elbowRightMotor);
			BEPUphysics.CollisionRuleManagement.CollisionRules.AddRule(upperArmRight, lowerArmRight, BEPUphysics.CollisionRuleManagement.CollisionRule.NoBroadPhase);            
			#endregion
            
			#region left leg
            //Make the first leg.
            upperLegLeft = new Box(body.Position + new Vector3(-.6f, -2.1f, 0), .5f, 1.3f, .5f, 8);
            space.Add(upperLegLeft);
            lowerLegLeft = new Box(upperLegLeft.Position + new Vector3(0, -1.7f, 0), .5f, 1.3f, .5f, 8);
            space.Add(lowerLegLeft);
            //Connect the body to the upper leg.
            space.Add(new BallSocketJoint(body, upperLegLeft, upperLegLeft.Position + new Vector3(0, .9f, 0)));
            //Angular motors can be used to simulate friction when their goal velocity is 0.
            hipLeftMotor = new AngularMotor(body, upperLegLeft);
            hipLeftMotor.Settings.MaximumForce = 350; //The maximum force of 'friction' in this joint.
            hipLeftMotor.Settings.Mode = MotorMode.Servomechanism;
            space.Add(hipLeftMotor);
            BEPUphysics.CollisionRuleManagement.CollisionRules.AddRule(body, upperLegLeft, BEPUphysics.CollisionRuleManagement.CollisionRule.NoBroadPhase);
            
            //Connect the upper leg to the lower leg.
            space.Add(new BallSocketJoint(upperLegLeft, lowerLegLeft, upperLegLeft.Position + new Vector3(0, -.9f, 0)));
            kneeLeftMotor = new AngularMotor(upperLegLeft, lowerLegLeft);
            kneeLeftMotor.Settings.MaximumForce = 250;
            kneeLeftMotor.Settings.Mode = MotorMode.Servomechanism;
            space.Add(kneeLeftMotor);
            BEPUphysics.CollisionRuleManagement.CollisionRules.AddRule(upperLegLeft, lowerLegLeft, BEPUphysics.CollisionRuleManagement.CollisionRule.NoBroadPhase);
			#endregion
			
			#region right leg
            //Make the second leg.
            upperLegRight = new Box(body.Position + new Vector3(.6f, -2.1f, 0), .5f, 1.3f, .5f, 8);
            space.Add(upperLegRight);
            lowerLegRight = new Box(upperLegRight.Position + new Vector3(0, -1.7f, 0), .5f, 1.3f, .5f, 8);
            space.Add(lowerLegRight);
            //Connect the body to the upper leg.
            space.Add(new BallSocketJoint(body, upperLegRight, upperLegRight.Position + new Vector3(0, .9f, 0)));
            //Angular motors can be used to simulate friction when their goal velocity is 0.
            hipRightMotor = new AngularMotor(body, upperLegRight);
            hipRightMotor.Settings.MaximumForce = 350; //The maximum force of 'friction' in this joint.
            hipRightMotor.Settings.Mode = MotorMode.Servomechanism;
            space.Add(hipRightMotor);
			BEPUphysics.CollisionRuleManagement.CollisionRules.AddRule(body, upperLegRight, BEPUphysics.CollisionRuleManagement.CollisionRule.NoBroadPhase);
			
            //Connect the upper leg to the lower leg.
            space.Add(new BallSocketJoint(upperLegRight, lowerLegRight, upperLegRight.Position + new Vector3(0, -.9f, 0)));
            kneeRightMotor = new AngularMotor(upperLegRight, lowerLegRight);
            kneeRightMotor.Settings.MaximumForce = 250;
            kneeRightMotor.Settings.Mode = MotorMode.Servomechanism;
            space.Add(kneeRightMotor);
            BEPUphysics.CollisionRuleManagement.CollisionRules.AddRule(upperLegRight, lowerLegRight, BEPUphysics.CollisionRuleManagement.CollisionRule.NoBroadPhase);
            #endregion
thx Grobi