Skip to content

point_goal

PointGoal

Bases: SuccessCondition

PointGoal (success condition) used for PointNavFixed/RandomTask Episode terminates if point goal is reached within @distance_tol by the @robot_idn robot's base

Parameters:

Name Type Description Default
robot_idn int

robot identifier to evaluate point goal with. Default is 0, corresponding to the first robot added to the scene

0
distance_tol float

Distance (m) tolerance between goal position and @robot_idn's robot base position that is accepted as a success

0.5
distance_axes str

Which axes to calculate distances when calculating the goal. Any combination of "x", "y", and "z" is valid (e.g.: "xy" or "xyz" or "y")

'xyz'
Source code in OmniGibson/omnigibson/termination_conditions/point_goal.py
class PointGoal(SuccessCondition):
    """
    PointGoal (success condition) used for PointNavFixed/RandomTask
    Episode terminates if point goal is reached within @distance_tol by the @robot_idn robot's base

    Args:
        robot_idn (int): robot identifier to evaluate point goal with. Default is 0, corresponding to the first
            robot added to the scene
        distance_tol (float): Distance (m) tolerance between goal position and @robot_idn's robot base position
            that is accepted as a success
        distance_axes (str): Which axes to calculate distances when calculating the goal. Any combination of "x",
            "y", and "z" is valid (e.g.: "xy" or "xyz" or "y")
    """

    def __init__(self, robot_idn=0, distance_tol=0.5, distance_axes="xyz"):
        self._robot_idn = robot_idn
        self._distance_tol = distance_tol
        self._distance_axes = [i for i, axis in enumerate("xyz") if axis in distance_axes]

        # Run super init
        super().__init__()

    def _step(self, task, env, action):
        # Make sure task is of type PointNavigation -- we import at runtime to avoid circular imports
        from omnigibson.tasks.point_navigation_task import PointNavigationTask

        assert isinstance(
            task, PointNavigationTask
        ), f"Cannot use {self.__class__.__name__} with a non-PointNavigationTask task instance!"
        # Terminate if point goal is reached (distance below threshold)
        results = th.zeros(env.num_envs, dtype=th.bool)
        for env_idx in range(env.num_envs):
            current = task.get_current_pos(env, env_idx)
            goal = task.get_goal_pos(env_idx)
            dist = T.l2_distance(current[self._distance_axes], goal[self._distance_axes])
            results[env_idx] = dist < self._distance_tol
        return results