Пример #1
0
def get_flex_args(dataset_dir: str, parse=True):

    common = get_parser(dataset_dir, get_help=False)
    domino, domino_postproc = get_args(dataset_dir, parse=False)
    parser = ArgumentParser(parents=[common, domino], conflict_handler='resolve', fromfile_prefix_chars='@')

    parser.add_argument("--all_flex_objects",
                        type=int,
                        default=1,
                        help="Whether all rigid objects should be FLEX")
    parser.add_argument("--step_physics",
                        type=int,
                        default=100,
                        help="How many physics steps to run forward after adding a solid FLEX object")
    parser.add_argument("--cloth",
                        action="store_true",
                        help="Demo: whether to drop a cloth")
    parser.add_argument("--squishy",
                        action="store_true",
                        help="Demo: whether to drop a squishy ball")
    parser.add_argument("--fluid",
                        action="store_true",
                        help="Demo: whether to drop fluid")
    parser.add_argument("--fwait",
                        type=none_or_str,
                        default="30",
                        help="How many frames to wait before applying the force")


    def postprocess(args):

        args = domino_postproc(args)
        args.all_flex_objects = bool(int(args.all_flex_objects))

        return args

    if not parse:
        return (parser, postproccess)

    args = parser.parse_args()
    args = postprocess(args)

    return args
Пример #2
0
def get_barrier_args(dataset_dir: str, parse=True):

    common = get_parser(dataset_dir, get_help=False)
    domino, domino_postproc = get_args(dataset_dir, parse=False)
    parser = ArgumentParser(parents=[common, domino], conflict_handler='resolve', fromfile_prefix_chars='@')

    parser.add_argument("--middle",
                        type=str,
                        default='platonic',
                        help="middle object type")
    parser.add_argument("--bridge_height",
                        type=float,
                        default=1.0,
                        help="How high to make the bridge")

    def postprocess(args):
        return args

    args = parser.parse_args()
    args = domino_postproc(args)
    args = postprocess(args)

    return args
Пример #3
0
def get_gravity_args(dataset_dir: str, parse=True):

    common = get_parser(dataset_dir, get_help=False)
    domino, domino_postproc = get_args(dataset_dir, parse=False)
    parser = ArgumentParser(parents=[common, domino],
                            conflict_handler='resolve',
                            fromfile_prefix_chars='@')

    parser.add_argument(
        "--ramp",
        type=int,
        default=1,
        help="Whether to place the probe object on the top of a ramp")
    parser.add_argument("--rheight",
                        type=none_or_str,
                        default=0.5,
                        help="Height of the ramp base")
    parser.add_argument("--probe",
                        type=str,
                        default="sphere",
                        help="comma-separated list of possible probe objects")
    parser.add_argument("--pscale",
                        type=str,
                        default="0.2",
                        help="scale of probe objects")
    parser.add_argument("--pmass",
                        type=str,
                        default="1.0",
                        help="scale of probe objects")
    parser.add_argument(
        "--foffset",
        type=str,
        default="0.0,0.5,0.0",
        help=
        "offset from probe centroid from which to apply force, relative to probe scale"
    )

    parser.add_argument("--collision_axis_length",
                        type=float,
                        default=2.5,
                        help="How far to put the probe and target")

    # camera
    parser.add_argument("--camera_distance",
                        type=float,
                        default=3.25,
                        help="radial distance from camera to centerpoint")
    parser.add_argument(
        "--camera_min_angle",
        type=float,
        default=0,
        help="minimum angle of camera rotation around centerpoint")
    parser.add_argument(
        "--camera_max_angle",
        type=float,
        default=90,
        help="maximum angle of camera rotation around centerpoint")
    parser.add_argument("--camera_min_height",
                        type=float,
                        default=2.0,
                        help="min height of camera")
    parser.add_argument("--camera_max_height",
                        type=float,
                        default=3.0,
                        help="max height of camera")

    def postprocess(args):

        args = domino_postproc(args)
        args.rheight = handle_random_transform_args(args.rheight)

        return args

    if not parse:
        return (parser, postprocess)

    args = parser.parse_args()
    args = postprocess(args)

    if args.training_data_mode:
        args.dir = os.path.join(args.dir, 'training_data')
        args.random = 0
        args.seed = args.seed + 1
        args.color = args.pcolor = args.mcolor = args.rcolor = None
        args.remove_zone = 1
        args.remove_target = 1
        args.save_passes = ""
        args.save_movies = False
        args.tower_cap = MODEL_NAMES

    return args
