Skip to content

[Bug]: Size of heterogeneous morphs #2750

@stergiosba

Description

@stergiosba

Bug Description

What is the expected way of getting "size" information from a rigid entity with heterogeneous morphs?
Currently setting a rigid body to have two different morphs, a gs.morphs.Box and gs.morphs.Cylinder for example makes the code order dependent and leads to errors as well.

Let's assume that I define the morphs so that the first is a Cylinder and the second is a Box, then obj.morph.size fails.
Now if the morph order is reversed, I only get the size of the box.

Even if we define both morphs to be of type Box, but with different sizes, we only get the size of the first Box.

Question: Is there an example or an expected way of doing this?

Steps to Reproduce

# code that defined size parameters for box and cylinder

# Define the morphs
morphs_heterogeneous = []
for r, h in zip(cylinder_radii, heights):
    morphs_heterogeneous.append(
        gs.morphs.Cylinder(radius=r, height=h)
    )
for w, h in zip(widths, heights):
    morphs_heterogeneous.append(
        gs.morphs.Box(size=(l, w, h))
    )

object = self.scene.add_entity(
    morph=morphs_heterogeneous,
)
# Then much later in the code
object.morph.size <--- raises AttributeError: 'Cylinder' object has no attribute 'size'

But:

# code that defined size parameters for box and cylinder

# Define the morphs
morphs_heterogeneous = []
for w, h in zip(widths, heights):
    morphs_heterogeneous.append(
        gs.morphs.Box(size=(l, w, h))
    )
for r, h in zip(cylinder_radii, heights):
    morphs_heterogeneous.append(
        gs.morphs.Cylinder(radius=r, height=h)
    )

object = self.scene.add_entity(
    morph=morphs_heterogeneous,
)
# Then much later in the code
object.morph.size <--- Returns the specified size of the first box

Expected Behavior

I think the expected behavior here is to get a list of box sizes when all are Box type. And then each primitive should have a similar function let's call it size for now that can be used even with all primitives without raising an AttributeError.

Screenshots/Videos

No response

Relevant log output

Environment

  • OS: Ubuntu 22.04
  • GPU/CPU NVIDIA RTX A5500
  • GPU-driver version (N/A if no GPU) 582
  • CUDA / CUDA-toolkit version (N/A if non-Nvidia) CUDA 12.8

Release version or Commit ID

Genesis version: 0.4.5

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions