robosuite icon indicating copy to clipboard operation
robosuite copied to clipboard

Unexpected behavior when resetting to dynamic states in robosuite 1.4.1 with Libero datasets

Open Kalcy-U opened this issue 1 year ago • 2 comments

I am experiencing unexpected failures when attempting to reset the environment to a dynamic state and continue execution from there.

Environment:

robosuite 1.4.1

Libero dataset and environment

Robot: Panda

Controller: OSC_POSE with control_delta=True

Steps to reproduce / Observations:

When executing demonstration trajectories from the initial environment state, the trajectory is reproduced correctly.

When attempting to start execution from states[x] (a dynamic state, e.g., the robot is moving or grasping an object), there is a high probability that the trajectory cannot be reproduced. The object being manipulated often immediately falls.

    print(f"start at {start_idx}")
    actions=actions[start_idx:]
    # obs = env.set_init_state(states[start_idx])
    env.sim.set_state_from_flattened(states[start_idx])
    env.env.sim.forward()
    for robot in env.env.robots:
        robot.controller.update(True) # To update controller.eef_pose
    env.check_success()
    env._post_process()
    env._update_observables(force=True)
    obs= env.env._get_observations()
    if render:
        obs_list = [obs['agentview_image']]

    dummy_action = np.zeros((7,))

    for i,action in enumerate(actions):

        obs, reward, done, info = env.step(action)

https://github.com/user-attachments/assets/88e7d355-42ca-489f-a969-a639d416cedb

Failed after set state: https://github.com/user-attachments/assets/cf11fe9c-4e5a-458b-aef4-1c2f4af0a2e4

There is another issue as well, and I’m not sure if it’s related to this one. Attempting to stop the robot by sending zero actions (np.zeros((7,0))) results in unexpected motion: after a few steps, the robot moves far away from its previous position (video attached).

    actions , states ,task_id= dataset_manager.get_trajectory_at_index(global_index)
    env,obs=get_benchmark_env( 'libero_10',task_id)
    traj_len = len(states)
    start_idx = int(traj_len * start_percent)
    print(f"start at {start_idx}")
    # obs = env.set_init_state(states[start_idx])
    env.sim.set_state_from_flattened(states[start_idx])
    env.env.sim.forward()
    for robot in env.env.robots:
        robot.controller.update(True) # To update controller.eef_pose
    env.check_success()
    env._post_process()
    env._update_observables(force=True)
    obs= env.env._get_observations()
    if render:
        obs_list = [obs['agentview_image']]

    dummy_action = np.zeros((7,))

    for i in range(200):

        obs, reward, done, info = env.step(dummy_action)
        if render:
            obs_list.append(obs['agentview_image'])
        
        print(f"Step {i}: reward={reward}, done={done}, info={info}")
        print(f"obs{obs['robot0_eef_pos']}")

        if done:
            print(f"done at step{i}")
            break
    save_render_video(obs_list,"replay.mp4",30)
    env.close()

https://github.com/user-attachments/assets/c8f10fe0-9c86-470d-a65a-336f61688e62 Any guidance or suggestions would be greatly appreciated. Thank you!

Kalcy-U avatar Aug 21 '25 10:08 Kalcy-U

Hi, regarding your first issue: (based on the snipper provided) It looks like you are using action playback. Unless you are using the exact same version of mujoco, this behavior is expected as the dynamics are slightly different across versions. Instead of reusing the action, I would reset the state at every timestep. If you want a reference script on playing back the dataset using the states see here

Regarding your second issue. Based of the video, it looks like the robot moves to a specific position then stays still. This suggests to me that somewhere in the code, the action you provided is being interpreted as an absolute command - as the end effector seems to move to zero in absolute coordinates (with respect to the robot base).

Hope this helps!

Abhiram824 avatar Aug 23 '25 21:08 Abhiram824

Closing this for now; feel free to reopen if you have any follow up questions!

Abhiram824 avatar Oct 01 '25 23:10 Abhiram824