Пример #4
0
def get_playroom_args(dataset_dir: str, parse=True):

    common = get_parser(dataset_dir, get_help=False)
    domino, domino_postproc = get_args(dataset_dir, parse=False)
    parser = ArgumentParser(parents=[common, domino],
                            conflict_handler='resolve',
                            fromfile_prefix_chars='@')

    ## Changed defaults
    parser.add_argument("--room",
                        type=str,
                        default="tdw",
                        help="Which room to be in")

    ### zone
    parser.add_argument("--zscale",
                        type=str,
                        default="[2.0,4.0],0.01,[2.0,4.0]",
                        help="scale of target zone")
    parser.add_argument("--zmaterial",
                        type=none_or_str,
                        default=None,
                        help="material of zone")
    parser.add_argument(
        "--material_types",
        type=none_or_str,
        default="Wood,Ceramic",
        help="Which class of materials to sample material names from")

    parser.add_argument(
        "--zone",
        type=str,
        default="cube",
        help="comma-separated list of possible target zone shapes")

    parser.add_argument("--zjitter",
                        type=float,
                        default=0.35,
                        help="amount of z jitter applied to the target zone")

    ### probe
    parser.add_argument(
        "--plift",
        type=float,
        default=0.0,
        help="Lift the probe object off the floor. Useful for rotated objects")

    ### force
    parser.add_argument("--fscale",
                        type=str,
                        default="[10.0,10.0]",
                        help="range of scales to apply to push force")
    parser.add_argument(
        "--fwait",
        type=none_or_str,
        default="5",
        help="range of time steps to apply to wait to apply force")

    parser.add_argument("--frot",
                        type=str,
                        default="[-30,30]",
                        help="range of angles in xz plane to apply push force")

    parser.add_argument(
        "--foffset",
        type=str,
        default="0.0,0.0,0.0",
        help=
        "offset from probe centroid from which to apply force, relative to probe scale"
    )

    parser.add_argument("--fjitter",
                        type=float,
                        default=0.5,
                        help="jitter around object centroid to apply force")

    ###target
    parser.add_argument("--target",
                        type=none_or_str,
                        default=','.join(ALL_NAMES),
                        help="comma-separated list of possible target objects")
    parser.add_argument(
        "--target_categories",
        type=none_or_str,
        default=None,
        # default=ANIMALS_TOYS_FRUIT,
        help="Allowable target categories")

    parser.add_argument("--tscale",
                        type=str,
                        default="[0.75,1.5]",
                        help="scale of target objects")

    ### probe
    parser.add_argument("--probe",
                        type=none_or_str,
                        default=','.join(ALL_NAMES),
                        help="comma-separated list of possible target objects")
    parser.add_argument(
        "--probe_categories",
        type=none_or_str,
        default=None,
        # default=ANIMALS_TOYS_FRUIT,
        help="Allowable probe categories")

    parser.add_argument("--pscale",
                        type=str,
                        default="[0.75,1.5]",
                        help="scale of probe objects")

    ## size ranges for objects
    parser.add_argument("--size_min",
                        type=none_or_str,
                        default="0.05",
                        help="Minimum size for probe and target objects")
    parser.add_argument("--size_max",
                        type=none_or_str,
                        default="4.0",
                        help="Maximum size for probe and target objects")

    ### layout
    parser.add_argument(
        "--collision_axis_length",
        type=float,
        default=1.5,
        help=
        "Length of spacing between probe and target objects at initialization."
    )

    ## collision specific arguments
    parser.add_argument(
        "--fupforce",
        type=none_or_str,
        default="[0.1,0.9]",
        help=
        "Upwards component of force applied, with 0 being purely horizontal force and 1 being the same force being applied horizontally applied vertically."
    )

    ## camera
    parser.add_argument(
        "--camera_min_height",
        type=float,
        default=2.0,
        help="minimum angle of camera rotation around centerpoint")
    parser.add_argument(
        "--camera_max_height",
        type=float,
        default=3.5,
        help="minimum angle of camera rotation around centerpoint")
    parser.add_argument(
        "--camera_min_angle",
        type=float,
        default=0,
        help="minimum angle of camera rotation around centerpoint")
    parser.add_argument(
        "--camera_max_angle",
        type=float,
        default=360,
        help="maximum angle of camera rotation around centerpoint")
    parser.add_argument("--camera_distance",
                        type=none_or_str,
                        default="[0.01,1.5]",
                        help="radial distance from camera to centerpoint")

    ## occluders and distractors
    parser.add_argument("--occluder",
                        type=none_or_str,
                        default="full",
                        help="The names or library of occluder objects to use")
    parser.add_argument("--distractor",
                        type=none_or_str,
                        default="full",
                        help="The names or library of occluder objects to use")
    parser.add_argument("--occluder_aspect_ratio",
                        type=none_or_str,
                        default="[0.5,2.5]",
                        help="The range of valid occluder aspect ratios")
    parser.add_argument("--distractor_aspect_ratio",
                        type=none_or_str,
                        default="[0.25,5.0]",
                        help="The range of valid distractor aspect ratios")
    parser.add_argument("--occluder_categories",
                        type=none_or_str,
                        default=OCCLUDER_CATEGORIES,
                        help="the category ids to sample occluders from")
    parser.add_argument("--distractor_categories",
                        type=none_or_str,
                        default=DISTRACTOR_CATEGORIES,
                        help="the category ids to sample distractors from")
    parser.add_argument("--num_occluders",
                        type=none_or_int,
                        default=1,
                        help="number of occluders")
    parser.add_argument("--num_distractors",
                        type=none_or_int,
                        default=1,
                        help="number of distractors")

    def postprocess(args):
        args.fupforce = handle_random_transform_args(args.fupforce)
        args.size_min = handle_random_transform_args(args.size_min)
        args.size_max = handle_random_transform_args(args.size_max)

        ## don't let background objects move
        args.no_moving_distractors = True

        return args

    args = parser.parse_args()
    args = domino_postproc(args)
    args = postprocess(args)

    return args
