threedworld-mit / tdw

ThreeDWorld simulation environment
BSD 2-Clause "Simplified" License
506 stars 75 forks source link

[Issue] Add your own models to TDW #507

Open hannibal9943 opened 2 years ago

hannibal9943 commented 2 years ago

Hi there,

The TDW based on real to sim transfer for embodied AI is very interesting and great works.

Under the TDW environment, I am testing the following: (1) converting my 3D models(.fbx or .obj) into an asset bundle, (2) adding a scene to TDW.

For test the above, I first ran the example file(local_object.py). As a result of the simulation, the build work generated an error as follows:

################################################################################################## Your installed tdw Python module is up to date with PyPi. Build version 1.10.9 Unity Engine 2020.3.24f1 Python tdw module version 1.10.9 The build quit due to an error. Check the build log for more info. If the build is on the same machine as this controller, the log path is probably C:\Users\argo8\AppData\LocalLow\MIT\TDW\Player.log If the build is on a remote Linux server, the log path is probably ~/.config/unity3d/MIT/TDW/Player.log (where ~ is your home directory)

Error while downloading Asset Bundle: Failed to decompress data for the AssetBundle 'file:///C:\Users\argo8\tdw_example_controller_output\local_object\Windows\cube'. Asset bundle is null: file:///C:\Users\argo8\tdw_example_controller_output\local_object\Windows\cube [TDWInput.AddObject] Tried to create null object. [TDWInput.AddObject] ################################################################################################## If you don't mind, please tell me how to solve the above problem?

Thanks in advance. Player.log

alters-mit commented 2 years ago

@hannibal9943 Please run local_object.py again, then send the Editor log (not the player log)

hannibal9943 commented 2 years ago

Thanks for your kind reply. I send the editor log. log.txt

alters-mit commented 2 years ago

This is the problem:

Building an AssetBundle for target 'LinuxStandaloneSupport' is not allowed because the required module is not installed.

Open Unity Hub, click Installs, and click the three dots:

image

Click Add Modules.

Select Linux BuildSupport and click Done.

Try running local_object.py again.

hannibal9943 commented 2 years ago

I appreciate your quick reply. In accordance with your comments, I added the modules(Linux BuildSupport and etc.). But, I have still the same error. I send the editor log and files.
local_object.zip

If you don't mind, please tell me how to solve the above problem? Thanks in advance. Player.log

alters-mit commented 2 years ago

@hannibal9943 Thanks for uploading the asset bundles. I tried loading them and got the same error. I ran local_object.py on my own machine and the asset bundles are ok.

Can you please run this again and send the Editor log in addition to the log.txt file generated by Asset Bundle Creator?

Additionally, try this:

  1. Run this script:
from pathlib import Path
from tdw.asset_bundle_creator.model_creator import ModelCreator
from tdw.backend.paths import EXAMPLE_CONTROLLER_OUTPUT_PATH

# Change this to the actual path.
source_file = Path.home().joinpath("tdw/Python/example_controllers/3d_models/cube.fbx")
output_directory = EXAMPLE_CONTROLLER_OUTPUT_PATH.joinpath("local_object_cube")
m = ModelCreator()
m.source_file_to_prefab(name="cube",
                        source_file=source_file,
                        output_directory=output_directory)
  1. Open the asset_bundle_creator Unity project in Unity 2020.3.24
  2. Navigate in the Project view to prefabs/ and double-click cube

Result: You should see a cube in the Scene view.

Let me know if something else happens.

alters-mit commented 2 years ago

I tried running this myself. There was a bug, but not the bug you've been having. Try upgrading TDW and asset_bundle_creator and run local_object.py again.

If it still fails, please tell me your OS version and whether you're using an M1.

hannibal9943 commented 2 years ago

Thank you for the friendly words in your comments. First of all, I'm sorry for the late reply because I was so busy that I didn't have time to go over it. With your above mentioned comments, I tried running local_object.py on OS version(Ventura 13.0.1). But, I have still the errors. I send the editor log and files.

source_files.zip local_object.zip Player.log

Thanks in advance.

hiracu commented 1 year ago

I'm getting,

# TDW/Player.log
...
TDW v1.12.15
Unable to read header from archive file: D:/tdw/test/Windows/cube
Failed to read data for the AssetBundle 'cube'.
Asset bundle is null: file:///D:/tdw/test/Windows/cube [TDWInput.AddObject]
Tried to create null object. [TDWInput.AddObject]

while attempting to add_object, very similar to local_object.py

Have the latest, Your installed tdw Python module is up to date with PyPi. Build version 1.12.15 Unity Engine 2020.3.24f1 Python tdw module version 1.12.15.0 Windows 11, python 3.10

