ravens/environment.py
def reset(self, task, last_info=None, disable_render_load=True):
        """Sets up PyBullet, loads models, resets the specific task.

        We do a step() call with act=None at the end. This will only return
        an empty obs dict, obs={}. For some tasks where the reward could be
        nonzero at the start, we can report the reward shown here.

        Args:
            last_info: Only for goal-conditioned learning DURING TEST TIME,
                since we load in a target image, but we also want to load in
                final object poses, since in many cases we get better
                accuracy. For simplicity, I suggest we put all this in the
                `info` dict, and we load it as the `info` that happens after
                finishing. That will have the most up to date object poses,
                and we can always add extra information as needed in
                last_info['extras'].
            disable_render_load: Need this as True to avoid `p.loadURDF`
                becoming a time bottleneck, judging from my profiling.
        """
        self.pause()
        self.task = task
        self.objects = []
        self.fixed_objects = []
        if self.use_new_deformable:
            p.resetSimulation(p.RESET_USE_DEFORMABLE_WORLD)
        else:
            p.resetSimulation()
        p.setGravity(0, 0, -9.8)

        # Slightly increase default movej timeout for the more demanding tasks.
        if self.is_bag_env():
            self.t_lim = 60
            if isinstance(self.task, tasks.names['bag-color-goal']):
                self.t_lim = 120

        # Empirically, this seems to make loading URDFs faster w/remote displays.
        if disable_render_load:
            p.configureDebugVisualizer(p.COV_ENABLE_RENDERING, 0)

        id_plane = p.loadURDF('assets/plane/plane.urdf', [0, 0, -0.001])
        id_ws = p.loadURDF('assets/ur5/workspace.urdf', [0.5, 0, 0])

        # Load UR5 robot arm equipped with task-specific end effector.
        self.ur5 = p.loadURDF(f'assets/ur5/ur5-{self.task.ee}.urdf')
        self.ee_tip_link = 12
        if self.task.ee == 'suction':
            self.ee = Suction(self.ur5, 11)
        elif self.task.ee == 'gripper':
            self.ee = Robotiq2F85(self.ur5, 9)
            self.ee_tip_link = 10
        else:
            self.ee = Gripper()

        # Get revolute joint indices of robot (skip fixed joints).
        num_joints = p.getNumJoints(self.ur5)
        joints = [p.getJointInfo(self.ur5, i) for i in range(num_joints)]
        self.joints = [j[0] for j in joints if j[2] == p.JOINT_REVOLUTE]

        # Move robot to home joint configuration.
        for i in range(len(self.joints)):
            p.resetJointState(self.ur5, self.joints[i], self.homej[i])

        # Get end effector tip pose in home configuration.
        ee_tip_state = p.getLinkState(self.ur5, self.ee_tip_link)
        self.home_pose = np.array(ee_tip_state[0] + ee_tip_state[1])

        # Reset end effector.
        self.ee.release()

        # Seems like this should be BEFORE reset()
        # since for bag-items we may assign to True!
        task.exit_gracefully = False

        # Reset task.
        if last_info is not None:
            task.reset(self, last_info)
        else:
            task.reset(self)

        # Daniel: might be useful to have this debugging tracker.
        self.IDTracker = utils.TrackIDs()
        self.IDTracker.add(id_plane, 'Plane')
        self.IDTracker.add(id_ws, 'Workspace')
        self.IDTracker.add(self.ur5, 'UR5')
        try:
            self.IDTracker.add(self.ee.body, 'Gripper.body')
        except:
            pass

        # Daniel: add other IDs, but not all envs use the ID tracker.
        try:
            task_IDs = task.get_ID_tracker()
            for i in task_IDs:
                self.IDTracker.add(i, task_IDs[i])
        except AttributeError:
            pass
        #print(self.IDTracker)  # If doing multiple episodes, check if I reset the ID dict!
        assert id_ws == 1, f'Workspace ID: {id_ws}'

        # Daniel: tune gripper for deformables if applicable, and CHECK HZ!!
        if self.is_softbody_env():
            self.ee.set_def_threshold(threshold=self.task.def_threshold)
            self.ee.set_def_nb_anchors(nb_anchors=self.task.def_nb_anchors)
            assert self.hz >= 480, f'Error, hz={self.hz} is too small!'

        # Restart simulation.
        self.start()
        if disable_render_load:
            p.configureDebugVisualizer(p.COV_ENABLE_RENDERING, 1)
        (obs, _, _, _) = self.step()
        return obs
Sets up PyBullet, loads models, resets the specific task.

        We do a step() call with act=None at the end. This will only return
        an empty obs dict, obs={}. For some tasks where the reward could be
        nonzero at the start, we can report the reward shown here.

        Args:
            last_info: Only for goal-conditioned learning DURING TEST TIME,
                since we load in a target image, but we also want to load in
                final object poses, since in many cases we get better
                accuracy. For simplicity, I suggest we put all this in the
                `info` dict, and we load it as the `info` that happens after
                finishing. That will have the most up to date object poses,
                and we can always add extra information as needed in
                last_info['extras'].
            disable_render_load: Need this as True to avoid `p.loadURDF`
                becoming a time bottleneck, judging from my profiling.
        
Sets up PyBullet, loads models, resets the specific task.
We do a step() call with act=None at the end. This will only return
an empty obs dict, obs={}. For some tasks where the reward could be
nonzero at the start, we can report the reward shown here.
Sets up PyBullet loads models resets the specific task . We do a step () call with act = None at the end . This will only return an empty obs dict obs = {} . For some tasks where the reward could be nonzero at the start we can report the reward shown here .
def reset(self, task, last_info=None, disable_render_load=True):
        self.pause()
        self.task = task
        self.objects = []
        self.fixed_objects = []
        if self.use_new_deformable:
            p.resetSimulation(p.RESET_USE_DEFORMABLE_WORLD)
        else:
            p.resetSimulation()
        p.setGravity(0, 0, -9.8)
        if self.is_bag_env():
            self.t_lim = 60
            if isinstance(self.task, tasks.names['bag-color-goal']):
                self.t_lim = 120
        if disable_render_load:
            p.configureDebugVisualizer(p.COV_ENABLE_RENDERING, 0)
        id_plane = p.loadURDF('assets/plane/plane.urdf', [0, 0, -0.001])
        id_ws = p.loadURDF('assets/ur5/workspace.urdf', [0.5, 0, 0])
        self.ur5 = p.loadURDF(f'assets/ur5/ur5-{self.task.ee}.urdf')
        self.ee_tip_link = 12
        if self.task.ee == 'suction':
            self.ee = Suction(self.ur5, 11)
        elif self.task.ee == 'gripper':
            self.ee = Robotiq2F85(self.ur5, 9)
            self.ee_tip_link = 10
        else:
            self.ee = Gripper()
        num_joints = p.getNumJoints(self.ur5)
        joints = [p.getJointInfo(self.ur5, i) for i in range(num_joints)]
        self.joints = [j[0] for j in joints if j[2] == p.JOINT_REVOLUTE]
        for i in range(len(self.joints)):
            p.resetJointState(self.ur5, self.joints[i], self.homej[i])
        ee_tip_state = p.getLinkState(self.ur5, self.ee_tip_link)
        self.home_pose = np.array(ee_tip_state[0] + ee_tip_state[1])
        self.ee.release()
        task.exit_gracefully = False
        if last_info is not None:
            task.reset(self, last_info)
        else:
            task.reset(self)
        self.IDTracker = utils.TrackIDs()
        self.IDTracker.add(id_plane, 'Plane')
        self.IDTracker.add(id_ws, 'Workspace')
        self.IDTracker.add(self.ur5, 'UR5')
        try:
            self.IDTracker.add(self.ee.body, 'Gripper.body')
        except:
            pass
        try:
            task_IDs = task.get_ID_tracker()
            for i in task_IDs:
                self.IDTracker.add(i, task_IDs[i])
        except AttributeError:
            pass
        assert id_ws == 1, f'Workspace ID: {id_ws}'
        if self.is_softbody_env():
            self.ee.set_def_threshold(threshold=self.task.def_threshold)
            self.ee.set_def_nb_anchors(nb_anchors=self.task.def_nb_anchors)
            assert self.hz >= 480, f'Error, hz={self.hz} is too small!'
        self.start()
        if disable_render_load:
            p.configureDebugVisualizer(p.COV_ENABLE_RENDERING, 1)
        (obs, _, _, _) = self.step()
        return obs
