Skip to content

Question regarding the reset logic in the prepare function #43

Description

@cxmzdd

First of all, thank you for open-sourcing this excellent work.
I have a question regarding the prepare function. I noticed that traj_len is set to 1000, and a reset operation is triggered when t == 0.9 * traj_len.
Does this imply that the first 100 frames of the reference motion are effectively skipped? I was wondering if you could elaborate on the rationale behind this design choice?

    def prepare(self, init_motor_angle=None):
        if init_motor_angle is not None:
            desired_motor_angle = init_motor_angle
        else:
            desired_motor_angle = self.policy.get_init_dof_pos()


        # logger.info(f"{desired_motor_angle=}")
        current_motor_angle = np.array(self.env.dof_pos)
        # logger.info(f"{current_motor_angle=}")


        traj_len = 1000
        last_step_time = time.time()
        logger.warning("prepare_init")
        pbar = ProgressBar("Prepare", traj_len)


        for t in range(traj_len):
            current_motor_angle = np.array(self.env.dof_pos)


            blend_ratio = np.minimum(t / 300, 1)
            action = (1 - blend_ratio) * current_motor_angle + blend_ratio * desired_motor_angle


            # warm up network
            self.step(dry_run=True)


            self.env.step(action)


            time_diff = last_step_time + self.dt - time.time()
            if time_diff > 0:
                time.sleep(time_diff)
            else:
                logger.error("Warning: frame drop")
            last_step_time = time.time()
            pbar.update()


            if t == 0.9 * traj_len:
                logger.info(f"{'=' * 10} RESET ZERO POSITION {'=' * 10}")
                self.reset()


        time.sleep(0.01)
        pbar.close()
        logger.warning("prepare_done")

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions