diff --git a/python/rainbow/simulators/prox_soft_bodies/collision_detection.py b/python/rainbow/simulators/prox_soft_bodies/collision_detection.py index 4e41015..ed4de2e 100644 --- a/python/rainbow/simulators/prox_soft_bodies/collision_detection.py +++ b/python/rainbow/simulators/prox_soft_bodies/collision_detection.py @@ -486,8 +486,9 @@ def _contact_determination(overlaps, engine, stats, debug_on): stats["contact_determination"] = contact_determination_timer.elapsed return stats + def _cp_unique_id(cp) -> tuple: - """ This function returns a unique id for a contact point. + """ This function returns a unique id for a ContactPoint instance. Args: cp (ContactPoint): A instance of the ContactPoint @@ -496,7 +497,8 @@ def _cp_unique_id(cp) -> tuple: """ return (cp.bodyA, cp.bodyB, tuple(cp.p)) -def _optimize_contact_reduction(engine, stats, debug_on): + +def _contact_reduction(engine, stats, debug_on): """ During contact point computation it may happen that different colliding triangles of one body results in the same contact point locations wrt to the other signed distance field of the other body. Imagine a spiky polygonal cone pointing into a spherical shape. Here all triangles of the spike will result in the same @@ -514,6 +516,7 @@ def _optimize_contact_reduction(engine, stats, debug_on): Returns: dict: A dictionary with profiling and timing measurements. """ + reduction_timer = None if debug_on: reduction_timer = Timer("contact_point_reduction", 8) reduction_timer.start() @@ -535,46 +538,6 @@ def _optimize_contact_reduction(engine, stats, debug_on): return stats -def _contact_reduction(engine, stats, debug_on): - """ - During contact point computation it may happen that different colliding triangles of one body results - in the same contact point locations wrt to the other signed distance field of the other body. Imagine a spiky - polygonal cone pointing into a spherical shape. Here all triangles of the spike will result in the same - contact point at the spiky tip. If the spiky polygonal cone has N triangle faces on the spike then we - will have N redundant contact points. This redundancy is usually bad for other numerical sub-routines for - computing impacts or contact forces. Hence, the purpose of this step is to eliminate redundant - contact point information. One may think of this as a kind of post-filtering process to clean up the - contact point information. - - :param engine: The current engine instance we are working with. - :param stats: A dictionary where to add more profiling and timing measurements. - :param debug_on: Boolean flag for toggling debug (aka profiling) info on and off. - :return: A dictionary with profiling and timing measurements. - """ - if engine.params.speedup: - return _optimize_contact_reduction(engine, stats, debug_on) - - reduction_timer = None - if debug_on: - reduction_timer = Timer("contact_point_reduction", 8) - reduction_timer.start() - # TODO 2020-09-07 Kristian: This brute force implementation can be implemented better - reduced_list = [] - for cp1 in engine.contact_points: - unique = True - for cp2 in reduced_list: - if {cp1.bodyA, cp1.bodyB} == {cp2.bodyA, cp2.bodyB} and ( - cp1.p == cp2.p - ).all(): - unique = False - if unique: - reduced_list.append(cp1) - engine.contact_points = reduced_list - if debug_on: - reduction_timer.end() - stats["contact_point_reduction"] = reduction_timer.elapsed - return stats - def run_collision_detection(engine, stats, debug_on): """ diff --git a/python/rainbow/util/USD.py b/python/rainbow/util/USD.py index 1d200b7..3a95618 100644 --- a/python/rainbow/util/USD.py +++ b/python/rainbow/util/USD.py @@ -94,7 +94,7 @@ def set_animation_time(self, duration: float) -> None: """ Set the total animation time of the scene Args: - duration (_type_): The total animation time of the scene + duration (float): The total animation time of the scene """ self.stage.SetStartTimeCode(0) self.stage.SetEndTimeCode(duration) diff --git a/python/rainbow/util/test_tools.py b/python/rainbow/util/test_tools.py index d4caf88..a0212de 100644 --- a/python/rainbow/util/test_tools.py +++ b/python/rainbow/util/test_tools.py @@ -6,7 +6,7 @@ """ -def is_array_equal(arr1, arr2, dec=8): +def is_array_equal(arr1, arr2): """ 2022-04-06 Kenny TODO: Write proper documentation. @@ -15,7 +15,7 @@ def is_array_equal(arr1, arr2, dec=8): :param dec: :return: """ - return None == np.testing.assert_array_almost_equal(arr1, arr2, dec) + return None == np.testing.assert_allclose(arr1, arr2, rtol=1e-5, atol=1e-8) def is_array_not_equal(arr1, arr2):