def reset ( self , task , last_info = None , disable_render_load = True ) : self . pause ( ) self . task = task self . objects = [ ] self . fixed_objects = [ ] if self . use_new_deformable : p . resetSimulation ( p . RESET_USE_DEFORMABLE_WORLD ) else : p . resetSimulation ( ) p . setGravity ( 0 , 0 , - 9.8 ) if self . is_bag_env ( ) : self . t_lim = 60 if isinstance ( self . task , tasks . names [ 'bag-color-goal' ] ) : self . t_lim = 120 if disable_render_load : p . configureDebugVisualizer ( p . COV_ENABLE_RENDERING , 0 ) id_plane = p . loadURDF ( 'assets/plane/plane.urdf' , [ 0 , 0 , - 0.001 ] ) id_ws = p . loadURDF ( 'assets/ur5/workspace.urdf' , [ 0.5 , 0 , 0 ] ) self . ur5 = p . loadURDF ( f'assets/ur5/ur5-{self.task.ee}.urdf' ) self . ee_tip_link = 12 if self . task . ee == 'suction' : self . ee = Suction ( self . ur5 , 11 ) elif self . task . ee == 'gripper' : self . ee = Robotiq2F85 ( self . ur5 , 9 ) self . ee_tip_link = 10 else : self . ee = Gripper ( ) num_joints = p . getNumJoints ( self . ur5 ) joints = [ p . getJointInfo ( self . ur5 , i ) for i in range ( num_joints ) ] self . joints = [ j [ 0 ] for j in joints if j [ 2 ] == p . JOINT_REVOLUTE ] for i in range ( len ( self . joints ) ) : p . resetJointState ( self . ur5 , self . joints [ i ] , self . homej [ i ] ) ee_tip_state = p . getLinkState ( self . ur5 , self . ee_tip_link ) self . home_pose = np . array ( ee_tip_state [ 0 ] + ee_tip_state [ 1 ] ) self . ee . release ( ) task . exit_gracefully = False if last_info is not None : task . reset ( self , last_info ) else : task . reset ( self ) self . IDTracker = utils . TrackIDs ( ) self . IDTracker . add ( id_plane , 'Plane' ) self . IDTracker . add ( id_ws , 'Workspace' ) self . IDTracker . add ( self . ur5 , 'UR5' ) try : self . IDTracker . add ( self . ee . body , 'Gripper.body' ) except : pass try : task_IDs = task . get_ID_tracker ( ) for i in task_IDs : self . IDTracker . add ( i , task_IDs [ i ] ) except AttributeError : pass assert id_ws == 1 , f'Workspace ID: {id_ws}' if self . is_softbody_env ( ) : self . ee . set_def_threshold ( threshold = self . task . def_threshold ) self . ee . set_def_nb_anchors ( nb_anchors = self . task . def_nb_anchors ) assert self . hz >= 480 , f'Error, hz={self.hz} is too small!' self . start ( ) if disable_render_load : p . configureDebugVisualizer ( p . COV_ENABLE_RENDERING , 1 ) ( obs , _ , _ , _ ) = self . step ( ) return obs
Sets up PyBullet, loads models, resets the specific task.
Sets up PyBullet loads models resets the specific task .
"""Sets up PyBullet, loads models, resets the specific task.

        We do a step() call with act=None at the end. This will only return
        an empty obs dict, obs={}. For some tasks where the reward could be
        nonzero at the start, we can report the reward shown here.

        Args:
            last_info: Only for goal-conditioned learning DURING TEST TIME,
                since we load in a target image, but we also want to load in
                final object poses, since in many cases we get better
                accuracy. For simplicity, I suggest we put all this in the
                `info` dict, and we load it as the `info` that happens after
                finishing. That will have the most up to date object poses,
                and we can always add extra information as needed in
                last_info['extras'].
            disable_render_load: Need this as True to avoid `p.loadURDF`
                becoming a time bottleneck, judging from my profiling.
        """ # Slightly increase default movej timeout for the more demanding tasks. # Empirically, this seems to make loading URDFs faster w/remote displays. # Load UR5 robot arm equipped with task-specific end effector. # Get revolute joint indices of robot (skip fixed joints). # Move robot to home joint configuration. # Get end effector tip pose in home configuration. # Reset end effector. # Seems like this should be BEFORE reset() # since for bag-items we may assign to True! # Reset task. # Daniel: might be useful to have this debugging tracker. # Daniel: add other IDs, but not all envs use the ID tracker. #print(self.IDTracker)  # If doing multiple episodes, check if I reset the ID dict! # Daniel: tune gripper for deformables if applicable, and CHECK HZ!! # Restart simulation.
self
task
last_info
Only for goal-conditioned learning DURING TEST TIME,
since we load in a target image, but we also want to load in
final object poses, since in many cases we get better
accuracy. For simplicity, I suggest we put all this in the
`info` dict, and we load it as the `info` that happens after
finishing. That will have the most up to date object poses,
and we can always add extra information as needed in
last_info['extras'].
Only for goal - conditioned learning DURING TEST TIME since we load in a target image but we also want to load in final object poses since in many cases we get better accuracy . For simplicity I suggest we put all this in the ` info ` dict and we load it as the ` info ` that happens after finishing . That will have the most up to date object poses and we can always add extra information as needed in last_info [ ' extras ' ] .
disable_render_load
Need this as True to avoid `p.loadURDF`
becoming a time bottleneck, judging from my profiling.
Need this as True to avoid ` p . loadURDF ` becoming a time bottleneck judging from my profiling .