コード例 #1
0
    def __init__(self, port: int = 1071,
                 all_flex_objects=True,
                 use_cloth=False,
                 use_squishy=False,
                 use_fluid=False,
                 step_physics=False,
                 middle_scale_range=0.5,
                 **kwargs):

        Dominoes.__init__(self, port=port, **kwargs)
        self._clear_flex_data()

        self.all_flex_objects = all_flex_objects
        self._set_add_physics_object()

        self.step_physics = step_physics
        self.use_cloth = use_cloth
        self.use_squishy = use_squishy
        self.use_fluid = use_fluid

        self.middle_scale_range = middle_scale_range
        print("MIDDLE SCALE RANGE", self.middle_scale_range)

        if self.use_fluid:
            self.ft_selection = random.choice(self.FLUID_TYPES.fluid_type_names)
コード例 #2
0
ファイル: contain.py プロジェクト: neuroailab/tdw_physics
    def clear_static_data(self) -> None:
        Dominoes.clear_static_data(self)

        self.tower_height = 0.0
        self.target_link_idx = None
        self.base = None
        self.attachment = None
コード例 #3
0
    def _write_static_data(self, static_group: h5py.Group) -> None:
        Dominoes._write_static_data(self, static_group)

        static_group.create_dataset("base_id", data=self.base_id)
        static_group.create_dataset("use_base", data=self.use_base)        
        static_group.create_dataset("base_type", data=self.base_type)
        static_group.create_dataset("attachment_id", data=self.attachment_id)
        static_group.create_dataset("attachent_type", data=self.attachment_type)
        static_group.create_dataset("use_attachment", data=self.use_attachment)                
        static_group.create_dataset("link_type", data=self.middle_type)
        static_group.create_dataset("num_links", data=self.num_links)        
        static_group.create_dataset("target_link_idx", data=self.target_link_idx)
        static_group.create_dataset("attachment_fixed", data=self.attachment_fixed_to_base)
        static_group.create_dataset("use_cap", data=self.use_cap)                        
コード例 #4
0
    def get_scene_initialization_commands(self) -> List[dict]:

        commands = Dominoes.get_scene_initialization_commands(self)
        commands[0].update({'convexify': True})
        create_container = {
            "$type": "create_flex_container",
            # "collision_distance": 0.001,
            "collision_distance": 0.025,
            # "collision_distance": 0.1,
            "static_friction": 1.0,
            "dynamic_friction": 1.0,
            "radius": 0.1875,
            'max_particles': 50000}
            # 'max_particles': 250000}

        if self.use_fluid:
            create_container.update({
                'viscosity': self.FLUID_TYPES.fluid_types[self.ft_selection].viscosity,
                'adhesion': self.FLUID_TYPES.fluid_types[self.ft_selection].adhesion,
                'cohesion': self.FLUID_TYPES.fluid_types[self.ft_selection].cohesion,
                'fluid_rest': 0.05,
                'damping': 0.01,
                'subsetp_count': 5,
                'iteration_count': 8,
                'buoyancy': 1.0})

        commands.append(create_container)

        if self.use_fluid:
            commands.append({"$type": "set_time_step", "time_step": 0.005})

        return commands
コード例 #5
0
    def _place_ramp_under_probe(self) -> List[dict]:

        cmds = Dominoes._place_ramp_under_probe(self)
        self.non_flex_objects.append(self.ramp_id)
        if self.ramp_base_height >= 0.01:
            self.non_flex_objects.append(self.ramp_base_id)
        return cmds
コード例 #6
0
ファイル: drape.py プロジェクト: neuroailab/tdw_physics
    def __init__(self, port: int = 1071,
                 all_flex_objects=True,
                 use_cloth=False,
                 use_squishy=False,
                 use_fluid=False,
                 step_physics=False,
                 tether_stiffness_range = [0.0, 1.0],
                 bend_stiffness_range = [0.0, 1.0],#[0.0, 1.0],
                 stretch_stiffness_range = [0.0, 1.0],
                 min_distance_ratio = 0.5,
                 max_distance_ratio = 0.5,
                 min_anchorloc = -0.4,
                 max_anchorloc = 0.4,
                 anchor_height = 0.5,
                 anchor_jitter = 0.2,#0.2,
                 height_jitter = 0.2,#0.3,
                 collision_label_threshold=0.1,
                 **kwargs):

        Dominoes.__init__(self, port=port, **kwargs)
        self._clear_flex_data()

        self.all_flex_objects = all_flex_objects
        self._set_add_physics_object()

        self.step_physics = step_physics
        self.use_cloth = use_cloth
        self.use_squishy = use_squishy
        self.use_fluid = use_fluid

        if self.use_fluid:
            self.ft_selection = random.choice(self.FLUID_TYPES.fluid_type_names)

        self.tether_stiffness_range = tether_stiffness_range
        self.bend_stiffness_range = bend_stiffness_range
        self.stretch_stiffness_range = stretch_stiffness_range
        self.min_distance_ratio = min_distance_ratio
        self.max_distance_ratio = max_distance_ratio
        self.min_anchorloc = min_anchorloc
        self.max_anchorloc = max_anchorloc
        self.anchor_height = anchor_height
        self.anchor_jitter = anchor_jitter
        self.height_jitter = height_jitter

        # for detecting collisions
        self.collision_label_thresh = collision_label_threshold
コード例 #7
0
ファイル: contain.py プロジェクト: neuroailab/tdw_physics
    def _write_frame_labels(
            self, frame_grp: h5py.Group, resp: List[bytes], frame_num: int,
            sleeping: bool) -> Tuple[h5py.Group, List[bytes], int, bool]:

        labels, resp, frame_num, done = Dominoes._write_frame_labels(
            self, frame_grp, resp, frame_num, sleeping)

        return labels, resp, frame_num, done
コード例 #8
0
 def _get_push_cmd(self, o_id, position_or_particle=None):
     if not self.all_flex_objects:
         return Dominoes._get_push_cmd(self, o_id, position_or_particle)
     cmd = {"$type": "apply_force_to_flex_object",
            "force": self.push_force,
            "id": o_id,
            "particle": -1}
     print("PUSH CMD FLEX")
     print(cmd)
     return cmd
コード例 #9
0
ファイル: gravity.py プロジェクト: neuroailab/tdw_physics
    def __init__(self,
                 port: int = 1071,
                 middle_scale_range=1.0,
                 middle_color=None,
                 middle_material=None,
                 middle_friction=0.1,
                 remove_middle=False,
                 **kwargs):

        Dominoes.__init__(self, port=port, **kwargs)

        # always use a ramp for probe
        self.use_ramp = True

        # middle
        self.middle_color = middle_color
        self.middle_material = middle_material
        self.middle_friction = middle_friction
        self.middle_objects = []
        self.remove_middle = remove_middle
コード例 #10
0
    def get_controller_label_funcs(classname="Tower"):
        funcs = Dominoes.get_controller_label_funcs(classname)

        def num_middle_objects(f):
            try:
                return int(np.array(f['static']['num_blocks']))
            except KeyError:
                return int(len(f['static']['mass'] - 3))

        def did_tower_fall(f):
            return is_trial_valid(f, valid_key='did_fall')

        funcs += [num_middle_objects, did_tower_fall]

        return funcs
コード例 #11
0
    def add_rigid_physics_object(self, *args, **kwargs):
        """
        Make sure controller knows to treat probe, zone, target, etc. as non-flex objects
        """

        o_id = kwargs.get('o_id', None)
        if o_id is None:
            o_id: int = self.get_unique_id()
            kwargs['o_id'] = o_id

        commands = Dominoes.add_physics_object(self, *args, **kwargs)
        self.non_flex_objects.append(o_id)

        print("Add rigid physics object", o_id)

        return commands
コード例 #12
0
 def clear_static_data(self) -> None:
     Dominoes.clear_static_data(self)
コード例 #13
0
ファイル: link.py プロジェクト: neuroailab/tdw_physics
    def get_controller_label_funcs(classname = "Linking"):
        funcs = Dominoes.get_controller_label_funcs(classname)

        return funcs
コード例 #14
0
ファイル: barriers.py プロジェクト: felixbinder/tdw_physics
    def get_controller_label_funcs(classname = "Barrier"):

        funcs = Dominoes.get_controller_label_funcs(classname)

        return funcs
コード例 #15
0
    def get_trial_initialization_commands(self) -> List[dict]:

        # clear the flex data
        FlexDataset.get_trial_initialization_commands(self)
        return Dominoes.get_trial_initialization_commands(self)
コード例 #16
0
 def _get_send_data_commands(self) -> List[dict]:
     commands = Dominoes._get_send_data_commands(self)
     commands.extend(FlexDataset._get_send_data_commands(self))
     return commands
コード例 #17
0
ファイル: barriers.py プロジェクト: felixbinder/tdw_physics
    def _write_static_data(self, static_group: h5py.Group) -> None:
        Dominoes._write_static_data(self, static_group)

        static_group.create_dataset("bridge_height", data=self.bridge_height)
コード例 #18
0
ファイル: gravity.py プロジェクト: neuroailab/tdw_physics
 def _write_static_data(self, static_group: h5py.Group) -> None:
     Dominoes._write_static_data(self, static_group)
     self.middle_type = type(self).__name__
     static_group.create_dataset("middle_type", data=self.middle_type)
コード例 #19
0
 def _write_static_data(self, static_group: h5py.Group) -> None:
     Dominoes._write_static_data(self, static_group)
コード例 #20
0
    def _place_target_object(self) -> List[dict]:

        self._fixed_target = True
        return Dominoes._place_target_object(
            self, size_range=self.target_scale_range)
コード例 #21
0
ファイル: contain.py プロジェクト: neuroailab/tdw_physics
    def get_controller_label_funcs(classname="Containment"):
        funcs = Dominoes.get_controller_label_funcs(classname)

        return funcs
コード例 #22
0
 def _place_and_push_probe_object(self) -> List[dict]:
     return Dominoes._place_and_push_probe_object(
         self, size_range=self.probe_scale_range)
コード例 #23
0
ファイル: contain.py プロジェクト: neuroailab/tdw_physics
    def get_per_frame_commands(self, resp: List[bytes],
                               frame: int) -> List[dict]:

        cmds = Dominoes.get_per_frame_commands(self, resp=resp, frame=frame)

        return cmds
コード例 #24
0
    def get_controller_label_funcs(classname="Collision"):

        funcs = Dominoes.get_controller_label_funcs(classname)

        return funcs
コード例 #25
0
    def get_controller_label_funcs(classname = "Rolling_Sliding"):

        funcs = Dominoes.get_controller_label_funcs(classname)

        return funcs