google-deepmind / dm_control

Google DeepMind's software stack for physics-based simulation and Reinforcement Learning environments, using MuJoCo.
Apache License 2.0
3.63k stars 647 forks source link

Removing dclass-attribute #478

Open ajoardar007 opened 2 weeks ago

ajoardar007 commented 2 weeks ago

Hello,

I am trying to remove class attributes as it is unnecessary for joints in my use-case.

When I try to use the del command example:

joints = mjcf_model.find_all('joint')
# Remove class-attribute from 'joint' heading
for joint in joints:
   if type(joint.dclass) is str:
      del joint.dclass

, I get the following error:

Traceback (most recent call last):
  File "/home/arnab/UWARL_catkin_ws/src/uwarl-mujoco-summit-wam-sim/src/main_rob_dup.py", line 817, in <module>
    del joints[0].dclass
  File "/home/arnab/.local/lib/python3.8/site-packages/dm_control/mjcf/element.py", line 711, in __delattr__
    raise AttributeError('object has no attribute: {}'.format(name))
AttributeError: object has no attribute: dclass

I need to remove the custom-named classes that the script generates as MuJoCo 2.2.x (Ubuntu 20.04) gives me errors when it is presented with:

<default class="smt_0\\front\\camera\\intel\"/>

, but not with this:

<default class="smt_0\\front\\camera\\intel\"></default>
yuvaltassa commented 2 weeks ago

try joint.dclass = '' ?

ajoardar007 commented 2 weeks ago

That will not remove the entry. It looks like it is a required field and it will be populated regardless.

The same holds true for the field name under geom: some places I have given a name, while at others I did not provide.

In essence, my feedback for further improvement would be to:

It would also be great if we can turn-off the auto-appending of names of the previous bodies in a kinematic-chain onto the next connected-body's name if the authors are taking care to keep the names unique (as natively required by MuJoCo). This scripts allows us to treat the building of kinemaic-chains as function-calls, like xacro-files for Gazebo; and, just like xacro-files, we can send custom-prefix's over a function-call to keep names unique whenever required.