Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor #1

Merged
merged 16 commits into from
Apr 7, 2024
Merged

Refactor #1

merged 16 commits into from
Apr 7, 2024

Conversation

aliberts
Copy link
Collaborator

@aliberts aliberts commented Apr 5, 2024

This integrates gymnasium_robotics.envs.robot_env.MujocoRobotEnv into Base in order for it to not inherit from a gymnasium_robotics.GoalEnv and instead simply be a gym.Env.

It also simplifies a lot of previously entangled code to be much easier to read and comprehend.

Some standard params were added in order to have a similar interface to gym-pusht and aloha:

  • obs_type: select the observation type to be returned by the step:
    • "state": contains agent and object state vectors only (no rendering)
    • "pixels": contains rendered image only (no state vectors)
    • "pixels_agent_pos": contains rendered image and agent state vector
  • observation_width, observation_height: sizes for the observation rendering output by env.step() (to be fed to the policy)
  • visualization_width, visualization_height: sizes for the visualization rendering, used when env.render() is called (for display in eval)

env.render() will render for observation by default ("rgb_array" rendering), and env.render(mode="visualize") will render for visualization.

@aliberts aliberts self-assigned this Apr 5, 2024
@aliberts aliberts requested review from Cadene and qgallouedec April 6, 2024 09:49
@aliberts aliberts marked this pull request as ready for review April 6, 2024 09:50
gym_xarm/tasks/base.py Outdated Show resolved Hide resolved
gym_xarm/tasks/base.py Outdated Show resolved Hide resolved
gym_xarm/tasks/base.py Outdated Show resolved Hide resolved
# see https://gymnasium.farama.org/content/migration-guide/#environment-render
from copy import deepcopy

model = deepcopy(self.model)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tried it? Are the actions applied to self.model forwarded to this copy properly?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes the sizes are set properly, I've checked. I should mention however that sizes are only set when using "rgb_array", but that's because of the way the WindowViewer is set by gym. Also when using "human" because of how the viewer is called the correct "camera0" is not set by default but that's on gym's side, so you have to hit Tab to switch to the correct cam:

Screenshot 2024-04-07 at 14 15 19 Screenshot 2024-04-07 at 14 15 25

gym_xarm/tasks/base.py Outdated Show resolved Hide resolved
@qgallouedec
Copy link
Member

LGTM, well done!

@aliberts aliberts merged commit 08ddd5a into main Apr 7, 2024
1 check passed
@aliberts aliberts deleted the user/aliberts/2024_04_04_refactor branch April 7, 2024 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants