Skip to content

Add set_scale to Arena and MujocoObject - #643

Merged
kevin-thankyou-lin merged 17 commits into
masterfrom
enable-scale-setting-arena
Jul 18, 2025
Merged

Add set_scale to Arena and MujocoObject #643
kevin-thankyou-lin merged 17 commits into
masterfrom
enable-scale-setting-arena

Conversation

@kevin-thankyou-lin

@kevin-thankyou-lin kevin-thankyou-lin commented Feb 25, 2025

Copy link
Copy Markdown
Contributor

What this does

Add ability to set_scale of bodies in arena, as well as set_scale for MujocoObjects; previously only MujocoXMLObject had these functions.

How to test

In _load_arena() add something like:

        table = mujoco_arena.worldbody.find("./body[@name='table']")
        mujoco_arena.set_scale([0.5, 0.5, 0.5], table)

scale=0.5
tmp0

scale=1.5
tmp0

@kevin-thankyou-lin kevin-thankyou-lin changed the title Add scale setting and saving in arena Add set_scale to Arena and MujocoObject Feb 27, 2025
@Abhiram824

Copy link
Copy Markdown
Member

Any reason why you can't just move the code to a parent class? Seems like its repeated across 3 classes.

@kevin-thankyou-lin

Copy link
Copy Markdown
Contributor Author

Refactored @Abhiram824 could you please take a look?

# Choose what to do based on elements type
if isinstance(elements, str):
# We simply return the value of this single element
assert element_type in {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can we keep the assert

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread robosuite/utils/mjcf_utils.py Outdated
scale_array = normalize_scale_array(scale)

# Scale geoms
geom_pairs = get_geoms_func(obj)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why do we need to treat geoms differently with the get_geoms_func? why cant we just do get_elements_func(obj, "geom") Also should we move the _get_elements to mjcf_utils.py?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@Abhiram824 Abhiram824 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks mostly good, left some comments mainly to refactor code

@Abhiram824 Abhiram824 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@kevin-thankyou-lin
kevin-thankyou-lin merged commit 4062cb4 into master Jul 18, 2025
ShahRutav pushed a commit to ShahRutav/robosuite that referenced this pull request Dec 31, 2025
* Add scale setting and saving in arena

* Require obj param for set_scale in arena

* Update interface of set_scale in arena

* Update set_scale object indexing

* Format

* Improve logging if invalid object to scale

* Add option to set_scale of MujocoObjects

* Format

* Refactor scale setting code

* format

* refactor

* re-add assert to get_ids

* Format

* Format
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

Successfully merging this pull request may close these issues.

2 participants