From 188708f77001c68dc4dfbb0ac84b302adacfc127 Mon Sep 17 00:00:00 2001 From: David Zimmermann Date: Mon, 25 Jan 2021 10:04:33 -0800 Subject: [PATCH 1/2] fix UnityDemo build This fixes the DllImport of InitVehicleManager so that it matches the method signature in the AirLibWrapper --- .../Scripts/Utilities/PInvokeWrapper.cs | 5 +++-- .../Scripts/Vehicles/IVehicleInterface.cs | 4 ++++ .../Assets/AirSimAssets/Scripts/Vehicles/Vehicle.cs | 12 ++++++++++++ .../Scripts/Vehicles/VehicleCompanion.cs | 13 +++++++++++++ 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/Unity/UnityDemo/Assets/AirSimAssets/Scripts/Utilities/PInvokeWrapper.cs b/Unity/UnityDemo/Assets/AirSimAssets/Scripts/Utilities/PInvokeWrapper.cs index 8f156909ce..8df024defe 100644 --- a/Unity/UnityDemo/Assets/AirSimAssets/Scripts/Utilities/PInvokeWrapper.cs +++ b/Unity/UnityDemo/Assets/AirSimAssets/Scripts/Utilities/PInvokeWrapper.cs @@ -13,8 +13,9 @@ public static class PInvokeWrapper { [DllImport(DLL_NAME)] public static extern void InitVehicleManager(IntPtr SetPose, IntPtr GetPose, IntPtr GetCollisionInfo, IntPtr GetRCData, IntPtr GetSimImages, IntPtr SetRotorSpeed, IntPtr SetEnableApi, IntPtr SetCarApiControls, IntPtr GetCarState, - IntPtr GetCameraInfo, IntPtr SetCameraPose, IntPtr SetCameraFoV, IntPtr SetSegmentationObjectid, IntPtr GetSegmentationObjectId, - IntPtr PrintLogMessage, IntPtr GetTransformFromUnity, IntPtr Reset, IntPtr GetVelocity, IntPtr GetRayCastHit, IntPtr Pause); + IntPtr GetCameraInfo, IntPtr SetCameraPose, IntPtr SetCameraFoV, IntPtr setDistortionParam, IntPtr getDistortionParams, + IntPtr setSegmentationObjectId, IntPtr getSegmentationObjectId, IntPtr PrintLogMessage, IntPtr GetTransformFromUnity, + IntPtr Reset, IntPtr GetVelocity, IntPtr GetRayCastHit, IntPtr Pause); [DllImport(DLL_NAME)] public static extern KinemticState GetKinematicState(string vehicleName); diff --git a/Unity/UnityDemo/Assets/AirSimAssets/Scripts/Vehicles/IVehicleInterface.cs b/Unity/UnityDemo/Assets/AirSimAssets/Scripts/Vehicles/IVehicleInterface.cs index 2809319985..ffed4a2e31 100644 --- a/Unity/UnityDemo/Assets/AirSimAssets/Scripts/Vehicles/IVehicleInterface.cs +++ b/Unity/UnityDemo/Assets/AirSimAssets/Scripts/Vehicles/IVehicleInterface.cs @@ -37,6 +37,10 @@ public interface IVehicleInterface { bool SetCameraFoV(string cameraName, float fov_degrees); + bool setDistortionParam(string cameraName, string paramName, float value); + + bool getDistortionParams(string cameraName); + bool PrintLogMessage(string message, string messageParams, string vehicleName, int severity); void ResetVehicle(); diff --git a/Unity/UnityDemo/Assets/AirSimAssets/Scripts/Vehicles/Vehicle.cs b/Unity/UnityDemo/Assets/AirSimAssets/Scripts/Vehicles/Vehicle.cs index 2049d2eecd..9dd77b11e7 100644 --- a/Unity/UnityDemo/Assets/AirSimAssets/Scripts/Vehicles/Vehicle.cs +++ b/Unity/UnityDemo/Assets/AirSimAssets/Scripts/Vehicles/Vehicle.cs @@ -284,6 +284,18 @@ public bool SetCameraFoV(string cameraName, float fov_degrees) { return false; } + public bool setDistortionParam(string cameraName, string paramName, float value) + { + // not implemented + return false; + } + + public bool getDistortionParams(string cameraName) + { + // not implemented + return false; + } + public bool PrintLogMessage(string message, string messageParams, string vehicleName, int severity) { if (!print_log_messages_) diff --git a/Unity/UnityDemo/Assets/AirSimAssets/Scripts/Vehicles/VehicleCompanion.cs b/Unity/UnityDemo/Assets/AirSimAssets/Scripts/Vehicles/VehicleCompanion.cs index ce674191e7..88cd5e30ba 100644 --- a/Unity/UnityDemo/Assets/AirSimAssets/Scripts/Vehicles/VehicleCompanion.cs +++ b/Unity/UnityDemo/Assets/AirSimAssets/Scripts/Vehicles/VehicleCompanion.cs @@ -95,6 +95,8 @@ private static void InitDelegators() { Marshal.GetFunctionPointerForDelegate(new Func(GetCameraInfo)), Marshal.GetFunctionPointerForDelegate(new Func(SetCameraPose)), Marshal.GetFunctionPointerForDelegate(new Func(SetCameraFoV)), + Marshal.GetFunctionPointerForDelegate(new Func(SetDistortionParam)), + Marshal.GetFunctionPointerForDelegate(new Func(getDistortionParams)), Marshal.GetFunctionPointerForDelegate(new Func(SetSegmentationObjectId)), Marshal.GetFunctionPointerForDelegate(new Func(GetSegmentationObjectId)), Marshal.GetFunctionPointerForDelegate(new Func(PrintLogMessage)), @@ -194,6 +196,17 @@ private static bool SetCameraFoV(string cameraName, float fov_degrees, string ve return vehicle.VehicleInterface.SetCameraFoV(cameraName, fov_degrees); } + private static bool SetDistortionParam(string cameraName, string paramName, float value, string vehicleName) { + var vehicle = Vehicles.Find(element => element.vehicleName == vehicleName); + return vehicle.VehicleInterface.setDistortionParam(cameraName, paramName, value); + } + + private static bool getDistortionParams(string cameraName, string vehicleName) + { + var vehicle = Vehicles.Find(element => element.vehicleName == vehicleName); + return vehicle.VehicleInterface.getDistortionParams(cameraName); + } + private static bool PrintLogMessage(string message, string messageParams, string vehicleName, int severity) { var vehicle = Vehicles.Find(element => element.vehicleName == vehicleName); return vehicle.VehicleInterface.PrintLogMessage(message, messageParams, vehicleName, severity); From a7dbed80e05cc4ae4dde4890e950e9454fe87cb1 Mon Sep 17 00:00:00 2001 From: zimmy87 Date: Tue, 2 Feb 2021 02:06:35 -0800 Subject: [PATCH 2/2] Response to CR feedback Fixing the names of various camera distortion APIs to align with the Unity project's naming conventions --- .../AirSimAssets/Scripts/Utilities/PInvokeWrapper.cs | 4 ++-- .../AirSimAssets/Scripts/Vehicles/IVehicleInterface.cs | 4 ++-- .../Assets/AirSimAssets/Scripts/Vehicles/Vehicle.cs | 4 ++-- .../AirSimAssets/Scripts/Vehicles/VehicleCompanion.cs | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Unity/UnityDemo/Assets/AirSimAssets/Scripts/Utilities/PInvokeWrapper.cs b/Unity/UnityDemo/Assets/AirSimAssets/Scripts/Utilities/PInvokeWrapper.cs index 8df024defe..60fd57dbf4 100644 --- a/Unity/UnityDemo/Assets/AirSimAssets/Scripts/Utilities/PInvokeWrapper.cs +++ b/Unity/UnityDemo/Assets/AirSimAssets/Scripts/Utilities/PInvokeWrapper.cs @@ -13,8 +13,8 @@ public static class PInvokeWrapper { [DllImport(DLL_NAME)] public static extern void InitVehicleManager(IntPtr SetPose, IntPtr GetPose, IntPtr GetCollisionInfo, IntPtr GetRCData, IntPtr GetSimImages, IntPtr SetRotorSpeed, IntPtr SetEnableApi, IntPtr SetCarApiControls, IntPtr GetCarState, - IntPtr GetCameraInfo, IntPtr SetCameraPose, IntPtr SetCameraFoV, IntPtr setDistortionParam, IntPtr getDistortionParams, - IntPtr setSegmentationObjectId, IntPtr getSegmentationObjectId, IntPtr PrintLogMessage, IntPtr GetTransformFromUnity, + IntPtr GetCameraInfo, IntPtr SetCameraPose, IntPtr SetCameraFoV, IntPtr SetDistortionParam, IntPtr GetDistortionParams, + IntPtr SetSegmentationObjectId, IntPtr GetSegmentationObjectId, IntPtr PrintLogMessage, IntPtr GetTransformFromUnity, IntPtr Reset, IntPtr GetVelocity, IntPtr GetRayCastHit, IntPtr Pause); [DllImport(DLL_NAME)] diff --git a/Unity/UnityDemo/Assets/AirSimAssets/Scripts/Vehicles/IVehicleInterface.cs b/Unity/UnityDemo/Assets/AirSimAssets/Scripts/Vehicles/IVehicleInterface.cs index ffed4a2e31..0ec4deec3b 100644 --- a/Unity/UnityDemo/Assets/AirSimAssets/Scripts/Vehicles/IVehicleInterface.cs +++ b/Unity/UnityDemo/Assets/AirSimAssets/Scripts/Vehicles/IVehicleInterface.cs @@ -37,9 +37,9 @@ public interface IVehicleInterface { bool SetCameraFoV(string cameraName, float fov_degrees); - bool setDistortionParam(string cameraName, string paramName, float value); + bool SetDistortionParam(string cameraName, string paramName, float value); - bool getDistortionParams(string cameraName); + bool GetDistortionParams(string cameraName); bool PrintLogMessage(string message, string messageParams, string vehicleName, int severity); diff --git a/Unity/UnityDemo/Assets/AirSimAssets/Scripts/Vehicles/Vehicle.cs b/Unity/UnityDemo/Assets/AirSimAssets/Scripts/Vehicles/Vehicle.cs index 9dd77b11e7..56d5ef9af6 100644 --- a/Unity/UnityDemo/Assets/AirSimAssets/Scripts/Vehicles/Vehicle.cs +++ b/Unity/UnityDemo/Assets/AirSimAssets/Scripts/Vehicles/Vehicle.cs @@ -284,13 +284,13 @@ public bool SetCameraFoV(string cameraName, float fov_degrees) { return false; } - public bool setDistortionParam(string cameraName, string paramName, float value) + public bool SetDistortionParam(string cameraName, string paramName, float value) { // not implemented return false; } - public bool getDistortionParams(string cameraName) + public bool GetDistortionParams(string cameraName) { // not implemented return false; diff --git a/Unity/UnityDemo/Assets/AirSimAssets/Scripts/Vehicles/VehicleCompanion.cs b/Unity/UnityDemo/Assets/AirSimAssets/Scripts/Vehicles/VehicleCompanion.cs index 88cd5e30ba..c83787d8d5 100644 --- a/Unity/UnityDemo/Assets/AirSimAssets/Scripts/Vehicles/VehicleCompanion.cs +++ b/Unity/UnityDemo/Assets/AirSimAssets/Scripts/Vehicles/VehicleCompanion.cs @@ -96,7 +96,7 @@ private static void InitDelegators() { Marshal.GetFunctionPointerForDelegate(new Func(SetCameraPose)), Marshal.GetFunctionPointerForDelegate(new Func(SetCameraFoV)), Marshal.GetFunctionPointerForDelegate(new Func(SetDistortionParam)), - Marshal.GetFunctionPointerForDelegate(new Func(getDistortionParams)), + Marshal.GetFunctionPointerForDelegate(new Func(GetDistortionParams)), Marshal.GetFunctionPointerForDelegate(new Func(SetSegmentationObjectId)), Marshal.GetFunctionPointerForDelegate(new Func(GetSegmentationObjectId)), Marshal.GetFunctionPointerForDelegate(new Func(PrintLogMessage)), @@ -198,13 +198,13 @@ private static bool SetCameraFoV(string cameraName, float fov_degrees, string ve private static bool SetDistortionParam(string cameraName, string paramName, float value, string vehicleName) { var vehicle = Vehicles.Find(element => element.vehicleName == vehicleName); - return vehicle.VehicleInterface.setDistortionParam(cameraName, paramName, value); + return vehicle.VehicleInterface.SetDistortionParam(cameraName, paramName, value); } - private static bool getDistortionParams(string cameraName, string vehicleName) + private static bool GetDistortionParams(string cameraName, string vehicleName) { var vehicle = Vehicles.Find(element => element.vehicleName == vehicleName); - return vehicle.VehicleInterface.getDistortionParams(cameraName); + return vehicle.VehicleInterface.GetDistortionParams(cameraName); } private static bool PrintLogMessage(string message, string messageParams, string vehicleName, int severity) {