Пример #5
0
def get_relational_args(dataset_dir: str, parse=True):

    common = get_parser(dataset_dir, get_help=False)
    domino, domino_postproc = get_args(dataset_dir, parse=False)
    parser = ArgumentParser(parents=[common, domino],
                            conflict_handler='resolve',
                            fromfile_prefix_chars='@')

    ## Relation type
    parser.add_argument("--relation",
                        type=str,
                        default=','.join([r.name for r in Relation]),
                        help="Which relation type to construct")

    ## scenarios
    parser.add_argument("--start",
                        type=none_or_int,
                        default=0,
                        help="which scenario to start with")
    parser.add_argument("--end",
                        type=none_or_int,
                        default=None,
                        help="which scenario to end on (exclusive)")
    parser.add_argument("--training_data",
                        type=none_or_int,
                        default=1,
                        help="Whether to use training data or testing data")

    ## Object types
    parser.add_argument("--container",
                        type=none_or_str,
                        default="b04_bowl_smooth",
                        help="comma-separated list of container names")
    parser.add_argument("--target",
                        type=none_or_str,
                        default="b04_clownfish",
                        help="comma-separated list of target object names")
    parser.add_argument("--distractor",
                        type=none_or_str,
                        default="b05_lobster",
                        help="comma-separated list of distractor object names")

    ## Object positions
    parser.add_argument("--cposition",
                        type=str,
                        default="[[-0.25,0.25],0.0,[-0.25,0.25]]",
                        help="Position ranges for the container")
    parser.add_argument(
        "--tposition",
        type=str,
        default="[0.3,1.0]",
        help="Position ranges for the target/distractor (offset from container)"
    )
    parser.add_argument("--trotation",
                        type=str,
                        default="[0,180]",
                        help="Pose ranges for the target/distractor")
    parser.add_argument(
        "--thorizontal",
        action="store_true",
        help="Whether to rotate the target object so that it's horizontal")
    parser.add_argument(
        "--tangle",
        type=str,
        default="[0,30]",
        help=
        "How much to jitter the target position angle relative to container")
    parser.add_argument("--tjitter",
                        type=float,
                        default="0.2",
                        help="How much to jitter the target position")

    ## Object scales
    parser.add_argument("--cscale",
                        type=str,
                        default="[0.75,1.25]",
                        help="scale of container")
    parser.add_argument("--tscale",
                        type=str,
                        default="[1.0,1.5]",
                        help="scale of target object")
    parser.add_argument("--max_target_scale_ratio",
                        type=float,
                        default=0.9,
                        help="Max ratio between target and container scale")
    parser.add_argument("--dscale",
                        type=str,
                        default="[0.75,1.25]",
                        help="scale of distractor")

    ## Camera
    parser.add_argument("--camera_distance",
                        type=none_or_str,
                        default="[1.75,2.5]",
                        help="radial distance from camera to centerpoint")
    parser.add_argument("--camera_min_height",
                        type=float,
                        default=1.25,
                        help="min height of camera")
    parser.add_argument("--camera_max_height",
                        type=float,
                        default=2.0,
                        help="max height of camera")
    parser.add_argument(
        "--camera_min_angle",
        type=float,
        default=0,
        help="minimum angle of camera rotation around centerpoint")
    parser.add_argument(
        "--camera_max_angle",
        type=float,
        default=360,
        help="maximum angle of camera rotation around centerpoint")
    parser.add_argument(
        "--camera_left_right_reflections",
        action="store_true",
        help=
        "Whether camera angle range includes reflections along the collision axis"
    )

    ## Changed defaults
    parser.add_argument("--room",
                        type=str,
                        default="tdw",
                        help="Which room to be in")
    parser.add_argument("--zscale",
                        type=str,
                        default="-1.0",
                        help="scale of target zone")
    parser.add_argument(
        "--zcolor",
        type=none_or_str,
        default=None,
        help=
        "comma-separated R,G,B values for the target zone color. None is random"
    )
    parser.add_argument(
        "--zmaterial",
        type=none_or_str,
        default=None,
        help="Material name for zone. If None, samples from material_type")
    parser.add_argument(
        "--material_types",
        type=none_or_str,
        default="Wood,Metal,Ceramic",
        help="Which class of materials to sample material names from")

    def postprocess(args):

        args.relation = [
            r for r in Relation if r.name in args.relation.split(',')
        ]

        args.container = [
            nm for nm in args.container.split(',') if nm in ALL_NAMES
        ]
        args.target = [nm for nm in args.target.split(',') if nm in ALL_NAMES]
        args.distractor = [
            nm for nm in args.distractor.split(',') if nm in ALL_NAMES
        ]

        args.zscale = handle_random_transform_args(args.zscale)
        args.cscale = handle_random_transform_args(args.cscale)
        args.tscale = handle_random_transform_args(args.tscale)
        args.dscale = handle_random_transform_args(args.dscale)

        args.cposition = handle_random_transform_args(args.cposition)
        args.cposition["y"] = 0.0

        args.tposition = handle_random_transform_args(args.tposition)
        args.trotation = handle_random_transform_args(args.trotation)
        args.tangle = handle_random_transform_args(args.tangle)

        args.camera_distance = handle_random_transform_args(
            args.camera_distance)

        return args

    args = parser.parse_args()
    args = postprocess(args)

    return args
