def _is_state_valid()

in habitat_baselines/motion_planning/motion_plan.py [0:0]


    def _is_state_valid(self, x: np.ndarray, take_image: bool = False) -> bool:
        """Returns if a state is collision free.
        :param take_image: If true, will render a debug image.
        """
        self._mp_space.set_arm(x)
        if self._ee_margin is not None and self._sphere_id is not None:
            self._use_sim.set_position(
                self._use_sim.get_ee_pos(), self._sphere_id
            )
        self._use_sim.micro_step()

        did_collide, coll_details = self._use_sim.get_collisions(
            self._config.COUNT_OBJ_COLLISIONS, self._ignore_names, True
        )
        if (
            self._ignore_first
            or self._use_sim.should_ignore_first_collisions()
        ) and self._coll_check_count == 0:
            self._ignore_names.extend(coll_details.robot_coll_ids)
            self._log(
                "First run, ignoring collisions from "
                + str(self._ignore_names)
            )
        self._coll_check_count += 1
        if take_image:
            self._render_debug_image(f"{did_collide}")

        if not self._use_sim.should_ignore_first_collisions():
            # We only want to continue to ignore collisions from this if we are
            # using a point cloud approach.
            self._ignore_names = []
        if did_collide and self._should_render:
            return False

        # Check we satisfy the EE margin, if there is one.
        if not self._check_ee_coll(
            self._ee_margin, self._sphere_id, coll_details
        ):
            return False

        return True