carla: RuntimeError: Unknown error while trying to spawn actor

Carla version: 0.9.11

I tried following the tutorial to add Props to carla here. More specifically, I followed the “Ingestion in a build from source”, i.e., I have a locally compiled Carla, which I run through Unreal Engine.

Added the files to the Import/ folder exactly like the tutorial described:

carla/ –Import/ ----Package01/ ----|–Package01.json ----|–Props/ ----|–|–Ball/ ----|–|–|–Ball.fbx

Package01.json:

{
    "maps": [
    ],
    "props": [
      {
        "name": "Football",
        "size": "small",
        "source": "./Props/Ball/Ball.fbx",
        "tag": "Other"
      }
    ]
  }

Used this object.

I ran make import, make PythonAPI and make launch in this order, and then started simulation inside Unreal Editor.

I tried spawning it (world.spawn_actor()...), even though it finds it on the Blueprint list (with blueprint_library.filter('static.prop.football')[0]), I get an error:

RuntimeError: Unknown error while trying to spawn actor

Also tried exporting it as a package and importing to a pre-compiled carla installation. Got the same error when trying to spawn.

edit: Tried with this object instead now. Didn’t get any error, but I can’t see anything spawned on the map.

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Comments: 15 (1 by maintainers)

Most upvoted comments

Hello all,

I found that I also am having this problem when trying to spawn custom props in shipping (package) mode. The issue for me was that the props were not being cooked by UE4’s UAT script, so the props were unable to be spawned in the package mode. You should be able to check if this is the case for you by seeing if find $SHIPPING_DIR -type f -name '$YOUR_PROP.*' does not return a .uasset and .uexp file.

If this is the case for you, I figured out how to solve this as follows:

  • Place all your custom props in a new directory in the Unreal/CarlaUE4/Content/ directory. For example lets say I create a directory MyProps in Content/
  • Ensure the Default.Package.json file still points to the correct location for all the prop paths:
# example
{
	"name": "my_prop",
	"path": "/Game/MyProps/SM_CustomProp.SM_CustomProp",
	"size": "Big"
}
  • Within the Unreal/CarlaUE4/Config/DefaultGame.ini file add a line like this:
+DirectoriesToAlwaysCook=(Path="/Game/MyProps/")

(Note, this can also be done from within the Editor in ProjectSettings look for “cook” and “additional asset directories”

Then running make package should include these new props in the cooking script.

You should be able to verify this works by ensuring that within the build directory there exists a CarlaUE4/Content/MyProps/SM_CustomProp.uexp file AND a CarlaUE4/Content/MyProps/SM_CustomProp.uasset file. (both are required else it won’t work)

If the above steps didn’t work for you, you might be successful by modifying Util/Build/Package.sh by adding the flags -CookAll -IgnoreCookErrors where the RunUAT.sh BuildCookRun command is being run (line 111 in 0.9.11). (Theoretically the same should translate for Windows .bat’s) which will forcefully cook everything in the Content/ directory, but will take much longer and probably does more than what you want.

After trying both methods, the first (modifying DefaultGame.ini) worked cleanly for me and I can verify that I’m able to spawn my custom props through the PythonAPI as desired while in the shipping (package) mode.

Hope this helps!

I also experienced the same issue and solved it after several tests.Thanks for @GustavoSilvera mentioning the existence of the file *.Package.json, I was able to find out the problem, which is caused by the naming rules-- “Override FullName” of UE4 while importing the .fbx file.

For example, my static mesh name in Blender is "MeshName", and the exported .fbx file is "FbxName.fbx". After importing all files into carla environment following offical instructions, I find that the static mesh name became "FbxName_MeshName" instead of the expected "FbxName" inside the UE4 content folder. My solution is to revise the "FbxName.FbxName" to "FbxName_MeshName.FbxName_MeshName" in the generated *.Package.json file after checking the real name.

All in all, it is important to check the real name of the imported static mesh inside the content folder of UE4, and see if it is the same as in (your_map_name).Package.json file.

(Besides, I cannot just import new props by filling the "props" content and leave the "maps" content empty in the json file, it is necessary for me to add new map files ( .fbx and .xodr) at the same time, otherwise, "import_assets_from_json_list if "tile_size" in maps[0]: IndexError: list index out of range" issue will break the process of importing new props. And I didn’t figure out the reason behind)

Hi folks, You are right, it seems there are some problems when importing props without a map. I’m fixing that.

The problem with the nomenclature adding the FBX name before the asset is because now you can import maps in tiles, and then we need to avoid conflicts between assets with the same name from different tiles, that is why we add the FBX name as a prefix.

Regards

Hi, I was facing the exact same issue when trying to spawn new props and I found a valid workaround (for props at least).

If you look at carla/Unreal/CarlaUE4/Content/Carla/Config/Default.Package.json this file defines a large list of valid props and their static mesh source destinations as spawnable props in CarlaUE4.

With this, I was able to add a new_prop after the last one (Calibrator in 0.9.11) that looked like:

{
	"name": "new_prop",
        "path": "/Game/Carla/Static/Static/SM_new_prop.SM_new_prop",
	"size": "Medium" # or whatever size estimation you'd like
}

Of course ensure you correctly have valid static mesh path file (note that the file does have a .uasset filetype, but in the json you should still denote it as SM_new_prop.SM_new_prop instead of SM_new_prop.uasset).

Then after a quick relaunch of the editor you should be able to now spawn your new_prop from the blueprint library as follows:

bp = list(blueprint_library.filter("static.prop.new_prop"))[0]
transform = world.get_map().get_spawn_points()[0] # or choose any other spawn point
world.spawn_actor(bp, transform) # should succeed with no errors

Note that I’ve only tested this in Town03, and interestingly some of the additional (opt) maps (in 0.9.11) have their own .Package.json files which you might need to modify similarly to reflect in those maps.

I also encountered the issue that make pacakge ARGS="--packages=<package>" does not cook props correctly in 0.9.12. This results in unable to spawn props when being imported to packaged Carla.

The fix for me is to add after this line

MapPathDataLinux.Append(PropsMapPath + TEXT("/PropsMap"));

I believe the cause is the missing PropsMap when cooking for Linux version. Hope it helps!