Пример #6
0
def get_rolling_sliding_args(dataset_dir: str, parse=True):

    common = get_parser(dataset_dir, get_help=False)
    domino, domino_postproc = get_args(dataset_dir, parse=False)
    parser = ArgumentParser(parents=[common, domino], conflict_handler='resolve', fromfile_prefix_chars='@')

    ## Changed defaults
    ### zone
    parser.add_argument("--zscale",
                        type=str,
                        default="2.0,0.01,2.0",
                        help="scale of target zone")

    parser.add_argument("--zone",
                        type=str,
                        default="cube",
                        help="comma-separated list of possible target zone shapes")

    parser.add_argument("--zjitter",
                        type=float,
                        default=0.,
                        help="amount of z jitter applied to the target zone")

    ### force
    parser.add_argument("--fscale",
                        type=str,
                        default="[0.0,0.0]",
                        help="range of scales to apply to push force")

    parser.add_argument("--frot",
                        type=str,
                        default="[-20,20]",
                        help="range of angles in xz plane to apply push force")

    parser.add_argument("--foffset",
                        type=str,
                        default="0.0,0.8,0.0",
                        help="offset from probe centroid from which to apply force, relative to probe scale")

    parser.add_argument("--fjitter",
                        type=float,
                        default=0.,
                        help="jitter around object centroid to apply force")

    parser.add_argument("--fupforce",
                        type=str,
                        default='[0,0]',
                        help="Upwards component of force applied, with 0 being purely horizontal force and 1 being the same force being applied horizontally applied vertically")


    ###target
    parser.add_argument("--target",
                        type=str,
                        default="pipe,cube,pentagon,sphere",
                        help="comma-separated list of possible target objects")

    parser.add_argument("--tscale",
                        type=str,
                        default="0.25,0.25,0.25",
                        help="scale of target objects")

    parser.add_argument("--tlift",
                        type=float,
                        default=0.,
                        help="Lift the target object off the floor/ramp. Useful for rotated objects")

    ### layout
    parser.add_argument("--rolling_sliding_axis_length",
                        type=float,
                        default=1.15,
                        help="Length of spacing between target object and zone.")

    ### ramp
    parser.add_argument("--ramp_scale",
                        type=str,
                        default="[0.2,0.25,0.5]",
                        help="Scaling factor of the ramp in xyz.")

    ### ledge
    parser.add_argument("--use_ledge",
                        type=int,
                        default=0,
                        help="Whether to place ledge between the target and the zone")

    parser.add_argument("--ledge",
                        type=str,
                        default="sphere",
                        help="comma-separated list of possible ledge objects")

    parser.add_argument("--ledge_position",
                        type=float,
                        default=0.5,
                        help="Fraction between 0 and 1 where to place the ledge on the axis")

    parser.add_argument("--ledge_scale",
                        type=str,
                        default="[0.05,0.05,100.0]",
                        help="Scaling factor of the ledge in xyz.")

    ### occluder/distractors
    parser.add_argument("--occluder_categories",
                                      type=none_or_str,
                                      default=OCCLUDER_CATS,
                                      help="the category ids to sample occluders from")
    parser.add_argument("--distractor_categories",
                                      type=none_or_str,
                                      default=DISTRACTOR_CATS,
                                      help="the category ids to sample distractors from")

    def postprocess(args):
        args.fupforce = handle_random_transform_args(args.fupforce)
        args.ramp_scale = handle_random_transform_args(args.ramp_scale)

        ### ledge
        args.use_ledge = bool(args.use_ledge)

        if args.ledge is not None:
            targ_list = args.ledge.split(',')
            assert all([t in MODEL_NAMES for t in targ_list]), \
                "All ledge object names must be elements of %s" % MODEL_NAMES
            args.ledge = targ_list
        else:
            args.ledge = MODEL_NAMES

        args.ledge_scale = handle_random_transform_args(args.ledge_scale)

        return args

    args = parser.parse_args()
    args = domino_postproc(args)
    args = postprocess(args)

    return args
