I have builded AirSim and builded sample Unity projects. But when I try to run CarDemo or DroneDemo directly, it crashes Unity. But running SimModeSelector, then selecting Car or Drone, does not crash Unity. I need to run CarDemo or DroneDemo directly without SimModeSelector, how can i do that? What can be the reason of crash?
specs: Windows 10, Unity 2018.2.15f1, VS2017 15.8.9, SDK 8.1
Same problem here.
Same problem here.
Unity requires simModeSelector to set necessary parameters for AirSim. The readme has been updated to remove instructions to open DroneDemo or CarDemo scenes directly.
@bugrahanakbulut, if you want to enter a sim mode directly, edit your json file accordingly.
"SimMode" : "Multirotor"
Or:
"SimMode" : "Car"
@msb336
Just wanted to pass along another thing that could cause Unity AirSim to crash and a solution for fixing it. In this case the cause is if your trying to use PX4/SITL vs SimpleFlight. This isn't a problem with Unreal Engine and the setting file works fine if you have your Setting.json file configured for PX4 like so:
{
"SettingsVersion": 1.2,
"SeeDocsAt": "https://github.com/Microsoft/AirSim/blob/master/docs/settings.md",
"SimMode": "Multirotor",
"Vehicles": {
"PX4": {
"VehicleType": "PX4Multirotor"
}
}
}
But this currently causes Unity to crash.
I believe the structs located in AirSim/Unity/UnityDemo/Assets/AirSimAssets/Scripts/Utilities/AirSimSettings.cs script need to be updated to be able to read the "Vehicles" data structure.
But until that happens, as a work around you can add "DefaultVehicleConfig": "PX4" to the settings file, like so:
{
"SettingsVersion": 1.2,
"SeeDocsAt": "https://github.com/Microsoft/AirSim/blob/master/docs/settings.md",
"SimMode": "Multirotor",
"DefaultVehicleConfig": "PX4",
"Vehicles": {
"PX4": {
"VehicleType": "PX4Multirotor"
}
}
}
This does not effect the Unreal, so you can use the same settings for Unreal and Unity.
There is one other thing I found I had to change however. In AirSim/Unity/UnityDemo/Assets/AirSimAssets/Scripts/Vehicles/VehicleCompanion.cs Line 45:
public static VehicleCompanion GetVehicleCompanion(IVehicleInterface vehicleInterface) {
var companion = new VehicleCompanion(vehicleInterface);
if (AirSimSettings.GetSettings().SimMode == "Car")
companion.vehicleName = "PhysXCar";
else if (AirSimSettings.GetSettings().SimMode == "Multirotor")
companion.vehicleName = AirSimSettings.GetSettings().DefaultVehicleConfig;
//Above line replaces // companion.vehicleName = "SimpleFlight";
Vehicles.Add(companion);
return companion;
}
```csharp
companion.vehicleName = "SimpleFlight";
is replaced by:
```csharp
companion.vehicleName = AirSimSettings.GetSettings().DefaultVehicleConfig;
And now I can use Unity AirSim with PX4 Software in the Loop and fly the drone using QGroundControl!!!
But this IS just a band-aid until the AirSimSettings.cs is updated to read the newer structs instead of trying to read DefaultVehicleConfig element which appears to have been removed back on May 17th with the following merge:
53cdcde41a9c325ba34d06b02a45d960bdb543ca
Works perfectly fine, thanks!
Glad to hear it @MelSoS !
If you have no further problems related to this issue, lets close it!
Most helpful comment
Glad to hear it @MelSoS !
If you have no further problems related to this issue, lets close it!