From 382f663a69088b2a7a3bcfd9f8e958dbb88b9cf8 Mon Sep 17 00:00:00 2001 From: Kolin Guo Date: Fri, 19 Apr 2024 17:58:23 -0700 Subject: [PATCH] Override 3 more SapienPlanningWorld methods to accept SAPIEN objects * is_articulation_planned * set_articulation_planned * is_object_attached --- mplib/sapien_utils/conversion.py | 71 ++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/mplib/sapien_utils/conversion.py b/mplib/sapien_utils/conversion.py index b58a3d8..bd4b607 100644 --- a/mplib/sapien_utils/conversion.py +++ b/mplib/sapien_utils/conversion.py @@ -352,6 +352,77 @@ def convert_physx_component(comp: PhysxRigidBaseComponent) -> FCLObject | None: ) # ----- Overloaded PlanningWorld methods to accept SAPIEN objects ----- # + def is_articulation_planned(self, articulation: PhysxArticulation | str) -> bool: # type: ignore + """ + Check whether the given articulation is being planned + + :param articulation: the articulation (or its name) to check + :return: ``True`` if the articulation is being planned, ``False`` otherwise. + + .. raw:: html + +
+ Overloaded + + PlanningWorld.is_articulation_planned() + + method + .. automethod:: mplib.PlanningWorld.is_articulation_planned + .. raw:: html +
+ """ + if isinstance(articulation, PhysxArticulation): + articulation = convert_object_name(articulation) + return super().is_articulation_planned(articulation) + + def set_articulation_planned( # type: ignore + self, articulation: PhysxArticulation | str, planned: bool + ) -> None: + """ + Sets the given articulation as being planned or not + + :param articulation: the articulation (or its name) + :param planned: whether the articulation should be planned + + .. raw:: html + +
+ Overloaded + + PlanningWorld.set_articulation_planned() + + method + .. automethod:: mplib.PlanningWorld.set_articulation_planned + .. raw:: html +
+ """ + if isinstance(articulation, PhysxArticulation): + articulation = convert_object_name(articulation) + super().set_articulation_planned(articulation, planned) + + def is_object_attached(self, obj: Entity | str) -> bool: # type: ignore + """ + Check whether the given non-articulated object is attached + + :param obj: the non-articulated object (or its name) to check + :return: ``True`` if the articulation is attached, ``False`` otherwise. + + .. raw:: html + +
+ Overloaded + + PlanningWorld.is_object_attached() + + method + .. automethod:: mplib.PlanningWorld.is_object_attached + .. raw:: html +
+ """ + if isinstance(obj, Entity): + obj = convert_object_name(obj) + return super().is_object_attached(obj) + def attach_object( # type: ignore self, obj: Entity | str,