I've tried unity: 2020.3.48f1 and 2022.3.11f1, manually converting model (tried both .obj and .fbx) source to asset bundle using the command:

 &"C:\Programs/Unity/Hub/Editor/2022.3.11f1/Editor/Unity.exe" -projectpath "C:/Users/hirak/asset_bundle_creator" -quit -batchmode -executeMethod ModelCreator.SourceFileToAssetBundles -name="cube" -source="C:/Users/hirak/Downloads/Gravel_001_SD-20231025T063244Z-001/untitled.fbx" -output_directory="D:/tdw/test"

# same arguments for Unity version 2020.348f1 

Aborting batchmode due to failure: executeMethod method ModelCreator.SourceFileToAssetBundles threw exception.


 🤷 , hence the direct command

Any idea or hits of cause? 
subalterngames commented 1 year ago

@hiracu Please run your controller again and then attach the Editor log to this GitHub issue.

hiracu commented 1 year ago

Hi @subalterngames ,

After running,

 &"C:\Programs\Unity\Unity 2020.3.48f1\Editor\Unity.exe" -projectpath "C:/Users/hirak/asset_bundle_creator" -quit -batchmode -executeMethod ModelCreator.SourceFileToAssetBundles -name="cube" -source="C:/Users/hirak/Downloads/Gravel_001_SD-20231025T063244Z-001/untitled.obj" -output_directory="D:/tdw/test"

the log is, Editor.log

Thanks

alters-mit commented 1 year ago

@hiracu There are no errors in the log you sent me.

Can you send me your modified local_object.py code?

hiracu commented 1 year ago

@alters-mit , this is the code,

from tdw.asset_bundle_creator.model_creator import ModelCreator
from tdw.controller import Controller
from tdw.add_ons.third_person_camera import ThirdPersonCamera
from tdw.add_ons.image_capture import ImageCapture
from tdw.backend.paths import EXAMPLE_CONTROLLER_OUTPUT_PATH

from platform import system
from pathlib import Path

output_directory = r"D:\tdw\test"
name = "cube"

# Get the path to the asset bundle.
#asset_bundle_path = Path(output_directory).joinpath(system()).joinpath(name)
#uri = f"file:///{str(asset_bundle_path.resolve())}"
uri = "file:///D:/tdw/test/Windows/cube"
#print(asset_bundle_path, uri)

# Launch the controller.
c = Controller()
camera = ThirdPersonCamera(position={"x": 0, "y": 0, "z": -0.6}, avatar_id="a")
capture = ImageCapture(avatar_ids=["a"], path=output_directory)
c.add_ons.extend([camera, capture])
c.communicate([{"$type": "create_empty_environment"},

               {"$type": "add_object", "name": "cube", "url": uri, "scale_factor": 1, "id": c.get_unique_id()},

# test, works
    # {
    #     "$type": "add_object",
    #     "name": "jug02",
    #     "url": "file:///D:/tdw/assets/models/windows/2018-2019.1/jug02",
    #     "scale_factor": 1.0,
    #     # "position": {
    #     #     # "x": 1.1990649221416774,
    #     #     # "y": 0.9167836,
    #     #     # "z": -2.0800465898213116
    #     # },
    #     # "category": "jug",
    #     "id": c.get_unique_id(),#5458180
    # },
                ])

c.communicate({"$type": "terminate"})

On running the script the terminal output (that hangs) is,

...
D:\tdw\test\Windows\cube file:///D:/tdw/test/Windows/cube
Your installed tdw Python module is up to date with PyPi.
Build version 1.12.15
Unity Engine 2020.3.24f1
Python tdw module version 1.12.15.0
The build quit due to an error. Check the build log for more info.
If the build is on the same machine as this controller, the log path is probably C:\Users\hirak\AppData\LocalLow\MIT\TDW\Player.log
If the build is on a remote Linux server, the log path is probably ~/.config/unity3d/MIT/TDW/Player.log (where ~ is your home directory)

# I kill the shell to exit

along with a blank white scene rendered, a/img_0000.jpg.

I tried, Asset Bundle Extractor. I was able to view TDW assets (cube, appliance-ge-profile-microwave_composite) as a test but I couldn't view my cube that was created in SourceFileToAssetBundles. I wonder if there was something wrong with the packaging?

Thanks

hiracu commented 1 year ago

I ran asset bundle creator on Unity 2020.3.24f1 and was able to render image without the error. So it appears, 2020.3.48f1 doesn't work for me. Strange

@alters-mit thanks for your help 🙇