Beispiel #1
0
class DummyEnvParameter:
    a: int = build_randomizable_param(0, low=-5, high=5)
    b: float = build_randomizable_param(0.0, low=-1.0, high=1.0)

    x: int = 0  # Non randomizable parameter.

    nested: DummyNestedEnvParameter = DummyNestedEnvParameter()
Beispiel #2
0
class DominosRearrangeSimParameters(RearrangeSimParameters):
    # How "skewed" the domino is. A bigger value corresponds to a thinner and taller domino.
    domino_eccentricity: float = build_randomizable_param(1.5,
                                                          low=1.0,
                                                          high=4.5)

    # The proportion compared to `object_size` to distance the dominos from each other
    domino_distance_mul: float = build_randomizable_param(4, low=2.0, high=5.0)

    num_objects: int = build_randomizable_param(5, low=1, high=8)
Beispiel #3
0
class HoldoutRearrangeSimParameters(RearrangeSimParameters):
    scene_object_configs: List[SceneObjectConfig] = attr.ib(
        default=[], converter=convert_scene_object_config)

    task_object_configs: List[TaskObjectConfig] = attr.ib(
        default=[TaskObjectConfig(xml_path="object/tests/block.xml")],
        converter=convert_task_object_config,
    )

    shared_settings: str = attr.ib(default="", converter=str)

    num_objects: int = build_randomizable_param(low=1, high=32)

    @num_objects.default
    def default_num_objects(self):
        return self._num_objects()

    @num_objects.validator
    def validate_num_objects(self, _, value):
        if value > self._num_objects():
            raise ValueError(
                f"Too many objects {value}, only {self._num_objects()} "
                f"objects are defined in config")

    def _num_objects(self):
        return sum(o.count for o in self.task_object_configs)
Beispiel #4
0
class RearrangeRobotControlParameters(RobotControlParameters):
    """ Robot control parameters – defined as parameters since max_position_change can be
    subject to ADR randomization """

    # refer to RobotControlParameters.default_max_pos_change_for_solver to set a
    # reasonable default here.
    max_position_change: float = build_randomizable_param(0.1, low=0.01, high=2.5)
Beispiel #5
0
class RearrangeEnvParameters(RobotEnvParameters):
    robot_control_params: RearrangeRobotControlParameters = build_nested_attr(
        RearrangeRobotControlParameters
    )

    simulation_params: RearrangeSimParameters = build_nested_attr(
        RearrangeSimParameters
    )

    # If true, turn on debugging features like visualizing bounding boxes.
    debug: bool = False

    # the range of object rescaling ratios (in log scale)
    object_scale_low: float = build_randomizable_param(0.0, low=0.0, high=0.5)
    object_scale_high: float = build_randomizable_param(0.0, low=0.0, high=1.8)

    # List of materials available for this environment. If multiple materials are specified
    # we will randomly select material from the list for each object.
    # If the list is None, all materials under materials folder will be considered.
    # If the list is empty, no material specific mujoco args will be applied.
    material_names: Optional[List[str]] = ["default"]
Beispiel #6
0
class ComposerRearrangeSimParameters(RearrangeSimParameters):
    # Overwrite the object group config type.
    object_groups: List[ComposerObjectGroupConfig] = None  # type: ignore

    def __attrs_post_init__(self):
        if self.object_groups is None:
            self.object_groups = [
                ComposerObjectGroupConfig(count=1, object_ids=[obj_id])
                for obj_id in range(self.num_objects)
            ]

    # Num. of geoms to use to compose one object.
    num_max_geoms: int = build_randomizable_param(1, low=1, high=20)

    # The type of object composer to be used.
    composer: Composer = attr.ib(  # type: ignore
        default="mixed",
        converter=composer_converter,  # type: ignore
    )
Beispiel #7
0
class RearrangeSimParameters(SimulationParameters):
    num_objects: int = build_randomizable_param(1, low=1, high=32)

    # The object size in half-size (as per Mujoco convention).
    object_size: float = build_randomizable_param(0.0254, low=0.01, high=0.1)

    # If not set, we use num_objects as max_num_objects.
    max_num_objects: Optional[int] = None

    # Max percent of table area to use.
    used_table_portion: float = build_randomizable_param(1.0,
                                                         low=0.4,
                                                         high=1.0)

    # Max number of times for placement retry. To place multiple objects, placement algorithm
    # place each object one by one. Whenever placing a new object is failed the placement
    # algorithm retry `max_placement_retry_per_object` times and if it still fails it start over
    # from the first object. The placement can start over for `max_placement_retry` times.
    max_placement_retry: int = 100
    max_placement_retry_per_object: int = 20

    # The `goal_distance_ratio` is used to decrease distance from object position to goal position
    # after uniformly sampling the goal. The decreased distance will be `goal_distance_ratio *
    # original_distance`. The distance cannot be decreased below `goal_distance_min`.
    goal_distance_ratio: float = build_randomizable_param(1.0,
                                                          low=0.0,
                                                          high=1.0)
    goal_distance_min: float = 0.06

    # The offset put on the relative positional distance between target and object. This can be
    # used to make the success threshold for object position different less strict. By adding
    # negative offset to relative positional distance, we can enjoy the effect of increasing the
    # success threshold by -goal_pos_offset.
    goal_pos_offset: float = build_randomizable_param(0.0, low=-0.04, high=0.0)

    # The weight put on the relative rotational distance between target and object. This can
    # be used to smoothly interpolate between not caring about rotational goals (when value = 0)
    # to fully caring about them (when value = 1).
    goal_rot_weight: float = build_randomizable_param(1.0, low=0.0, high=1.0)

    # Height of reach target object above the table, curriculum from high to low
    # helps policy learn to handle safety plane in z.
    target_height: float = build_randomizable_param(0.1, low=0.0, high=0.2)

    # Collection of penalties to impose on sim
    # Penalties are defined as positive numbers and are subtracted from
    # the reward.
    penalty: dict = dict(table_collision=0.0,
                         objects_off_table=1.0,
                         wrist_collision=0.0)

    # for camera view randomization (fov, pos and quat)
    camera_fovy_radius: float = build_randomizable_param(0.0, low=0, high=0.1)
    camera_pos_radius: float = build_randomizable_param(0.0, low=0, high=0.01)

    # about 5 degrees
    camera_quat_radius: float = build_randomizable_param(0.0, low=0, high=0.09)

    # Whether we should cast shadows. This is disabled by default because it slows down rendering
    # signficantly when using envs with custom meshes. We enable it for sim2real experiments.
    cast_shadows: bool = False

    # Lighting randomizations.
    light_pos_range: float = build_randomizable_param(0.0, low=0.0, high=0.8)
    light_ambient_intensity: float = build_randomizable_param(0.1,
                                                              low=0.1,
                                                              high=0.7)
    light_diffuse_intensity: float = build_randomizable_param(0.4,
                                                              low=0.1,
                                                              high=0.7)

    # Objects assigned with the same group id should be visually same (same shape, size, color).
    # We always assume group id starting from 0 and new ones are assigned incrementally.
    object_groups: List[ObjectGroupConfig] = None  # type: ignore

    def __attrs_post_init__(self):
        # Assign default value to object_groups if empty. Hard to use @object_groups.default here
        # as it depends on self.num_objects and the order is messed up in different subclasses.
        if self.object_groups is None:
            self.object_groups = [
                ObjectGroupConfig(count=1, object_ids=[obj_id])
                for obj_id in range(self.num_objects)
            ]
Beispiel #8
0
class DummyNestedEnvParameter:
    c: int = build_randomizable_param(1, low=-3, high=3)