Skip to content

Commit

Permalink
Merge pull request #2328 from rajat2004/unity-buil-improvements
Browse files Browse the repository at this point in the history
Unity build improvements
  • Loading branch information
madratman authored Apr 30, 2020
2 parents 65e7dcb + 3b9c8ac commit f37af51
Show file tree
Hide file tree
Showing 19 changed files with 190 additions and 78 deletions.
14 changes: 9 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -359,13 +359,17 @@ xcuserdata/
/*.gcno

# Unity
/Unity/UnityDemo/Library
/Unity/UnityDemo/Assembly-CSharp.csproj
/Unity/UnityDemo/UnityDemo.sln
/Unity/UnityDemo/Logs/
/Unity/UnityDemo/Assets/Plugins/AirsimWrapper.dll
/Unity/UnityDemo/Assets/Plugins/libAirsimWrapper.so
/Unity/linux-build/
/Unity/linux-build
/Unity/UnityDemo/Assets/Plugins/
/Unity/UnityDemo/[Ll]ibrary/
/Unity/UnityDemo/[Tt]emp/
/Unity/UnityDemo/[Oo]bj/
/Unity/UnityDemo/[Bb]uild/
/Unity/UnityDemo/[Bb]uilds/
/Unity/UnityDemo/[Ll]ogs/
/Unity/UnityDemo/[Uu]ser[Ss]ettings/

# ROS
ros/.catkin_tools/
Expand Down
14 changes: 12 additions & 2 deletions Unity/AirLibWrapper/AirsimWrapper/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,22 @@ IncludeEigen()

project(AirsimWrapper VERSION 0)

find_package(Boost REQUIRED COMPONENTS filesystem)
if(Boost_FOUND)
MESSAGE("Boost information:")
MESSAGE(" Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}")
MESSAGE(" Boost_LIBRARIES: ${Boost_LIBRARIES}")
MESSAGE(" Boost_LIBRARY_DIRS: ${Boost_LIBRARY_DIRS}")
endif()

include_directories(${Boost_INCLUDE_DIRS})

# RPC includes & source files
BuildRpc()
# MavLink source files
BuildMavLink()
#AirLib source files
BuildAirlib()
BuildAirLib()
#AirsimWrapper source files
BuildAirsimWrapper()

Expand All @@ -53,7 +63,7 @@ else ()
)
endif ()

target_link_libraries(${PROJECT_NAME} ${CMAKE_THREAD_LIBS_INIT} -lstdc++ -lpthread -lboost_filesystem)
target_link_libraries(${PROJECT_NAME} ${CMAKE_THREAD_LIBS_INIT} -lstdc++ -lpthread ${Boost_LIBRARIES})



Expand Down
3 changes: 1 addition & 2 deletions Unity/AirLibWrapper/AirsimWrapper/cmake/airlib-setup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ file(GLOB_RECURSE AIRLIB_LIBRARY_SOURCE_FILES
${AIRSIM_ROOT}/AirLib/src/api/*.cpp
${AIRSIM_ROOT}/AirLib/src/common/common_utils/*.cpp
${AIRSIM_ROOT}/AirLib/src/safety/*.cpp
${AIRSIM_ROOT}/AirLib/src/vehicles/car/api/*.cpp
${AIRSIM_ROOT}/AirLib/src/vehicles/multirotor/api/*.cpp
${AIRSIM_ROOT}/AirLib/src/vehicles/car/*.cpp
${AIRSIM_ROOT}/AirLib/src/vehicles/multirotor/*.cpp
)

Expand Down
2 changes: 1 addition & 1 deletion Unity/AirLibWrapper/AirsimWrapper/cmake/rpc-setup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(UNUSED_LAMBDA_CAPTURE_WARN_SUPPORTED)
check_warning_flag("unused-lambda-capture" UNUSED_LAMBDA_CAPTURE_WARN_SUPPORTED)
if(${UNUSED_LAMBDA_CAPTURE_WARN_SUPPORTED})
list(APPEND RPCLIB_BUILD_FLAGS -Wno-no-unused-lambda-capture)
list(APPEND RPCLIB_BUILD_FLAGS -Wno-unused-lambda-capture)
endif()

check_warning_flag("zero-as-null-pointer-constant" ZERO_AS_NULL_POINTER_CONSTANT_WARN_SUPPORTED)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ public void SetOrientation(AirSimQuaternion orientation) {
isPoseOverride = true;
}

public void SetFoV(float fov_degrees) {
fov = fov_degrees;
}

public void ToggleRecording() {
isCapturing = !isCapturing;
if (isCapturing) {
Expand Down Expand Up @@ -213,4 +217,4 @@ private void SetUpRenderTextureForCapture(ImageType type) {
captureRect = new Rect(0, 0, captureSettings.Width, captureSettings.Height);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ 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 SetCameraOrientation, IntPtr SetSegmentationObjectid, IntPtr GetSegmentationObjectId,
IntPtr GetCameraInfo, IntPtr SetCameraOrientation, IntPtr SetCameraFoV, IntPtr SetSegmentationObjectid, IntPtr GetSegmentationObjectId,
IntPtr PrintLogMessage, IntPtr GetTransformFromUnity, IntPtr Reset, IntPtr GetVelocity, IntPtr GetRayCastHit, IntPtr Pause);

[DllImport(DLL_NAME)]
Expand All @@ -37,4 +37,4 @@ public static extern void InitVehicleManager(IntPtr SetPose, IntPtr GetPose, Int
[DllImport(DLL_NAME)]
public static extern void InvokeCollisionDetection(CollisionInfo collisionInfo);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public interface IVehicleInterface {

bool SetCameraOrientation(string cameraName, AirSimQuaternion orientation);

bool SetCameraFoV(string cameraName, float fov_degrees);

bool PrintLogMessage(string message, string messageParams, string vehicleName, int severity);

void ResetVehicle();
Expand All @@ -45,4 +47,4 @@ public interface IVehicleInterface {

bool Pause(float timeScale);
}
}
}
16 changes: 13 additions & 3 deletions Unity/UnityDemo/Assets/AirSimAssets/Scripts/Vehicles/Vehicle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public AirSimPose GetPose() {

public UnityTransform GetTransform()
{
return new UnityTransform(new AirSimQuaternion(currentPose.orientation.x, currentPose.orientation.y, currentPose.orientation.z, currentPose.orientation.w),
return new UnityTransform(new AirSimQuaternion(currentPose.orientation.x, currentPose.orientation.y, currentPose.orientation.z, currentPose.orientation.w),
new AirSimVector(currentPose.position.x, currentPose.position.y, currentPose.position.z),
new AirSimVector(scale3D.x, scale3D.y, scale3D.z));
}
Expand Down Expand Up @@ -274,6 +274,16 @@ public bool SetCameraOrientation(string cameraName, AirSimQuaternion orientation
return false;
}

public bool SetCameraFoV(string cameraName, float fov_degrees) {
foreach(DataCaptureScript capture in captureCameras) {
if (capture.GetCameraName() == cameraName) {
capture.SetFoV(fov_degrees);
return true;;
}
}
return false;
}

public bool PrintLogMessage(string message, string messageParams, string vehicleName, int severity) {

if (!print_log_messages_)
Expand Down Expand Up @@ -318,7 +328,7 @@ private void InitializeVehicle() {
//Setting the initial get pose(HomePoint in AirLib) values to that of vehicle's location in the scene for initial setup in AirLib
DataManager.SetToAirSim(transform.position, ref currentPose.position);
DataManager.SetToAirSim(transform.rotation, ref currentPose.orientation);

collisionInfo.SetDefaultValues();
SetUpCameras();
captureResetEvent = new AutoResetEvent(false);
Expand Down Expand Up @@ -352,4 +362,4 @@ private void UpdateSegmentationView() {
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ private static void InitDelegators() {
Marshal.GetFunctionPointerForDelegate(new Func<string, CarState>(GetCarState)),
Marshal.GetFunctionPointerForDelegate(new Func<string, string, CameraInfo>(GetCameraInfo)),
Marshal.GetFunctionPointerForDelegate(new Func<string, AirSimQuaternion, string, bool>(SetCameraOrientation)),
Marshal.GetFunctionPointerForDelegate(new Func<string, float, string, bool>(SetCameraFoV)),
Marshal.GetFunctionPointerForDelegate(new Func<string, int, bool, bool>(SetSegmentationObjectId)),
Marshal.GetFunctionPointerForDelegate(new Func<string, int>(GetSegmentationObjectId)),
Marshal.GetFunctionPointerForDelegate(new Func<string, string, string, int, bool>(PrintLogMessage)),
Expand Down Expand Up @@ -188,6 +189,11 @@ private static bool SetCameraOrientation(string cameraName, AirSimQuaternion ori
return vehicle.VehicleInterface.SetCameraOrientation(cameraName, orientation);
}

private static bool SetCameraFoV(string cameraName, float fov_degrees, string vehicleName) {
var vehicle = Vehicles.Find(element => element.vehicleName == vehicleName);
return vehicle.VehicleInterface.SetCameraFoV(cameraName, fov_degrees);
}

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);
Expand All @@ -207,4 +213,4 @@ private static bool Pause(string vehicleName, float timeScale)
return vehicle.VehicleInterface.Pause(timeScale);
}
}
}
}
24 changes: 0 additions & 24 deletions Unity/UnityDemo/Assets/Plugins/AirsimWrapper.dll.meta

This file was deleted.

46 changes: 46 additions & 0 deletions Unity/UnityDemo/Packages/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"dependencies": {
"com.unity.2d.sprite": "1.0.0",
"com.unity.2d.tilemap": "1.0.0",
"com.unity.collab-proxy": "1.2.16",
"com.unity.ext.nunit": "1.0.0",
"com.unity.ide.rider": "1.1.4",
"com.unity.ide.vscode": "1.2.0",
"com.unity.multiplayer-hlapi": "1.0.4",
"com.unity.test-framework": "1.1.13",
"com.unity.textmeshpro": "2.0.1",
"com.unity.ugui": "1.0.0",
"com.unity.xr.legacyinputhelpers": "2.1.3",
"com.unity.modules.ai": "1.0.0",
"com.unity.modules.androidjni": "1.0.0",
"com.unity.modules.animation": "1.0.0",
"com.unity.modules.assetbundle": "1.0.0",
"com.unity.modules.audio": "1.0.0",
"com.unity.modules.cloth": "1.0.0",
"com.unity.modules.director": "1.0.0",
"com.unity.modules.imageconversion": "1.0.0",
"com.unity.modules.imgui": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0",
"com.unity.modules.particlesystem": "1.0.0",
"com.unity.modules.physics": "1.0.0",
"com.unity.modules.physics2d": "1.0.0",
"com.unity.modules.screencapture": "1.0.0",
"com.unity.modules.terrain": "1.0.0",
"com.unity.modules.terrainphysics": "1.0.0",
"com.unity.modules.tilemap": "1.0.0",
"com.unity.modules.ui": "1.0.0",
"com.unity.modules.uielements": "1.0.0",
"com.unity.modules.umbra": "1.0.0",
"com.unity.modules.unityanalytics": "1.0.0",
"com.unity.modules.unitywebrequest": "1.0.0",
"com.unity.modules.unitywebrequestassetbundle": "1.0.0",
"com.unity.modules.unitywebrequestaudio": "1.0.0",
"com.unity.modules.unitywebrequesttexture": "1.0.0",
"com.unity.modules.unitywebrequestwww": "1.0.0",
"com.unity.modules.vehicles": "1.0.0",
"com.unity.modules.video": "1.0.0",
"com.unity.modules.vr": "1.0.0",
"com.unity.modules.wind": "1.0.0",
"com.unity.modules.xr": "1.0.0"
}
}
20 changes: 17 additions & 3 deletions Unity/UnityDemo/ProjectSettings/EditorSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,33 @@
--- !u!159 &1
EditorSettings:
m_ObjectHideFlags: 0
serializedVersion: 7
serializedVersion: 9
m_ExternalVersionControlSupport: Visible Meta Files
m_SerializationMode: 2
m_LineEndingsForNewScripts: 2
m_DefaultBehaviorMode: 0
m_PrefabRegularEnvironment: {fileID: 0}
m_PrefabUIEnvironment: {fileID: 0}
m_SpritePackerMode: 0
m_SpritePackerPaddingPower: 1
m_EtcTextureCompressorBehavior: 1
m_EtcTextureFastCompressor: 1
m_EtcTextureNormalCompressor: 2
m_EtcTextureBestCompressor: 4
m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd
m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmref
m_ProjectGenerationRootNamespace:
m_UserGeneratedProjectSuffix:
m_CollabEditorSettings:
inProgressEnabled: 1
m_EnableTextureStreamingInEditMode: 1
m_EnableTextureStreamingInPlayMode: 1
m_AsyncShaderCompilation: 1
m_EnterPlayModeOptionsEnabled: 0
m_EnterPlayModeOptions: 3
m_ShowLightmapResolutionOverlay: 1
m_UseLegacyProbeSampleCount: 1
m_AssetPipelineMode: 1
m_CacheServerMode: 0
m_CacheServerEndpoint:
m_CacheServerNamespacePrefix: default
m_CacheServerEnableDownload: 1
m_CacheServerEnableUpload: 1
3 changes: 2 additions & 1 deletion Unity/UnityDemo/ProjectSettings/ProjectVersion.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
m_EditorVersion: 2018.2.14f1
m_EditorVersion: 2019.3.12f1
m_EditorVersionWithRevision: 2019.3.12f1 (84b23722532d)
11 changes: 11 additions & 0 deletions Unity/UnityDemo/ProjectSettings/VFXManager.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!937362698 &1
VFXManager:
m_ObjectHideFlags: 0
m_IndirectShader: {fileID: 0}
m_CopyBufferShader: {fileID: 0}
m_SortShader: {fileID: 0}
m_RenderPipeSettingsPath:
m_FixedTimeStep: 0.016666668
m_MaxDeltaTime: 0.05
10 changes: 10 additions & 0 deletions Unity/UnityDemo/ProjectSettings/XRSettings.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"m_SettingKeys": [
"VR Device Disabled",
"VR Device User Alert"
],
"m_SettingValues": [
"False",
"False"
]
}
1 change: 1 addition & 0 deletions Unity/build.cmd
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
REM //---------- copy binaries and include for MavLinkCom in deps ----------
msbuild AirLibWrapper\AirsimWrapper.sln /target:Clean /target:Build /property:Configuration=Release /property:Platform=x64
if ERRORLEVEL 1 goto :buildfailed
if NOT EXIST UnityDemo\Assets\Plugins mkdir UnityDemo\Assets\Plugins
copy /Y AirLibWrapper\x64\Release\AirsimWrapper.dll UnityDemo\Assets\Plugins

REM //---------- done building ----------
Expand Down
Loading

0 comments on commit f37af51

Please sign in to comment.