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

Unity Car/Drone Demo Crashes #1617

Closed
bugrahanakbulut opened this issue Dec 10, 2018 · 6 comments
Closed

Unity Car/Drone Demo Crashes #1617

bugrahanakbulut opened this issue Dec 10, 2018 · 6 comments
Labels

Comments

@bugrahanakbulut
Copy link

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

@jasonhbartlett
Copy link

Same problem here.

1 similar comment
@MelSoS
Copy link

MelSoS commented Dec 11, 2018

Same problem here.

@msb336
Copy link
Contributor

msb336 commented Dec 14, 2018

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"

@jasonhbartlett
Copy link

jasonhbartlett commented Dec 14, 2018

@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;
        }
companion.vehicleName = "SimpleFlight";

is replaced by:

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:
53cdcde

@MelSoS
Copy link

MelSoS commented Jan 3, 2019

Works perfectly fine, thanks!

@msb336
Copy link
Contributor

msb336 commented Jan 3, 2019

Glad to hear it @MelSoS !
If you have no further problems related to this issue, lets close it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants