clvrai / furniture

IKEA Furniture Assembly Environment for Long-Horizon Complex Manipulation Tasks
https://clvrai.com/furniture
MIT License
496 stars 56 forks source link

Converting a new furniture model and XML questions #9

Open iltertaha opened 4 years ago

iltertaha commented 4 years ago

Hello, I want to add a new furniture model. I have read docs and examined several utility files in the environment. However, I couldn't find answers to the questions below.

As I understood from docs, I need a .stl file for each part and one XML file. I decided to use Blender to split my own object into several stl parts, however I don't know whether I should write XML manually or not.

I have some questions related to XML creation.

1) In between the worldbody tags of XML objects, how do you write positions and other informations for each site? For example, in the chair_bernhard_0146.xml below. (Converting a New Furniture Model)

 <body name="1_chair_leg_left" pos="-0.115 0.0 0.1727" quat="1 0 0 0">
            <geom density="100" material="light-wood" mesh="1_chair_leg_left" name="1_chair_leg_left_geom" pos="0 0 0" rgba="0.82 0.71 0.55 1" solref="0.001 1" type="mesh" />
            <site name="leg_left-seat,conn_site1" pos="0.0 0.0 0.1401" quat="0.707 0 -0.707 0" rgba="1 0 1 0.3" size="0.0057" />
            <site name="1_chair_leg_left_corner_site1" pos="-0.019 0.1305 -0.144" rgba="0 0 1 0.3" size="0.0057" />
            <site name="1_chair_leg_left_corner_site2" pos="-0.019 -0.129 -0.144" rgba="0 0 1 0.3" size="0.0057" />
            <site name="1_chair_leg_left_corner_site3" pos="0.0307 0.0230 0.1382" rgba="0 0 1 0.3" size="0.0057" />
            <site name="1_chair_leg_left_corner_site4" pos="0.0307 -0.022 0.1382" rgba="0 0 1 0.3" size="0.0057" />
            <site name="1_chair_leg_left_corner_site5" pos="-0.019 0.0230 0.1382" rgba="0 0 1 0.3" size="0.0057" />
            <site name="1_chair_leg_left_corner_site6" pos="-0.019 -0.022 0.1382" rgba="0 0 1 0.3" size="0.0057" />
            <site name="1_chair_leg_left_bottom_site" pos="-0.019 0.0 -0.134" rgba="0 0 1 0.3" size="0.0057" />
            <site name="1_chair_leg_left_top_site" pos="0.0 0.0 0.1382" rgba="0 0 1 0.3" size="0.0057" />
            <site name="1_chair_leg_left_horizontal_radius_site" pos="-0.019 0.0 0.0" rgba="0 0 1 0.3" size="0.0057" />
        </body>

2) How do you decide the numbers of site's (corner_site1,corner_site2 ...) for each body?

3) If there is a script or tool to form XML files, I will be very happy if you can share with us.

4) There are some files in furniture/blob/dev/env/xml_adjusting/ directory.

I didn't figure out how to use them correctly.Because in addition to position and other details,
rescaling is also important and hard to do with hand.

Thank you for your time.

edwhu commented 4 years ago

Hello, here is the short answer:

  1. Use the xmlTool in Unity Editor to place sites and rotations
  2. This is up to your discretion
  3. Yes, there are tools in the dev branch xml_adjusting folder

Here is an explanation of the scripts. Yes, the XML is generated semi-automatically. Check env/models/assets/objects/incomplete in the dev branch for unconverted furniture. You write the skeleton XML (meshes, bodies) manually, and then use the xmlTool script in Unity Editor to generate the connection sites and collision primitives. Finally, you'll need to run xml_adjusting/color_sites.py to generate the weld inequalities in the xml. You may also want to run rescale.py to rescale, translate, and rotate the furniture.

Try checking out the dev branch, open your Unity Editor to the Empty scene, and then click on the toolbar Window > xmlTools. You can import a skeleton xml from there and use the tool to add connection sites and geometry primitives.

We will update the documentation very soon for an in-depth tutorial on the conversion. We can post a video tutorial as well if it is helpful. Please let me know if you have more detailed questions!

tzuhwan commented 3 years ago

Hi Hueds, I am trying to add my own furniture model as well. I have already written my semi-complete xml file. However I am struggling to open the xml file in Unity Editor, as I cannot find xmlTools under Window on the toolbar. Can you clarify? Thank you!