Пример #7
0
def get_collide_args(dataset_dir: str, parse=True):
    """
    Combine Tower-specific args with general Dominoes args
    """
    common = get_parser(dataset_dir, get_help=False)
    domino, domino_postproc = get_args(dataset_dir, parse=False)
    parser = ArgumentParser(parents=[common, domino], conflict_handler='resolve')

    parser.add_argument("--collision_axis_length",
                        type=float,
                        default=2.0,
                        help="How far to put the probe and target")
    parser.add_argument("--middle",
                        type=str,
                        default="cylinder",
                        help="comma-separated list of possible middle objects")
    parser.add_argument("--mscale",
                        type=str,
                        default="0.1,0.5,0.25",
                        help="Scale or scale range for middle object to sample from")
    parser.add_argument("--mrot",
                        type=str,
                        default="[-45,45]",
                        help="comma separated list of initial middle object rotation values")
    parser.add_argument("--horizontal",
                        type=int,
                        default=1,
                        help="whether to place the middle object horizontally (on its side)")
    parser.add_argument("--spacing_jitter",
                        type=float,
                        default=0.25,
                        help="jitter in how to space middle object in xz plane")
    parser.add_argument("--probe",
                        type=str,
                        default="sphere",
                        help="comma-separated list of possible probe objects")
    parser.add_argument("--pmass",
                        type=str,
                        default="[2.0,4.0]",
                        help="scale of probe objects")
    parser.add_argument("--pscale",
                        type=str,
                        default="[0.2,0.4]",
                        help="scale of probe objects")
    parser.add_argument("--tscale",
                        type=str,
                        default="[0.5,0.5]",
                        help="scale of target objects")
    parser.add_argument("--fscale",
                        type=str,
                        default="[4.0,10.0]",
                        help="range of scales to apply to push force")
    parser.add_argument("--frot",
                        type=str,
                        default="[-20,20]",
                        help="range of angles in xz plane to apply push force")
    parser.add_argument("--foffset",
                        type=str,
                        default="0.0,0.5,0.0",
                        help="offset from probe centroid from which to apply force, relative to probe scale")
    parser.add_argument("--fjitter",
                        type=float,
                        default=0.0,
                        help="jitter around object centroid to apply force")
    parser.add_argument("--camera_distance",
                        type=float,
                        default=1.5,
                        help="radial distance from camera to centerpoint")
    parser.add_argument("--camera_min_angle",
                        type=float,
                        default=0,
                        help="minimum angle of camera rotation around centerpoint")
    parser.add_argument("--camera_max_angle",
                        type=float,
                        default=180,
                        help="maximum angle of camera rotation around centerpoint")


    def postprocess(args):
        args.horizontal = bool(args.horizontal)

        return args

    args = parser.parse_args()
    args = domino_postproc(args)
    args = postprocess(args)

    print(vars(parser.parse_args()))

    return args
Пример #8
0
def get_tower_args(dataset_dir: str, parse=True):
    """
    Combine Tower-specific args with general Dominoes args
    """
    common = get_parser(dataset_dir, get_help=False)
    domino, domino_postproc = get_args(dataset_dir, parse=False)
    parser = ArgumentParser(parents=[common, domino],
                            conflict_handler='resolve',
                            fromfile_prefix_chars='@')

    parser.add_argument("--remove_target",
                        type=int_or_bool,
                        default=1,
                        help="Whether to remove the target object")
    parser.add_argument(
        "--ramp",
        type=int,
        default=0,
        help="Whether to place the probe object on the top of a ramp")
    parser.add_argument("--collision_axis_length",
                        type=float,
                        default=3.0,
                        help="How far to put the probe and target")
    parser.add_argument(
        "--num_blocks",
        type=int,
        default=3,
        help="Number of rectangular blocks to build the tower base with")
    parser.add_argument(
        "--mscale",
        type=str,
        default="[0.5,0.5]",
        help="Scale or scale range for rectangular blocks to sample from")
    parser.add_argument(
        "--mgrad",
        type=float,
        default=0.0,
        help="Size of block scale gradient going from top to bottom of tower")
    parser.add_argument("--tower_cap",
                        type=none_or_str,
                        default="bowl",
                        help="Object types to use as a capper on the tower")
    parser.add_argument(
        "--spacing_jitter",
        type=float,
        default=0.25,
        help=
        "jitter in how to space middle objects, as a fraction of uniform spacing"
    )
    parser.add_argument(
        "--mrot",
        type=str,
        default="[-45,45]",
        help="comma separated list of initial middle object rotation values")
    parser.add_argument(
        "--mmass",
        type=str,
        default="2.0",
        help="comma separated list of initial middle object rotation values")
    parser.add_argument("--middle",
                        type=str,
                        default="cube",
                        help="comma-separated list of possible middle objects")
    parser.add_argument("--probe",
                        type=str,
                        default="sphere",
                        help="comma-separated list of possible target objects")
    parser.add_argument("--pmass",
                        type=str,
                        default="3.0",
                        help="scale of probe objects")
    parser.add_argument("--pscale",
                        type=str,
                        default="0.3",
                        help="scale of probe objects")
    parser.add_argument("--tscale",
                        type=str,
                        default="[0.5,0.5]",
                        help="scale of target objects")
    parser.add_argument("--zone",
                        type=none_or_str,
                        default="cube",
                        help="type of zone object")
    parser.add_argument("--zscale",
                        type=str,
                        default="3.0,0.01,3.0",
                        help="scale of target zone")
    parser.add_argument("--fscale",
                        type=str,
                        default="1.0",
                        help="range of scales to apply to push force")
    parser.add_argument("--frot",
                        type=str,
                        default="[-0,0]",
                        help="range of angles in xz plane to apply push force")
    parser.add_argument(
        "--foffset",
        type=str,
        default="0.0,0.5,0.0",
        help=
        "offset from probe centroid from which to apply force, relative to probe scale"
    )
    parser.add_argument("--fjitter",
                        type=float,
                        default=0.0,
                        help="jitter around object centroid to apply force")
    parser.add_argument(
        "--fwait",
        type=none_or_str,
        default="[15,15]",
        help="How many frames to wait before applying the force")
    parser.add_argument("--camera_distance",
                        type=float,
                        default=3.0,
                        help="radial distance from camera to centerpoint")
    parser.add_argument(
        "--camera_min_angle",
        type=float,
        default=0,
        help="minimum angle of camera rotation around centerpoint")
    parser.add_argument(
        "--camera_max_angle",
        type=float,
        default=90,
        help="maximum angle of camera rotation around centerpoint")

    # for generating training data without zones, targets, caps, and at lower resolution
    parser.add_argument(
        "--training_data_mode",
        action="store_true",
        help=
        "Overwrite some parameters to generate training data without target objects, zones, etc."
    )

    def postprocess(args):

        # parent postprocess
        args = domino_postproc(args)

        # whether to use a cap object on the tower
        if args.tower_cap is not None:
            cap_list = args.tower_cap.split(',')
            assert all([t in MODEL_NAMES for t in cap_list]), \
                "All target object names must be elements of %s" % MODEL_NAMES
            args.tower_cap = cap_list
        else:
            args.tower_cap = []

        return args

    if not parse:
        return (parser, postprocess)

    args = parser.parse_args()
    # args = domino_postproc(args)
    args = postprocess(args)

    # produce training data
    if args.training_data_mode:
        args.dir = os.path.join(args.dir, 'training_data')
        args.random = 0
        args.seed = args.seed + 1
        args.color = args.pcolor = args.mcolor = args.rcolor = None
        args.remove_zone = 1
        args.remove_target = 1
        args.save_passes = ""
        args.save_movies = False
        args.tower_cap = MODEL_NAMES

    return args
Пример #9
0
def get_drop_args(dataset_dir: str):
    """
    Combine Drop-specific arguments with controller-common arguments
    """
    common = get_parser(dataset_dir, get_help=False)
    domino, domino_postproc = get_args(dataset_dir, parse=False)
    parser = ArgumentParser(parents=[common, domino], conflict_handler='resolve', fromfile_prefix_chars='@')

    parser.add_argument("--drop",
                        type=str,
                        default=None,
                        help="comma-separated list of possible drop objects")
    parser.add_argument("--target",
                        type=str,
                        default=None,
                        help="comma-separated list of possible target objects")
    parser.add_argument("--ymin",
                        type=float,
                        default=1.25,
                        help="min height to drop object from")
    parser.add_argument("--ymax",
                        type=float,
                        default=1.5,
                        help="max height to drop object from")
    parser.add_argument("--dscale",
                        type=str,
                        default="[0.1,0.4]",
                        help="scale of drop objects")
    parser.add_argument("--tscale",
                        type=str,
                        default="[0.3,0.7]",
                        help="scale of target objects")
    parser.add_argument("--drot",
                        type=str,
                        default="{'x':[0,360],'y':[0,360],'z':[0,360]}",
                        help="comma separated list of initial drop rotation values")
    parser.add_argument("--zscale",
                        type=str,
                        default="2.0,0.01,2.0",
                        help="scale of target zone")
    # parser.add_argument("--trot",
    #                     type=str,
    #                     default=None,
    #                     help="comma separated list of initial target rotation values")
    parser.add_argument("--jitter",
                        type=float,
                        default=0.2,
                        help="amount to jitter initial drop object horizontal position across trials")
    # parser.add_argument("--camera_distance",
    #                     type=float,
    #                     default=1.25,
    #                     help="radial distance from camera to drop/target object pair")
    # parser.add_argument("--camera_min_angle",
    #                     type=float,
    #                     default=0,
    #                     help="minimum angle of camera rotation around centerpoint")
    # parser.add_argument("--camera_max_angle",
    #                     type=float,
    #                     default=0,
    #                     help="maximum angle of camera rotation around centerpoint")
    parser.add_argument("--camera_min_height",
                        type=float,
                        default=0.,
                         help="min height of camera as a fraction of drop height")
    parser.add_argument("--camera_max_height",
                        type=float,
                        default=2.,
                        help="max height of camera as a fraction of drop height")
    parser.add_argument("--mmass",
                    type=str,
                    default="10.0",
                    help="Scale or scale range for mass of  middle object")
    ### occluder/distractors
    parser.add_argument("--occluder_categories",
                                      type=none_or_str,
                                      default=OCCLUDER_CATS,
                                      help="the category ids to sample occluders from")
    parser.add_argument("--distractor_categories",
                                      type=none_or_str,
                                      default=DISTRACTOR_CATS,
                                      help="the category ids to sample distractors from")


    def postprocess(args):
         # whether to set all objects same color
        args.monochrome = bool(args.monochrome)

        args.dscale = handle_random_transform_args(args.dscale)
        # args.tscale = handle_random_transform_args(args.tscale)

        args.drot = handle_random_transform_args(args.drot)
        # args.trot = handle_random_transform_args(args.trot)

        # choose a valid room
        assert args.room in ['box', 'tdw', 'house'], args.room

        if args.drop is not None:
            drop_list = args.drop.split(',')
            assert all([d in MODEL_NAMES for d in drop_list]), \
                "All drop object names must be elements of %s" % MODEL_NAMES
            args.drop = drop_list
        else:
            args.drop = MODEL_NAMES

        # if args.target is not None:
        #     targ_list = args.target.split(',')
        #     assert all([t in MODEL_NAMES for t in targ_list]), \
        #         "All target object names must be elements of %s" % MODEL_NAMES
        #     args.target = targ_list
        # else:
        #     args.target = MODEL_NAMES

        # if args.color is not None:
        #     rgb = [float(c) for c in args.color.split(',')]
        #     assert len(rgb) == 3, rgb
        #     args.color = rgb

        return args

    args = parser.parse_args()
    args = domino_postproc(args)
    args = postprocess(args)

    return args
