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

flexcomp object cannot be created #457

Closed
bakehamster opened this issue Apr 1, 2024 · 0 comments
Closed

flexcomp object cannot be created #457

bakehamster opened this issue Apr 1, 2024 · 0 comments

Comments

@bakehamster
Copy link

bakehamster commented Apr 1, 2024

Hi guys,

Currently, I am encountering an issue with creating a flexcomp object using dm_control/mjcf. When I attempted to load this model.

<mujoco model="deformable_sphere">
	
	<option timestep="0.01" solver="CG"/>
	
    <extension>
        <plugin plugin="mujoco.elasticity.solid"/>
    </extension>

    <worldbody>
		<geom size=".2 .2 .5" type="plane" />
		<light pos="0 0 .6"/>
		<camera name="closeup" pos="0 -.1 .07" xyaxes="1 0 0 0 1 2"/>
		<body name="alma">
			<flexcomp name="ball" dim="3" type="gmsh" rgba=".8 .2 .2 1" radius="0.25" pos="0 0 4" mass="1" file="valid_path.msh">
				<edge equality="true"/>
				<plugin plugin="mujoco.elasticity.solid"></plugin>
				<contact selfcollide="none" condim="3"/>
			</flexcomp>
		</body>
    </worldbody>
</mujoco>

I tried to load it in two different ways.
I've tried to create it with mjcf.

env_mjcf = mjcf.RootElement(model="scene")


env_mjcf.option.timestep = 0.01
env_mjcf.option.solver = "CG"

env_mjcf.extension.add(
    "plugin",
    plugin="mujoco.elasticity.solid"
)

flexcomp = env_mjcf.worldbody.add(
        "flexcomp",
        name="ball",
        type="gmsh",
        radius=0.25,
        pos=[0, 0, 4.75],
        mass=1,
        dim=3,
        file="valid_ath"

    )
flexcomp.add("contact", selfcollide=None, condim="3")
flexcomp.add("plugin", plugin="mujoco.elasticity.solid")

The other way was simply loading it from a file.

ball = mjcf.from_file("valid_path")
env_mjcf.attach(ball)

I successfully loaded my model into a standalone mujoco.viewer, and it worked fine. However, when attempting to load it with mjcf, the following problem occurred:

dm_control\mjcf\element.py", line 534, in _check_valid_attribute
raise AttributeError(AttributeError: Line 14: error while parsing element <flexcomp>: 'dim' is not a valid attribute for <flexcomp>)

But when I checked the Mujoco documentation, it clearly specifies a dim parameter. Mujoco documentation.
I've tried with and without the body flag, but the dim parameter must be defined either way.

Any idea about the problem?

This is the gmsh mesh which I wanted to load sphere_basic_text.txt.

Mujoco: 3.1.3
dm_control: 1.0.17
Python: 3.11

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

1 participant