Skip to content

Commit

Permalink
Add ObjFixedPropId enums to actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Kajiih committed Feb 12, 2024
1 parent 8998512 commit aba8091
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions src/rl_ai2thor/envs/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

if TYPE_CHECKING:
from rl_ai2thor.envs.ai2thor_envs import ITHOREnv
from rl_ai2thor.envs.tasks import ObjFixedPropId
from rl_ai2thor.utils.ai2thor_types import EventLike


Expand Down Expand Up @@ -183,7 +184,7 @@ class EnvironmentAction:
action_category: ActionCategory
_: dataclasses.KW_ONLY # Following arguments are keyword-only
has_target_object: bool = False
object_required_property: str | None = None
object_required_property: ObjFixedPropId | None = None
parameter_name: str | None = None
parameter_range: tuple[float, float] | None = None
parameter_discrete_value: float | None = None
Expand Down Expand Up @@ -575,15 +576,15 @@ def __init__(self, ai2thor_action: str) -> None:
ai2thor_action=Ai2thorAction.PICKUP_OBJECT,
action_category=ActionCategory.PICKUP_PUT_ACTIONS,
has_target_object=True,
object_required_property="pickupable",
object_required_property=ObjFixedPropId.PICKUPABLE,
config_dependent_parameters={"forceAction", "manualInteract"},
)
put_object_action = EnvironmentAction(
name=EnvActionName.PUT_OBJECT,
ai2thor_action=Ai2thorAction.PUT_OBJECT,
action_category=ActionCategory.PICKUP_PUT_ACTIONS,
has_target_object=True,
object_required_property="receptacle",
object_required_property=ObjFixedPropId.RECEPTACLE,
config_dependent_parameters={"forceAction", "placeStationary"},
)
drop_hand_object_action = EnvironmentAction(
Expand All @@ -609,7 +610,7 @@ def __init__(self, ai2thor_action: str) -> None:
parameter_range=(0, 200),
parameter_discrete_value=100,
has_target_object=True,
object_required_property="moveable",
object_required_property=ObjFixedPropId.MOVEABLE,
config_dependent_parameters={"forceAction"},
)
pull_object_action = EnvironmentAction(
Expand All @@ -620,7 +621,7 @@ def __init__(self, ai2thor_action: str) -> None:
parameter_range=(0, 200),
parameter_discrete_value=100,
has_target_object=True,
object_required_property="moveable",
object_required_property=ObjFixedPropId.MOVEABLE,
config_dependent_parameters={"forceAction"},
)
# Note: "DirectionalPush", "TouchThenApplyForce" are not available because we keep only actions with a single parameter
Expand All @@ -630,15 +631,15 @@ def __init__(self, ai2thor_action: str) -> None:
ai2thor_action=Ai2thorAction.OPEN_OBJECT,
action_category=ActionCategory.OPEN_CLOSE_ACTIONS,
has_target_object=True,
object_required_property="openable",
object_required_property=ObjFixedPropId.OPENABLE,
config_dependent_parameters={"forceAction"},
)
close_object_action = EnvironmentAction(
name=EnvActionName.CLOSE_OBJECT,
ai2thor_action=Ai2thorAction.CLOSE_OBJECT,
action_category=ActionCategory.OPEN_CLOSE_ACTIONS,
has_target_object=True,
object_required_property="openable",
object_required_property=ObjFixedPropId.OPENABLE,
config_dependent_parameters={"forceAction"},
)
partial_open_object_action = EnvironmentAction(
Expand All @@ -648,31 +649,31 @@ def __init__(self, ai2thor_action: str) -> None:
parameter_name="openness",
parameter_range=(0, 1),
has_target_object=True,
object_required_property="openable",
object_required_property=ObjFixedPropId.OPENABLE,
config_dependent_parameters={"forceAction"},
)
toggle_object_on_action = EnvironmentAction(
name=EnvActionName.TOGGLE_OBJECT_ON,
ai2thor_action=Ai2thorAction.TOGGLE_OBJECT_ON,
action_category=ActionCategory.TOGGLE_ACTIONS,
has_target_object=True,
object_required_property="toggleable",
object_required_property=ObjFixedPropId.TOGGLEABLE,
config_dependent_parameters={"forceAction"},
)
toggle_object_off_action = EnvironmentAction(
name=EnvActionName.TOGGLE_OBJECT_OFF,
ai2thor_action=Ai2thorAction.TOGGLE_OBJECT_OFF,
action_category=ActionCategory.TOGGLE_ACTIONS,
has_target_object=True,
object_required_property="toggleable",
object_required_property=ObjFixedPropId.TOGGLEABLE,
config_dependent_parameters={"forceAction"},
)
fill_object_with_liquid_action = ConditionalExecutionAction(
name=EnvActionName.FILL_OBJECT_WITH_LIQUID,
ai2thor_action=Ai2thorAction.FILL_OBJECT_WITH_LIQUID,
action_category=ActionCategory.LIQUID_MANIPULATION_ACTIONS,
has_target_object=True,
object_required_property="canFillWithLiquid",
object_required_property=ObjFixedPropId.CAN_FILL_WITH_LIQUID,
other_ai2thor_parameters={"fillLiquid": "water"},
config_dependent_parameters={"forceAction"},
action_condition=fill_object_with_liquid_condition,
Expand All @@ -682,23 +683,23 @@ def __init__(self, ai2thor_action: str) -> None:
ai2thor_action=Ai2thorAction.EMPTY_LIQUID_FROM_OBJECT,
action_category=ActionCategory.LIQUID_MANIPULATION_ACTIONS,
has_target_object=True,
object_required_property="canFillWithLiquid",
object_required_property=ObjFixedPropId.CAN_FILL_WITH_LIQUID,
config_dependent_parameters={"forceAction"},
)
break_object_action = EnvironmentAction(
name=EnvActionName.BREAK_OBJECT,
ai2thor_action=Ai2thorAction.BREAK_OBJECT,
action_category=ActionCategory.BREAK_ACTIONS,
has_target_object=True,
object_required_property="breakable",
object_required_property=ObjFixedPropId.BREAKABLE,
config_dependent_parameters={"forceAction"},
)
slice_object_action = ConditionalExecutionAction(
name=EnvActionName.SLICE_OBJECT,
ai2thor_action=Ai2thorAction.SLICE_OBJECT,
action_category=ActionCategory.SLICE_ACTIONS,
has_target_object=True,
object_required_property="sliceable",
object_required_property=ObjFixedPropId.SLICEABLE,
config_dependent_parameters={"forceAction"},
action_condition=slice_object_condition,
)
Expand All @@ -707,23 +708,23 @@ def __init__(self, ai2thor_action: str) -> None:
ai2thor_action=Ai2thorAction.USE_UP_OBJECT,
action_category=ActionCategory.USE_UP_ACTIONS,
has_target_object=True,
object_required_property="canBeUsedUp",
object_required_property=ObjFixedPropId.SLICEABLE,
config_dependent_parameters={"forceAction"},
)
dirty_object_action = EnvironmentAction(
name=EnvActionName.DIRTY_OBJECT,
ai2thor_action=Ai2thorAction.DIRTY_OBJECT,
action_category=ActionCategory.CLEAN_DIRTY_ACTIONS,
has_target_object=True,
object_required_property="dirtyable",
object_required_property=ObjFixedPropId.DIRTYABLE,
config_dependent_parameters={"forceAction"},
)
clean_object_action = ConditionalExecutionAction(
name=EnvActionName.CLEAN_OBJECT,
ai2thor_action=Ai2thorAction.CLEAN_OBJECT,
action_category=ActionCategory.CLEAN_DIRTY_ACTIONS,
has_target_object=True,
object_required_property="dirtyable",
object_required_property=ObjFixedPropId.DIRTYABLE,
config_dependent_parameters={"forceAction"},
action_condition=clean_object_condition,
)
Expand Down

0 comments on commit aba8091

Please sign in to comment.