Пример #10
0
def get_collision_args(dataset_dir: str, parse=True):

    common = get_parser(dataset_dir, get_help=False)
    domino, domino_postproc = get_args(dataset_dir, parse=False)
    parser = ArgumentParser(parents=[common, domino],
                            conflict_handler='resolve',
                            fromfile_prefix_chars='@')

    ## Changed defaults
    ### zone
    parser.add_argument("--zscale",
                        type=str,
                        default="1.0,0.01,1.0",
                        help="scale of target zone")

    parser.add_argument(
        "--zone",
        type=str,
        default="cube",
        help="comma-separated list of possible target zone shapes")

    parser.add_argument("--zjitter",
                        type=float,
                        default=0.35,
                        help="amount of z jitter applied to the target zone")

    ### probe
    parser.add_argument("--probe",
                        type=str,
                        default="sphere",
                        help="comma-separated list of possible probe objects")

    parser.add_argument("--pscale",
                        type=str,
                        default="0.35,0.35,0.35",
                        help="scale of probe objects")

    parser.add_argument(
        "--plift",
        type=float,
        default=0.,
        help="Lift the probe object off the floor. Useful for rotated objects")

    ### force
    parser.add_argument("--fscale",
                        type=str,
                        default="[5.0,10.0]",
                        help="range of scales to apply to push force")

    parser.add_argument("--frot",
                        type=str,
                        default="[-20,20]",
                        help="range of angles in xz plane to apply push force")

    parser.add_argument(
        "--foffset",
        type=str,
        default="0.0,0.8,0.0",
        help=
        "offset from probe centroid from which to apply force, relative to probe scale"
    )

    parser.add_argument("--fjitter",
                        type=float,
                        default=0.5,
                        help="jitter around object centroid to apply force")

    ###target
    parser.add_argument("--target",
                        type=str,
                        default="pipe,cube,pentagon",
                        help="comma-separated list of possible target objects")

    parser.add_argument("--tscale",
                        type=str,
                        default="0.25,0.5,0.25",
                        help="scale of target objects")

    ### layout
    parser.add_argument(
        "--collision_axis_length",
        type=float,
        default=2.0,
        help=
        "Length of spacing between probe and target objects at initialization."
    )

    ## collision specific arguments
    parser.add_argument(
        "--fupforce",
        type=str,
        default='[0,0]',
        help=
        "Upwards component of force applied, with 0 being purely horizontal force and 1 being the same force being applied horizontally applied vertically."
    )

    ## camera
    parser.add_argument(
        "--camera_min_angle",
        type=float,
        default=0,
        help="minimum angle of camera rotation around centerpoint")
    parser.add_argument(
        "--camera_max_angle",
        type=float,
        default=360,
        help="maximum angle of camera rotation around centerpoint")
    parser.add_argument("--camera_distance",
                        type=none_or_str,
                        default="2.3",
                        help="radial distance from camera to centerpoint")

    ## occluders and distractors
    parser.add_argument("--occluder_aspect_ratio",
                        type=none_or_str,
                        default="[0.5,2.5]",
                        help="The range of valid occluder aspect ratios")
    parser.add_argument("--distractor_aspect_ratio",
                        type=none_or_str,
                        default="[0.25,5.0]",
                        help="The range of valid distractor aspect ratios")
    parser.add_argument("--occluder_categories",
                        type=none_or_str,
                        default=OCCLUDER_CATS,
                        help="the category ids to sample occluders from")
    parser.add_argument("--distractor_categories",
                        type=none_or_str,
                        default=DISTRACTOR_CATS,
                        help="the category ids to sample distractors from")

    def postprocess(args):
        args.fupforce = handle_random_transform_args(args.fupforce)
        return args

    args = parser.parse_args()
    args = domino_postproc(args)
    args = postprocess(args)

    return args
