Stability problems with suspension

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
RayBatts
Posts: 4
Joined: Mon Nov 08, 2010 7:36 pm

Stability problems with suspension

Post by RayBatts »

I'm looking to implement a fairly different suspension system for a vehicle I'm building. I've done a lot of tweaking and joint/constraint replacement, but can't seem to figure out what's going on here.

The suspension is built as follows: (Blue squares represent the anchor point of the RevoluteJoints)

Image

The suspension arm acts as a lever that raises the cylindrical suspension piece/rig and the wheel up as the car body or wheel touches the ground. Eventually I'd like to add a spring from the body to the suspension rig to push it back up when it's in the air, but I need to figure out this problem first.

When the vehicle hits the ground, it bounces up and down a couple of times (as expected) as the Revolute between the car body and the suspension arm settles. After settling, the vehicle jitters and then eventually flies up into the air. It's obvious that a lot of fighting is going on. Collision is disabled between all parts of the vehicle.

I've taken apart the vehicle and have found what I believe to be the source of the stability...and that's the suspension rig to the revolute joint. When I make the motor active and move it, I see the suspension rig jitter and rotate a little bit, although it already has a NoRotationJoint attached to it. The jittering occurs when the motor starts or stops motion. Increasing its softness stops it, but I believe that if the suspension rig is allowed to rotate at all, that is likely the source of the instability. This jittering occurs even when gravity is turned off, and the wheel/suspension rig is floating in the air, disconnected to the body/suspension arm.

Here's what some of the code looks like for building this system... any help would be appreciated as I'm about at the end of my rope here.

Code: Select all

                var suspensionRig = new Cylinder(rigPos, rigHeight, rigRadius, 1.0f);
                Space.Add(suspensionRig);

                var wheelToRig = new RevoluteJoint(myWheel, suspensionRig , myWheel.Position, Vector3.Left);
                wheelToRig.Motor.IsActive = true;
                wheelToRig.Motor.Settings.Mode = MotorMode.VelocityMotor;
                wheelToRig.Motor.TestAxis = Vector3.Forward;
                wheelToRig.Motor.Basis.SetWorldAxes(Vector3.Left, Vector3.Forward);
                Space.Add(wheelToRig);
                AddRotationLock(suspensionRig,  TwoEntityConstraint.WorldEntity);

                 ///Create suspension arm
                var arm = new Box(armPos, armSize.X, armSize.Y, armSize.Z, 0.1f);
                Space.Add(arm);

                var bodyToArm = new RevoluteJoint(carBody, arm, arm.Position - new Vector3(arm.HalfWidth, 0, 0), Vector3.Forward);
                bodyToArm.Limit.IsActive = true;
                bodyToArm.Limit.LocalTestAxis = Vector3.Down;
                bodyToArm.Limit.Basis.SetWorldAxes(Vector3.Forward, Vector3.Down);
                bodyToArm.Limit.MinimumAngle = -MathHelper.PiOver4 * 0.5f;
                bodyToArm.Limit.MaximumAngle = MathHelper.PiOver4 * 0.5f;
                Space.Add(bodyToArm);

                var armToRig = new RevoluteJoint(suspensionRig, arm, arm.Position + new Vector3(arm.HalfWidth, 0, 0), Vector3.Forward);
                armToRig.Limit.IsActive = true;
                armToRig.Limit.LocalTestAxis = Vector3.Down;
                armToRig.Limit.Basis.SetWorldAxes(Vector3.Forward, Vector3.Down);
                armToRig.Limit.MinimumAngle = -MathHelper.PiOver4 * 0.5f;
                armToRig.Limit.MaximumAngle = MathHelper.PiOver4 * 0.5f;
                Space.Add(armToRig);
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Stability problems with suspension

Post by Norbo »

Nothing obvious jumps out at me on a glancing inspection, but weird behavioral problems often require a reproduction to pin down. Could you set up a runnable, debuggable demo in the latest BEPUphysicsDemos that shows the simplest configuration that still replicates the weird behavior so that I can dig deeper?
Post Reply