Skip to content

State noise in robot_env.py doesn't actually reach the agent's observation #13

Description

@meowljh

I was running perturbation experiments on FetchReach and noticed that noise_factor="state" has no visible effect on what the agent observes. After digging into the code, I think there's a bug in robot_env.py.

The step() function applies noise to obs["achieved_goal"] (line 178), but then returns obs["observation"] on line 200. For all Fetch environments, _get_obs() in gymnasium-robotics creates achieved_goal as grip_pos.copy() — a completely separate array — so adding noise there doesn't touch observation at all.

# line 178: noise goes here
obs["achieved_goal"] = obs["achieved_goal"] + random.gauss(args.noise_mu, args.noise_sigma)

# line 200: but this is what gets returned
return obs["observation"], reward, terminated, truncated, info

I compared with adroit_door.py (line 335) and kitchen_env.py (line 443)d directly to the returned observation — those work correctly because get_obs() returns a flat ndarray or they modify obs["observation"] directly.

The fix I'd expect is to change line 178 to obs["observation"] = obs["observation"] + noise instead of targeting achieved_goal. This would affect FetchReach/Push/Slide/PickAndPlace and Shadow Hand (anything using robot_env.py's step function).

Let me know if I'm misreading the intent — maybe state noise was supposed to only perturb the goal-achievement signal? But even then, the noisy achieved_goal isn't returned either, so it has no observable effect anywhere.

Also, do you have any plans to add perturbation on dynamics for other tasks? It seems dynamics perturb is only implemented on the locomotion tasks.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions