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

Meshcat-viewer: Scale of .obj meshes gets reset when transformation gets applied #2446

Open
jviereck opened this issue Oct 4, 2024 · 2 comments

Comments

@jviereck
Copy link
Contributor

jviereck commented Oct 4, 2024

I've compiled the latest version of pinocchio from source and the latest meshcat-python package version. The parts of my robot are made of .obj meshes that are scaled to size. When I create a MeshcatVisualizer and load the URDF file, the .obj meshes are displayed, however, the scale seems to be ignored.

Spending some time debugging this, it looks like setting the transform

            # Update viewer configuration.
            self.viewer[visual_name].set_transform(T)

in MeshcatVisualizer::updatePlacements is causing the scaling property to be reset. When I apply the scaling once more like this:

            # Update viewer configuration.
            self.viewer[visual_name].set_transform(T)

            if visual_name in self.scales:
                self.viewer[visual_name].set_property("scale", self.scales[visual_name])

then the scale shows up properly in Meshcat. Here, self.scales is a new dict that stores the scaling values when the objects are created in MeshcatVisualizer::loadViewerGeometryObject.

Does this ring a bell for anyone?

@PepMS
Copy link
Contributor

PepMS commented Nov 8, 2024

Hi there!

I've found the same problem. In my case I'm using negative scale to do symmetric meshes. The negative scale was applied in the case of other visualizer, such as GepettoVisualizer. However, in MeshcatVisualizer it was not considered.

I have not found the code snippet you are mentioning, @jviereck (probably for different versions). However, I believe that something should be changed in updatePlacements. I've done some progress but not solved the problem yet.

BTW, I'm using Pinocchio 3.2.0.

@PepMS
Copy link
Contributor

PepMS commented Nov 8, 2024

By adding these lines, it seems that it works:

scale = visual.meshScale
Tscale = np.identity(4)
Tscale[range(3), range(3)] = np.array(scale)

Ttransform = T @ Tscale

# Update viewer configuration.
self.viewer[visual_name].set_transform(Ttransform)

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