perezjln / gym-lowcostrobot

Other
30 stars 18 forks source link

pip install doesn't seem to include the assets folder. #23

Closed ResourceHog closed 4 months ago

ResourceHog commented 5 months ago

Python version: 3.12.2 OS: Windows 11 Steps to reproduce: Create a venv with python -m venv venv Activate the venv ./venv/Scripts/Activate Install the repo: pip install git+https://github.com/perezjln/gym-lowcostrobot.git

Create a file app.py

import gymnasium as gym
import gym_lowcostrobot # Import the low-cost robot environments

# Create the environment
env = gym.make("PickPlaceCube-v0", render_mode="human")

# Reset the environment
observation, info = env.reset()

for _ in range(1000):
    # Sample random action
    action = env.action_space.sample()

    # Step the environment
    observation, reward, terminted, truncated, info = env.step(action)

    # Reset the environment if it's done
    if terminted or truncated:
        observation, info = env.reset()

# Close the environment
env.close()

run the file python -m app

result:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\<censored>\Desktop\projects\Low Cost Robot\Gym\app.py", line 5, in <module>
    env = gym.make("PickPlaceCube-v0", render_mode="human")
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\<censored>\Desktop\projects\Low Cost Robot\Gym\venv\Lib\site-packages\gymnasium\envs\registration.py", line 802, in make
    env = env_creator(**env_spec_kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\<censored>\Desktop\projects\Low Cost Robot\Gym\venv\Lib\site-packages\gym_lowcostrobot\envs\pick_place_cube_env.py", line 80, in __init__
    self.model = mujoco.MjModel.from_xml_path(os.path.join(ASSETS_PATH, "pick_place_cube.xml"), {})
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: mjParseXML: resource not found via provider or OS filesystem: 'C:\Users\<censored>\Desktop\projects\Low Cost Robot\Gym\venv\Lib\site-packages\gym_lowcostrobot\assets/low_cost_robot_6dof\pick_place_cube.xml'
perezjln commented 4 months ago

Hi @ResourceHog , thanks for the feedback. @qgallouedec - I'm checking it today, surprising.

qgallouedec commented 4 months ago

Yeah it's because Windows uses \ instead of /. @perezjln, you should replace

https://github.com/perezjln/gym-lowcostrobot/blob/0b542db687340aae294d3895cf91c8bf225e6df8/gym_lowcostrobot/__init__.py#L7

by

ASSETS_PATH = os.path.join(os.path.dirname(__file__), "assets", "low_cost_robot_6dof")
perezjln commented 4 months ago

https://github.com/perezjln/gym-lowcostrobot/commit/baef4e9f04016a14a0ce3f88b4676f4a0da1525c