ravens/tasks/defs_bags.py
def _apply_small_force(self, num_iters, fx=10, fy=10, fz=8):
        """A small force to perturb the starting bag."""

        # First bag. Assume that 32 beads are in one bag.
        bead_idx = np.random.randint(len(self.cable_bead_IDs))
        bead_id = self.cable_bead_IDs[bead_idx]
        fx_1 = np.random.randint(low=-fx, high=fx + 1)
        fy_1 = np.random.randint(low=-fy, high=fy + 1)

        # Second bag if necessary.
        if len(self.cable_bead_IDs) > 32:
            assert len(self.cable_bead_IDs) == 64, len(self.cable_bead_IDs)
            if bead_idx < 32:
                bead_idx_2 = np.random.randint(32, len(self.cable_bead_IDs))
            else:
                bead_idx_2 = np.random.randint(0, 32)
            bead_id_2 = self.cable_bead_IDs[bead_idx_2]
            fx_2 = np.random.randint(low=-fx, high=fx + 1)
            fy_2 = np.random.randint(low=-fy, high=fy + 1)

        for _ in range(num_iters):
            p.applyExternalForce(bead_id, linkIndex=-1, forceObj=[fx_1, fy_1, fz],
                                 posObj=[0,0,0], flags=p.LINK_FRAME)
            if len(self.cable_bead_IDs) > 32:
                p.applyExternalForce(bead_id_2, linkIndex=-1, forceObj=[fx_2, fy_2, fz],
                                     posObj=[0,0,0], flags=p.LINK_FRAME)

            if self._debug:
                print(f'Perturbing {bead_id}: [{fx:0.2f}, {fy:0.2f}, {fz:0.2f}]')
A small force to perturb the starting bag.
A small force to perturb the starting bag.
A small force to perturb the starting bag .
def _apply_small_force(self, num_iters, fx=10, fy=10, fz=8):
        bead_idx = np.random.randint(len(self.cable_bead_IDs))
        bead_id = self.cable_bead_IDs[bead_idx]
        fx_1 = np.random.randint(low=-fx, high=fx + 1)
        fy_1 = np.random.randint(low=-fy, high=fy + 1)
        if len(self.cable_bead_IDs) > 32:
            assert len(self.cable_bead_IDs) == 64, len(self.cable_bead_IDs)
            if bead_idx < 32:
                bead_idx_2 = np.random.randint(32, len(self.cable_bead_IDs))
            else:
                bead_idx_2 = np.random.randint(0, 32)
            bead_id_2 = self.cable_bead_IDs[bead_idx_2]
            fx_2 = np.random.randint(low=-fx, high=fx + 1)
            fy_2 = np.random.randint(low=-fy, high=fy + 1)
        for _ in range(num_iters):
            p.applyExternalForce(bead_id, linkIndex=-1, forceObj=[fx_1, fy_1, fz],
                                 posObj=[0,0,0], flags=p.LINK_FRAME)
            if len(self.cable_bead_IDs) > 32:
                p.applyExternalForce(bead_id_2, linkIndex=-1, forceObj=[fx_2, fy_2, fz],
                                     posObj=[0,0,0], flags=p.LINK_FRAME)
            if self._debug:
                print(f'Perturbing {bead_id}: [{fx:0.2f}, {fy:0.2f}, {fz:0.2f}]')
def _apply_small_force ( self , num_iters , fx = 10 , fy = 10 , fz = 8 ) : bead_idx = np . random . randint ( len ( self . cable_bead_IDs ) ) bead_id = self . cable_bead_IDs [ bead_idx ] fx_1 = np . random . randint ( low = - fx , high = fx + 1 ) fy_1 = np . random . randint ( low = - fy , high = fy + 1 ) if len ( self . cable_bead_IDs ) > 32 : assert len ( self . cable_bead_IDs ) == 64 , len ( self . cable_bead_IDs ) if bead_idx < 32 : bead_idx_2 = np . random . randint ( 32 , len ( self . cable_bead_IDs ) ) else : bead_idx_2 = np . random . randint ( 0 , 32 ) bead_id_2 = self . cable_bead_IDs [ bead_idx_2 ] fx_2 = np . random . randint ( low = - fx , high = fx + 1 ) fy_2 = np . random . randint ( low = - fy , high = fy + 1 ) for _ in range ( num_iters ) : p . applyExternalForce ( bead_id , linkIndex = - 1 , forceObj = [ fx_1 , fy_1 , fz ] , posObj = [ 0 , 0 , 0 ] , flags = p . LINK_FRAME ) if len ( self . cable_bead_IDs ) > 32 : p . applyExternalForce ( bead_id_2 , linkIndex = - 1 , forceObj = [ fx_2 , fy_2 , fz ] , posObj = [ 0 , 0 , 0 ] , flags = p . LINK_FRAME ) if self . _debug : print ( f'Perturbing {bead_id}: [{fx:0.2f}, {fy:0.2f}, {fz:0.2f}]' )
A small force to perturb the starting bag.
A small force to perturb the starting bag .
"""A small force to perturb the starting bag.""" # First bag. Assume that 32 beads are in one bag. # Second bag if necessary.
self
num_iters
fx
fy
fz