edwhu commented 3 years ago

Hi, what branch are you using? Maybe some unity script code has changed since then so it no longer shows up.

Can you try checking out the dev branch to a commit around Feb 9, 2020, and try reloading the unity editor? You may need to add xmlTools as a script into unity first as well.

I am not familiar with the new changes, maybe @youngwoon can comment on this?

tzuhwan commented 3 years ago

I've checked out the dev branch, but maybe my issue is that I'm opening Unity Editor through Finder. Are there any scripts that I am supposed to run to open the Unity Editor?

edwhu commented 3 years ago

No, opening the Unity Editor is fine. Did you download the correct version of Unity?

tzuhwan commented 3 years ago

"You may need to add xmlTools as a script into unity first as well."

Sorry I didn't see this. Where can I find the xmlTools script? In xml_adjusting folder I see pycache/init.cpython-37.pyc and rescale.cpython-37.pyc

edwhu commented 3 years ago

If you check out the furniture unity package in dev, there is an xmlTools script in the script folder. When you import the furniture-unity package on the unity editor, it should load this.

https://github.com/clvrai/furniture/tree/dev/furniture-unity/Assets/Scripts

tzuhwan commented 3 years ago

Yes I found the xmltools script, thank you. But to load the furniture-unity package, am I not looking for .unitypackage files? I can't find any of such files.

edwhu commented 3 years ago

From what I remember, you can just select the furniture-unity folder as the project folder for the unity editor.

tzuhwan commented 3 years ago

Yes I did that, but all that I see under Assets > Scenes is just SampleScene. I should be able to find the scripts under Assets right on the unity editor right

edwhu commented 3 years ago

Hmm, my memory is a bit fuzzy. I thought there was some Scripts menu in the menu bar on top of the screen somewhere. Another thing to try is if you load the SampleScene, maybe the xmlTools script is associated with that scene.

I will take a look this weekend if you cannot find the script.

tzuhwan commented 3 years ago

Yea that would be much appreciated hueds! Perhaps a screen recording if possible.

edwhu commented 3 years ago

I was able to open the unity editor, and see the xmltools pane. Can you click the window option on the menubar? Screenshot

tzuhwan commented 3 years ago

Hi Hueds thanks for your help! I can now access xmlTools. Should I select any of the options, or it doesn't really matter?

Next I figure I should import the model, but when I select "Import model", I receive the following exception:

NullReferenceException: Object reference not set to an instance of an object xmlTool.RunImport () (at Assets/Scripts/xmlTool.cs:1048) xmlTool.OnGUI () (at Assets/Scripts/xmlTool.cs:105)

Is there anything that I should change in xmlTool.cs? Currently I have my xml file structured as follows:

<mujoco model="desk_lamp">
    <asset>
        <mesh file="0.stl" name="part0" scale="1 1 1" />
        <mesh file="1.stl" name="part1" scale="1 1 1" />
        <mesh file="2.stl" name="part2" scale="1 1 1" />
    </asset>
    <equality>
        </equality>
    <worldbody>
        <body name="0_part0" pos="0 0 0" quat="1 0 0 0">
        <geom conaffinity="0" contype="0" density="0" mesh="part0" name="0_part0_mesh" pos="0 0 0" rgba="0.82 0.71 0.55 1" type="mesh" />

        </body>
        <body name="1_part1" pos="-0.005 -0.01 0" quat="1 0 0 0">
            <geom conaffinity="0" contype="0" density="0" mesh="part1" name="1_part1_mesh" pos="0 0 0" rgba="0.82 0.71 0.55 1" type="mesh" />
        </body>

        <body name="2_par2" pos="0 0 0.2">
            <geom conaffinity="0" contype="0" density="0" mesh="part2" name="2_part2_mesh" pos="0 0 0" rgba="0.82 0.71 0.55 1" type="mesh" />
        </body>
    </worldbody>
</mujoco>
tzuhwan commented 3 years ago

Hueds please ignore my earlier comment. I am able to(somewhat) generate the sites. However I cannot find xml_adjusting/color_sites.py. Do you mean furniture/xml_adjusting/xml_edit.py? Thanks!

edwhu commented 3 years ago

Hi, that seems correct. from what i remember, color sites would go through the xml file, and add a different color to each conn_site.