From 1031d5791e86c23edda961f95a9fd1cbde4ed234 Mon Sep 17 00:00:00 2001 From: Dhruv Arora Date: Tue, 25 Jun 2024 14:11:46 -0700 Subject: [PATCH] Fixed Suspension and organized code with constants - made suspension a function of the radius to stop the robot from shifting when stationary - potential issue: robot is now raised off the ground even more than before --- fission/src/systems/physics/PhysicsSystem.ts | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/fission/src/systems/physics/PhysicsSystem.ts b/fission/src/systems/physics/PhysicsSystem.ts index 8461f6cbc2..4c5bf336e3 100644 --- a/fission/src/systems/physics/PhysicsSystem.ts +++ b/fission/src/systems/physics/PhysicsSystem.ts @@ -30,6 +30,11 @@ const COUNT_OBJECT_LAYERS = 10 export const SIMULATION_PERIOD = 1.0 / 120.0 const STANDARD_SUB_STEPS = 3 +// Friction constants +const FLOOR_FRICTION = 0.7; +const SUSPENSION_MIN_FACTOR = 0.1; +const SUSPENSION_MAX_FACTOR = 0.3; + /** * The PhysicsSystem handles all Jolt Phyiscs interactions within Synthesis. * This system can create physical representations of objects such as Robots, @@ -68,7 +73,7 @@ class PhysicsSystem extends WorldSystem { new THREE.Vector3(0.0, -2.0, 0.0), undefined ) - ground.SetFriction(0.7); + ground.SetFriction(FLOOR_FRICTION); this._joltBodyInterface.AddBody(ground.GetID(), JOLT.EActivation_Activate) } @@ -451,16 +456,10 @@ class PhysicsSystem extends WorldSystem { wheelSettings.mMaxHandBrakeTorque = 0.0 wheelSettings.mRadius = radius * 1.05 wheelSettings.mWidth = 0.1 - wheelSettings.mSuspensionMinLength = 0.0000003 - wheelSettings.mSuspensionMaxLength = 0.0000006 + wheelSettings.mSuspensionMinLength = radius * SUSPENSION_MIN_FACTOR + wheelSettings.mSuspensionMaxLength = radius * SUSPENSION_MAX_FACTOR wheelSettings.mInertia = 1 - // const friction = new JOLT.LinearCurve() - // friction.Clear() - // friction.AddPoint(1, 1) - // friction.AddPoint(0, 1) - // wheelSettings.mLongitudinalFriction = friction - const vehicleSettings = new JOLT.VehicleConstraintSettings() vehicleSettings.mWheels.clear()