Пример #11
0
def get_flex_args(dataset_dir: str, parse=True):

    common = get_parser(dataset_dir, get_help=False)
    domino, domino_postproc = get_args(dataset_dir, parse=False)
    parser = ArgumentParser(parents=[common, domino], conflict_handler='resolve', fromfile_prefix_chars='@')

    parser.add_argument("--all_flex_objects",
                        type=int,
                        default=1,
                        help="Whether all rigid objects should be FLEX")
    parser.add_argument("--step_physics",
                        type=int,
                        default=100,
                        help="How many physics steps to run forward after adding a solid FLEX object")
    parser.add_argument("--cloth",
                        action="store_true",
                        help="Demo: whether to drop a cloth")
    parser.add_argument("--squishy",
                        action="store_true",
                        help="Demo: whether to drop a squishy ball")
    parser.add_argument("--fluid",
                        action="store_true",
                        help="Demo: whether to drop fluid")
    parser.add_argument("--fwait",
                        type=none_or_str,
                        default="30",
                        help="How many frames to wait before applying the force")
    parser.add_argument("--collision_label_threshold",
                        type=float,
                        default=0.1,
                        help="Euclidean distance at which target and zone are said to be touching")
    parser.add_argument("--min_distance_ratio",
                        type=float,
                        default=0.5,
                        help="minimum ratio of distance between the anchor and target zone")
    parser.add_argument("--max_distance_ratio",
                        type=float,
                        default=0.5,
                        help="maximum ratio of distance between the anchor and target zone")
    parser.add_argument("--min_anchorloc",
                        type=float,
                        default=-0.4,
                        help="minimum of the two anchor x-locations")
    parser.add_argument("--max_anchorloc",
                        type=float,
                        default=0.4,
                        help="maximum of the two anchor x-locations")
    parser.add_argument("--anchor_height",
                        type=float,
                        default=0.5,
                        help="anchor height")
    parser.add_argument("--anchor_jitter",
                        type=float,
                        default=0.0,
                        help="jitter in anchor locations")
    parser.add_argument("--height_jitter",
                        type=float,
                        default=0.0,
                        help="jitter in anchor heights")

    def postprocess(args):

        args = domino_postproc(args)
        args.all_flex_objects = bool(int(args.all_flex_objects))

        return args

    if not parse:
        return (parser, postproccess)

    args = parser.parse_args()
    args = postprocess(args)

    return args
Пример #12
0
def get_gravity_args(dataset_dir: str, parse=True):

    common = get_parser(dataset_dir, get_help=False)
    domino, domino_postproc = get_args(dataset_dir, parse=False)
    parser = ArgumentParser(parents=[common, domino],
                            conflict_handler='resolve',
                            fromfile_prefix_chars='@')

    # what type of scenario to make it
    parser.add_argument(
        "--middle",
        type=str,
        default="ramp",
        help="comma-separated list of possible middle objects/scenario types")
    parser.add_argument("--num_middle_objects",
                        type=int,
                        default=2,
                        help="The number of middle objects to place")
    parser.add_argument("--mfriction",
                        type=float,
                        default=0.1,
                        help="Static and dynamic friction on middle objects")
    parser.add_argument(
        "--ramp",
        type=int,
        default=1,
        help="Whether to place the probe object on the top of a ramp")
    parser.add_argument("--rheight",
                        type=none_or_str,
                        default=0.5,
                        help="Height of the ramp base")
    parser.add_argument("--rscale",
                        type=none_or_str,
                        default=None,
                        help="The xyz scale of the ramp")
    parser.add_argument("--rcolor",
                        type=none_or_str,
                        default=None,
                        help="The rgb color of the ramp")
    parser.add_argument("--probe",
                        type=str,
                        default="sphere",
                        help="comma-separated list of possible probe objects")
    parser.add_argument("--pscale",
                        type=str,
                        default="0.2",
                        help="scale of probe objects")
    parser.add_argument("--pmass",
                        type=str,
                        default="1.0",
                        help="scale of probe objects")
    parser.add_argument(
        "--foffset",
        type=str,
        default="0.0,0.5,0.0",
        help=
        "offset from probe centroid from which to apply force, relative to probe scale"
    )

    parser.add_argument("--collision_axis_length",
                        type=float,
                        default=2.5,
                        help="How far to put the probe and target")

    # camera
    parser.add_argument("--camera_distance",
                        type=float,
                        default=3.0,
                        help="radial distance from camera to centerpoint")
    parser.add_argument(
        "--camera_min_angle",
        type=float,
        default=0,
        help="minimum angle of camera rotation around centerpoint")
    parser.add_argument(
        "--camera_max_angle",
        type=float,
        default=90,
        help="maximum angle of camera rotation around centerpoint")
    parser.add_argument("--camera_min_height",
                        type=float,
                        default=2.0,
                        help="min height of camera")
    parser.add_argument("--camera_max_height",
                        type=float,
                        default=3.0,
                        help="max height of camera")

    def postprocess(args):

        args = domino_postproc(args)
        args.rheight = handle_random_transform_args(args.rheight)

        return args

    if not parse:
        return (parser, postprocess)

    args = parser.parse_args()
    args = postprocess(args)

    return args