From 30f0f520695993c18c1e2b570c10c8c92c11bc59 Mon Sep 17 00:00:00 2001 From: AntoineRichard Date: Tue, 10 Sep 2024 10:37:13 +0200 Subject: [PATCH] fixed jolts in physics? --- cfg/physics/default_physics.yaml | 5 +++-- src/configurations/physics_confs.py | 6 ++++++ src/physics/physics_scene.py | 6 +++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/cfg/physics/default_physics.yaml b/cfg/physics/default_physics.yaml index 76e5b86..d0919b4 100644 --- a/cfg/physics/default_physics.yaml +++ b/cfg/physics/default_physics.yaml @@ -1,7 +1,8 @@ physics_scene: - dt: 0.16666 + dt: 0.016666 gravity: [0.0, 0.0, -1.62] enable_ccd: true - enable_stabilization: false + enable_stabilization: true solver_type: PGS use_gpu_pipeline: false + broadphase_type: SAP diff --git a/src/configurations/physics_confs.py b/src/configurations/physics_confs.py index 390916c..e0d3f4d 100644 --- a/src/configurations/physics_confs.py +++ b/src/configurations/physics_confs.py @@ -30,6 +30,7 @@ class PhysicsSceneConf: gpu_max_num_partions: int = None gpu_collision_stack_size: int = None solver_type: str = None + broadphase_type: str = None enable_stabilization: bool = None bounce_threshold_velocity: float = None friction_offset_threshold: float = None @@ -41,3 +42,8 @@ def __post_init__(self): for attribute in dataclasses.fields(self): if getattr(self, attribute.name) is not None: self.physics_scene_args[attribute.name] = getattr(self, attribute.name) + + if self.broadphase_type is not None: + assert self.broadphase_type in ["SAP", "MBP", "GPU"] + if self.solver_type is not None: + assert self.solver_type in ["PGS", "TGS"] diff --git a/src/physics/physics_scene.py b/src/physics/physics_scene.py index 4ddb753..5f2636b 100644 --- a/src/physics/physics_scene.py +++ b/src/physics/physics_scene.py @@ -14,6 +14,10 @@ class PhysicsSceneManager: def __init__(self, settings: PhysicsSceneConf) -> None: self.settings = settings - self.physics_context = PhysicsContext(sim_params=self.settings.physics_scene_args) + self.physics_context = PhysicsContext(sim_params=self.settings.physics_scene_args, set_defaults=True) if self.settings.enable_ccd: self.physics_context.enable_ccd(True) + if self.settings.broadphase_type is not None: + self.physics_context.set_broadphase_type(self.settings.broadphase_type) + if self.settings.solver_type is not None: + self.physics_context.set_solver_type(self.settings.solver_type)