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

Issue importing deformable cloth object #466

Open
VijayGKR opened this issue Mar 31, 2024 · 1 comment
Open

Issue importing deformable cloth object #466

VijayGKR opened this issue Mar 31, 2024 · 1 comment

Comments

@VijayGKR
Copy link

Hello Robosuite Team,

I'm having issues importing a deformable cloth object. The xml file I'm using to define the object is below:

<mujoco>
    <asset>
        <texture name="texcorner4" type="2d" file="blue-wood.png"/>
        <material name="matcorner4" texture="texcorner4"/>
    </asset>
  <worldbody>
    <body>
        <body name="object">
        <body name="B3_5">
        <composite prefix='' type="cloth" count="9 9 1" spacing="0.03" flatinertia="0.01">
            <joint kind="main" damping="0.002"/>
            <skin material="matcorner4" texcoord="true" inflate="0.005" subgrid="2"/>
            <geom type="capsule" size="0.0075 0.005" rgba=".8 .2 .1 1" group="0"/>
        </composite>
        </body>
        </body>
        <site rgba="0 0 0 0" size="0.005" pos="0 0 -0.007" name="bottom_site"/>
        <site rgba="0 0 0 0" size="0.005" pos="0 0 0.007" name="top_site"/>
        <site rgba="0 0 0 0" size="0.005" pos="0.2 0.2 0" name="horizontal_radius_site"/>
    </body>
  </worldbody>
</mujoco>

The code where I initialize the environment and attempt to render the environment (main.py) crashes and results in this:

Traceback (most recent call last):
  File "/Users/vijaykumaravelrajan/PycharmProjects/pythonProject4/main.py", line 108, in <module>
    env = suite.make(
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/robosuite/environments/base.py", line 42, in make
    return REGISTERED_ENVS[env_name](*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/robosuite/environments/manipulation/stack.py", line 183, in __init__
    super().__init__(
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/robosuite/environments/manipulation/manipulation_env.py", line 162, in __init__
    super().__init__(
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/robosuite/environments/robot_env.py", line 214, in __init__
    super().__init__(
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/robosuite/environments/base.py", line 139, in __init__
    self._initialize_sim()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/robosuite/environments/base.py", line 235, in _initialize_sim
    self.sim = MjSim.from_xml_string(xml)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/robosuite/utils/binding_utils.py", line 1073, in from_xml_string
    model = mujoco.MjModel.from_xml_string(xml)
ValueError: XML Error: Schema violation: unrecognized attribute: 'name'

Element 'geom', line 374

Below is the code for the initialization of the cloth object and a modified stack task importing the object:

# create environment instance
class ClothObject(MujocoXMLObject):
    def __init__(self, name):
        super().__init__("cloth.xml",
                            name=name)

class Stack(suite.Stack):
    def _load_model(self):
            """
            Loads an xml model, puts it in self.model
            """
            super()._load_model()

            # Adjust base pose accordingly
            xpos = self.robots[0].robot_model.base_xpos_offset["table"](self.table_full_size[0])
            self.robots[0].robot_model.set_base_xpos(xpos)

            # load model for table top workspace
            mujoco_arena = TableArena(
                table_full_size=self.table_full_size,
                table_friction=self.table_friction,
                table_offset=self.table_offset,
            )

            # Arena always gets set to zero origin
            mujoco_arena.set_origin([0, 0, 0])

            self.clothB = ClothObject(name = "testCLoth")


            objects = [self.clothB]

            # Create placement initializer
            if self.placement_initializer is not None:
                self.placement_initializer.reset()
                self.placement_initializer.add_objects(objects)
            else:
                self.placement_initializer = UniformRandomSampler(
                    name="ObjectSampler",
                    mujoco_objects=objects,
                    x_range=[-3, 3],
                    y_range=[-3, 3],
                    rotation=None,
                    ensure_object_boundary_in_range=False,
                    ensure_valid_placement=True,
                    reference_pos=self.table_offset,
                    z_offset=0.01,
                )

            # task includes arena, robot, and objects of interest
            self.model = ManipulationTask(
                mujoco_arena=mujoco_arena,
                mujoco_robots=[robot.robot_model for robot in self.robots],
                mujoco_objects=objects,
            )

Has this issue been resolved since this previous issue report?
#276

@kevin-thankyou-lin
Copy link
Contributor

As a sanity check, since the underlying simulation uses mujoco, can you try loading the xml inside mujoco first?

python -m mujoco.viewer --mjcf=/path/to/some/mjcf.xml here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants