From 7836654dd44c93eccb3f74d1e497290d77e21d6a Mon Sep 17 00:00:00 2001 From: Hyunseok Yang Date: Fri, 7 Aug 2020 20:58:55 +0900 Subject: [PATCH 1/6] Fix Missing included shaders and Update ProjectSettings --- ProjectSettings/GraphicsSettings.asset | 2 +- ProjectSettings/ProjectSettings.asset | 222 ++++++++++++------------- 2 files changed, 112 insertions(+), 112 deletions(-) diff --git a/ProjectSettings/GraphicsSettings.asset b/ProjectSettings/GraphicsSettings.asset index 29b2f63d..7f2f30a8 100644 --- a/ProjectSettings/GraphicsSettings.asset +++ b/ProjectSettings/GraphicsSettings.asset @@ -40,7 +40,7 @@ GraphicsSettings: - {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0} - {fileID: 45, guid: 0000000000000000f000000000000000, type: 0} - {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} - - {fileID: 4800000, guid: 1a5580673dcecd5aca2677d75ef17de5, type: 3} + - {fileID: 4800000, guid: 580493fad5661e266b759ad2bd7f2c54, type: 3} - {fileID: 4800000, guid: f0d7cb58cac7143ddb2c05bc920dcd35, type: 3} - {fileID: 4800000, guid: 85b8ee53555329de0b74a90a2d692751, type: 3} m_PreloadedShaders: [] diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 6d39ea86..8ef72520 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -173,7 +173,7 @@ PlayerSettings: AndroidMinSdkVersion: 19 AndroidTargetSdkVersion: 0 AndroidPreferredInstallLocation: 1 - aotOptions: + aotOptions: stripEngineCode: 1 iPhoneStrippingLevel: 0 iPhoneScriptCallOptimization: 0 @@ -213,7 +213,7 @@ PlayerSettings: rgba: 0 iOSLaunchScreenFillPct: 100 iOSLaunchScreenSize: 100 - iOSLaunchScreenCustomXibPath: + iOSLaunchScreenCustomXibPath: iOSLaunchScreeniPadType: 0 iOSLaunchScreeniPadImage: {fileID: 0} iOSLaunchScreeniPadBackgroundColor: @@ -221,9 +221,9 @@ PlayerSettings: rgba: 0 iOSLaunchScreeniPadFillPct: 100 iOSLaunchScreeniPadSize: 100 - iOSLaunchScreeniPadCustomXibPath: + iOSLaunchScreeniPadCustomXibPath: iOSUseLaunchScreenStoryboard: 0 - iOSLaunchScreenCustomStoryboardPath: + iOSLaunchScreenCustomStoryboardPath: iOSDeviceRequirements: [] iOSURLSchemes: [] iOSBackgroundModes: 0 @@ -231,9 +231,9 @@ PlayerSettings: metalEditorSupport: 1 metalAPIValidation: 1 iOSRenderExtraFrameOnPause: 0 - appleDeveloperTeamID: - iOSManualSigningProvisioningProfileID: - tvOSManualSigningProvisioningProfileID: + appleDeveloperTeamID: + iOSManualSigningProvisioningProfileID: + tvOSManualSigningProvisioningProfileID: iOSManualSigningProvisioningProfileType: 0 tvOSManualSigningProvisioningProfileType: 0 appleEnableAutomaticSigning: 0 @@ -241,13 +241,13 @@ PlayerSettings: iOSAutomaticallyDetectAndAddCapabilities: 1 appleEnableProMotion: 0 clonedFromGUID: c0afd0d1d80e3634a9dac47e8a0426ea - templatePackageId: com.unity.template.3d@3.1.2 - templateDefaultScene: Assets/Scenes/SampleScene.unity + templatePackageId: + templateDefaultScene: Assets/Scenes/MainScene.unity AndroidTargetArchitectures: 1 AndroidSplashScreenScale: 0 androidSplashScreen: {fileID: 0} AndroidKeystoreName: '{inproject}: ' - AndroidKeyaliasName: + AndroidKeyaliasName: AndroidBuildApkPerCpuArchitecture: 0 AndroidTVCompatibility: 0 AndroidIsGame: 1 @@ -305,7 +305,7 @@ PlayerSettings: m_Width: 16 m_Height: 16 m_Kind: 0 - - m_BuildTarget: + - m_BuildTarget: m_Icons: - serializedVersion: 2 m_Icon: {fileID: 2800000, guid: 42491c491c989c4f2a78e1338a397f7e, type: 3} @@ -410,47 +410,47 @@ PlayerSettings: enableInternalProfiler: 0 logObjCUncaughtExceptions: 1 enableCrashReportAPI: 0 - cameraUsageDescription: - locationUsageDescription: - microphoneUsageDescription: - switchNetLibKey: + cameraUsageDescription: + locationUsageDescription: + microphoneUsageDescription: + switchNetLibKey: switchSocketMemoryPoolSize: 6144 switchSocketAllocatorPoolSize: 128 switchSocketConcurrencyLimit: 14 switchScreenResolutionBehavior: 2 switchUseCPUProfiler: 0 switchApplicationID: 0x01004b9000490000 - switchNSODependencies: - switchTitleNames_0: - switchTitleNames_1: - switchTitleNames_2: - switchTitleNames_3: - switchTitleNames_4: - switchTitleNames_5: - switchTitleNames_6: - switchTitleNames_7: - switchTitleNames_8: - switchTitleNames_9: - switchTitleNames_10: - switchTitleNames_11: - switchTitleNames_12: - switchTitleNames_13: - switchTitleNames_14: - switchPublisherNames_0: - switchPublisherNames_1: - switchPublisherNames_2: - switchPublisherNames_3: - switchPublisherNames_4: - switchPublisherNames_5: - switchPublisherNames_6: - switchPublisherNames_7: - switchPublisherNames_8: - switchPublisherNames_9: - switchPublisherNames_10: - switchPublisherNames_11: - switchPublisherNames_12: - switchPublisherNames_13: - switchPublisherNames_14: + switchNSODependencies: + switchTitleNames_0: + switchTitleNames_1: + switchTitleNames_2: + switchTitleNames_3: + switchTitleNames_4: + switchTitleNames_5: + switchTitleNames_6: + switchTitleNames_7: + switchTitleNames_8: + switchTitleNames_9: + switchTitleNames_10: + switchTitleNames_11: + switchTitleNames_12: + switchTitleNames_13: + switchTitleNames_14: + switchPublisherNames_0: + switchPublisherNames_1: + switchPublisherNames_2: + switchPublisherNames_3: + switchPublisherNames_4: + switchPublisherNames_5: + switchPublisherNames_6: + switchPublisherNames_7: + switchPublisherNames_8: + switchPublisherNames_9: + switchPublisherNames_10: + switchPublisherNames_11: + switchPublisherNames_12: + switchPublisherNames_13: + switchPublisherNames_14: switchIcons_0: {fileID: 0} switchIcons_1: {fileID: 0} switchIcons_2: {fileID: 0} @@ -481,11 +481,11 @@ PlayerSettings: switchSmallIcons_12: {fileID: 0} switchSmallIcons_13: {fileID: 0} switchSmallIcons_14: {fileID: 0} - switchManualHTML: - switchAccessibleURLs: - switchLegalInformation: + switchManualHTML: + switchAccessibleURLs: + switchLegalInformation: switchMainThreadStackSize: 1048576 - switchPresenceGroupId: + switchPresenceGroupId: switchLogoHandling: 0 switchReleaseVersion: 0 switchDisplayVersion: 1.0.0 @@ -493,7 +493,7 @@ PlayerSettings: switchTouchScreenUsage: 0 switchSupportedLanguagesMask: 0 switchLogoType: 0 - switchApplicationErrorCodeCategory: + switchApplicationErrorCodeCategory: switchUserAccountSaveDataSize: 0 switchUserAccountSaveDataJournalSize: 0 switchApplicationAttribute: 0 @@ -513,14 +513,14 @@ PlayerSettings: switchRatingsInt_10: 0 switchRatingsInt_11: 0 switchRatingsInt_12: 0 - switchLocalCommunicationIds_0: - switchLocalCommunicationIds_1: - switchLocalCommunicationIds_2: - switchLocalCommunicationIds_3: - switchLocalCommunicationIds_4: - switchLocalCommunicationIds_5: - switchLocalCommunicationIds_6: - switchLocalCommunicationIds_7: + switchLocalCommunicationIds_0: + switchLocalCommunicationIds_1: + switchLocalCommunicationIds_2: + switchLocalCommunicationIds_3: + switchLocalCommunicationIds_4: + switchLocalCommunicationIds_5: + switchLocalCommunicationIds_6: + switchLocalCommunicationIds_7: switchParentalControl: 0 switchAllowsScreenshot: 1 switchAllowsVideoCapturing: 1 @@ -544,34 +544,34 @@ PlayerSettings: switchNetworkInterfaceManagerInitializeEnabled: 1 switchPlayerConnectionEnabled: 1 ps4NPAgeRating: 12 - ps4NPTitleSecret: - ps4NPTrophyPackPath: + ps4NPTitleSecret: + ps4NPTrophyPackPath: ps4ParentalLevel: 11 ps4ContentID: ED1633-NPXX51362_00-0000000000000000 ps4Category: 0 ps4MasterVersion: 01.00 ps4AppVersion: 01.00 ps4AppType: 0 - ps4ParamSfxPath: + ps4ParamSfxPath: ps4VideoOutPixelFormat: 0 ps4VideoOutInitialWidth: 1920 ps4VideoOutBaseModeInitialWidth: 1920 ps4VideoOutReprojectionRate: 60 - ps4PronunciationXMLPath: - ps4PronunciationSIGPath: - ps4BackgroundImagePath: - ps4StartupImagePath: - ps4StartupImagesFolder: - ps4IconImagesFolder: - ps4SaveDataImagePath: - ps4SdkOverride: - ps4BGMPath: - ps4ShareFilePath: - ps4ShareOverlayImagePath: - ps4PrivacyGuardImagePath: - ps4NPtitleDatPath: + ps4PronunciationXMLPath: + ps4PronunciationSIGPath: + ps4BackgroundImagePath: + ps4StartupImagePath: + ps4StartupImagesFolder: + ps4IconImagesFolder: + ps4SaveDataImagePath: + ps4SdkOverride: + ps4BGMPath: + ps4ShareFilePath: + ps4ShareOverlayImagePath: + ps4PrivacyGuardImagePath: + ps4NPtitleDatPath: ps4RemotePlayKeyAssignment: -1 - ps4RemotePlayKeyMappingDir: + ps4RemotePlayKeyMappingDir: ps4PlayTogetherPlayerCount: 0 ps4EnterButtonAssignment: 1 ps4ApplicationParam1: 0 @@ -599,9 +599,9 @@ PlayerSettings: ps4ScriptOptimizationLevel: 0 ps4Audio3dVirtualSpeakerCount: 14 ps4attribCpuUsage: 0 - ps4PatchPkgPath: - ps4PatchLatestPkgPath: - ps4PatchChangeinfoPath: + ps4PatchPkgPath: + ps4PatchLatestPkgPath: + ps4PatchChangeinfoPath: ps4PatchDayOne: 0 ps4attribUserManagement: 0 ps4attribMoveSupport: 0 @@ -614,18 +614,18 @@ PlayerSettings: ps4attribEyeToEyeDistanceSettingVR: 0 ps4IncludedModules: [] ps4attribVROutputEnabled: 0 - monoEnv: + monoEnv: splashScreenBackgroundSourceLandscape: {fileID: 0} splashScreenBackgroundSourcePortrait: {fileID: 0} blurSplashScreenBackground: 1 - spritePackerPolicy: + spritePackerPolicy: webGLMemorySize: 16 webGLExceptionSupport: 1 webGLNameFilesAsHashes: 0 webGLDataCaching: 1 webGLDebugSymbols: 0 - webGLEmscriptenArgs: - webGLModulesDirectory: + webGLEmscriptenArgs: + webGLModulesDirectory: webGLTemplate: APPLICATION:Default webGLAnalyzeBuildSize: 0 webGLUseEmbeddedResources: 0 @@ -642,7 +642,7 @@ PlayerSettings: Standalone: 1 incrementalIl2cppBuild: {} allowUnsafeCode: 0 - additionalIl2CppArgs: + additionalIl2CppArgs: scriptingRuntimeVersion: 1 gcIncremental: 1 gcWBarrierValidation: 0 @@ -650,16 +650,16 @@ PlayerSettings: Standalone: 3 m_RenderingPath: 1 m_MobileRenderingPath: 1 - metroPackageName: Template_3D - metroPackageVersion: - metroCertificatePath: - metroCertificatePassword: - metroCertificateSubject: - metroCertificateIssuer: + metroPackageName: CLOiSim + metroPackageVersion: + metroCertificatePath: + metroCertificatePassword: + metroCertificateSubject: + metroCertificateIssuer: metroCertificateNotAfter: 0000000000000000 - metroApplicationDescription: Template_3D + metroApplicationDescription: CLOiSim wsaImages: {} - metroTileShortName: + metroTileShortName: metroTileShowName: 0 metroMediumTileShowName: 0 metroLargeTileShowName: 0 @@ -674,22 +674,22 @@ PlayerSettings: metroSplashScreenUseBackgroundColor: 0 platformCapabilities: {} metroTargetDeviceFamilies: {} - metroFTAName: + metroFTAName: metroFTAFileTypes: [] - metroProtocolName: - XboxOneProductId: - XboxOneUpdateKey: - XboxOneSandboxId: - XboxOneContentId: - XboxOneTitleId: - XboxOneSCId: - XboxOneGameOsOverridePath: - XboxOnePackagingOverridePath: - XboxOneAppManifestOverridePath: + metroProtocolName: + XboxOneProductId: + XboxOneUpdateKey: + XboxOneSandboxId: + XboxOneContentId: + XboxOneTitleId: + XboxOneSCId: + XboxOneGameOsOverridePath: + XboxOnePackagingOverridePath: + XboxOneAppManifestOverridePath: XboxOneVersion: 1.0.0.0 XboxOnePackageEncryption: 0 XboxOnePackageUpdateGranularity: 2 - XboxOneDescription: + XboxOneDescription: XboxOneLanguage: - enus XboxOneCapability: [] @@ -701,8 +701,8 @@ PlayerSettings: XboxOneAllowedProductIds: [] XboxOnePersistentLocalStorageSize: 0 XboxOneXTitleMemory: 8 - XboxOneOverrideIdentityName: - XboxOneOverrideIdentityPublisher: + XboxOneOverrideIdentityName: + XboxOneOverrideIdentityPublisher: vrEditorSettings: daydream: daydreamIconForeground: {fileID: 0} @@ -714,16 +714,16 @@ PlayerSettings: Hub: 0 UNet: 1 luminIcon: - m_Name: - m_ModelFolderPath: - m_PortalFolderPath: + m_Name: + m_ModelFolderPath: + m_PortalFolderPath: luminCert: - m_CertPath: + m_CertPath: m_SignPackage: 1 luminIsChannelApp: 0 luminVersion: m_VersionCode: 1 - m_VersionName: + m_VersionName: apiCompatibilityLevel: 6 cloudProjectId: 73a56b8e-7805-4cf3-ae10-497db8ccebcf framebufferDepthMemorylessMode: 0 From cf8c799f37c7a2a0fbe4a0e3dbf11328e23d5f57 Mon Sep 17 00:00:00 2001 From: Hyunseok Date: Sat, 8 Aug 2020 23:15:05 +0900 Subject: [PATCH 2/6] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 6cbb1bf9..0e514110 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ Here is the full list of models that is implemented or planned to be implemented - [X] 2-Wheeled Motor - [X] Sonar sensor - [X] IMU +- [X] Contact - [X] Camera - [ ] Camera intrinsic parameter - [X] Multi-camera From bfd65e8ce229222d9f251261dcd21951a821dcd2 Mon Sep 17 00:00:00 2001 From: Hyunseok Date: Sat, 8 Aug 2020 23:19:55 +0900 Subject: [PATCH 3/6] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0e514110..75c19bca 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ Inertia factors which retrieved from SDF are NOT USED for rigidbody in Unity. Be #### Tested environement: - Linux - Ubuntu 18.04 - - Current editor version is *'2019.4.1f1 (LTS)'*. + - Current editor version is *'2019.4.7f1 (LTS)'*. #### Release version If you don't want to build a project, just USE a release binary([Download linux version](https://github.com/lge-ros2/multi-robot-simulator/releases)). And just refer to 'Usage' From 9fc1230509feefae314e68375b4ee267f9c18ae5 Mon Sep 17 00:00:00 2001 From: Hyunseok Date: Sat, 8 Aug 2020 23:21:25 +0900 Subject: [PATCH 4/6] Update README.md --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 75c19bca..a6c7eb4e 100644 --- a/README.md +++ b/README.md @@ -60,8 +60,9 @@ Inertia factors which retrieved from SDF are NOT USED for rigidbody in Unity. Be ## Getting Started #### Tested environement: - - Linux - Ubuntu 18.04 - - Current editor version is *'2019.4.7f1 (LTS)'*. + - Linux: Ubuntu 18.04 + - Intel(R) Core(TM) i7-8700K, 32GB, GeForce RTX 2070 + - Current editor version is *'2019.4.6f1 (LTS)'*. #### Release version If you don't want to build a project, just USE a release binary([Download linux version](https://github.com/lge-ros2/multi-robot-simulator/releases)). And just refer to 'Usage' From 00713a408f10a3700909320cf9b2ec5f87cf5293 Mon Sep 17 00:00:00 2001 From: Hyunseok Yang Date: Mon, 10 Aug 2020 22:37:31 +0900 Subject: [PATCH 5/6] Enhance performance of sensor device - Lidar --- .../Scripts/Devices/Lidar.LaserCameraData.cs | 78 ++++++------ Assets/Scripts/Devices/Lidar.cs | 111 +++++++++++++----- 2 files changed, 129 insertions(+), 60 deletions(-) diff --git a/Assets/Scripts/Devices/Lidar.LaserCameraData.cs b/Assets/Scripts/Devices/Lidar.LaserCameraData.cs index a92afb46..afe8ec0b 100644 --- a/Assets/Scripts/Devices/Lidar.LaserCameraData.cs +++ b/Assets/Scripts/Devices/Lidar.LaserCameraData.cs @@ -11,32 +11,31 @@ namespace SensorDevices { public partial class Lidar : Device { + const int colorFormatUnitSize = sizeof(float); + struct LaserCamData { - const int colorFormatUnit = sizeof(float); + public float maxHAngleHalf; + public float maxHAngleHalfTangent; + public float angleResolutionH; + public float centerAngle; - private int index; - private float centerAngle; private int imageWidth; private int imageHeight; private byte[] imageBuffer; - public float CenterAngle - { - get => centerAngle; - set => centerAngle = value; - } - - public int ImageWidth => imageWidth; + public double[] output; - public int ImageHeight => imageHeight; + public float StartAngle => centerAngle - maxHAngleHalf; + public float EndAngle => centerAngle + maxHAngleHalf; - public void AllocateBuffer(in int dataIndex, in int width, in int height) + public void AllocateBuffer(in int width, in int height) { - index = dataIndex; imageWidth = width; imageHeight = height; - imageBuffer = new byte[width * height * colorFormatUnit]; + imageBuffer = new byte[width * height * colorFormatUnitSize]; + + output = new double[imageWidth]; } public void SetBufferData(in NativeArray buffer) @@ -47,14 +46,27 @@ public void SetBufferData(in NativeArray buffer) } } - public float GetDepthData(in float horizontalAngle, in float verticalAngle = 0) + public void ResolveLaserRanges(in float rangeMax = 1.0f) + { + for (var index = 0; index < output.Length; index++) + { + var rayAngleH = angleResolutionH * index; + var depthData = GetDepthData(rayAngleH); + var rayDistance = (depthData > 0) ? depthData * rangeMax : Mathf.Infinity; + + // CCW for ROS2 message direction + var ccwIndex = output.Length - index - 1; + output[ccwIndex] = rayDistance; + } + } + + private float GetDepthData(in float horizontalAngle, in float verticalAngle = 0) { - var horizontalAngleInCamData = (horizontalAngle - centerAngle) * Mathf.Deg2Rad; + var horizontalAngleInCamData = (horizontalAngle - maxHAngleHalf) * Mathf.Deg2Rad; var verticalAngleInCamData = verticalAngle * Mathf.Deg2Rad; - var maxAngleTangent = Mathf.Tan(laserCameraHFovHalf * Mathf.Deg2Rad); - var offsetY = (imageHeight * 0.5f) * (1f + (Mathf.Tan(verticalAngleInCamData) / maxAngleTangent)); - var offsetX = (imageWidth * 0.5f) * (1f + (Mathf.Tan(horizontalAngleInCamData) / maxAngleTangent)); + var offsetX = (imageWidth * 0.5f) * (1f + Mathf.Tan(horizontalAngleInCamData)/maxHAngleHalfTangent); + var offsetY = (imageHeight * 0.5f) * (1f + Mathf.Tan(verticalAngleInCamData)/maxHAngleHalfTangent); var decodedData = GetDecodedData((int)offsetX, (int)offsetY); @@ -66,27 +78,19 @@ public float GetDepthData(in float horizontalAngle, in float verticalAngle = 0) return (finalDepthData > 1.0f) ? 1.0f : finalDepthData; } - private float DecodeChannel(in byte r, in byte g, in byte b, in byte a) - { - // decodedData = (r / 255f) + (g / 255f) / 255f + (b / 255f) / 65025f; - // decodedData = (r * 0.0039215686f) + (g * 0.0000153787f) + (b * 0.0000000603f); - // decodedData = (r / 255f) + (g / 255f) / 255f + (b / 255f) / 65025f + (a / 255f) / 16581375f; - return (r * 0.0039215686f) + (g * 0.0000153787f) + (b * 0.0000000603f) + (a * 0.0000000002f); - } - private float GetDecodedData(in int pixelOffsetX, in int pixelOffsetY) { if (imageBuffer != null && imageBuffer.Length > 0) { // Decode - var imageOffsetX = colorFormatUnit * pixelOffsetX; - var imageOffsetY = colorFormatUnit * imageWidth * pixelOffsetY; + var imageOffsetX = colorFormatUnitSize * pixelOffsetX; + var imageOffsetY = colorFormatUnitSize * imageWidth * pixelOffsetY; var imageOffset = imageOffsetY + imageOffsetX; - byte r = imageBuffer[imageOffset + 0]; - byte g = imageBuffer[imageOffset + 1]; - byte b = imageBuffer[imageOffset + 2]; - byte a = imageBuffer[imageOffset + 3]; + var r = imageBuffer[imageOffset + 0]; + var g = imageBuffer[imageOffset + 1]; + var b = imageBuffer[imageOffset + 2]; + var a = imageBuffer[imageOffset + 3]; return DecodeChannel(r, g, b, a); } @@ -95,6 +99,14 @@ private float GetDecodedData(in int pixelOffsetX, in int pixelOffsetY) return 0; } } + + private float DecodeChannel(in byte r, in byte g, in byte b, in byte a) + { + // decodedData = (r / 255f) + (g / 255f) / 255f + (b / 255f) / 65025f; + // decodedData = (r * 0.0039215686f) + (g * 0.0000153787f) + (b * 0.0000000603f); + // decodedData = (r / 255f) + (g / 255f) / 255f + (b / 255f) / 65025f + (a / 255f) / 16581375f; + return (r * 0.0039215686f) + (g * 0.0000153787f) + (b * 0.0000000603f) + (a * 0.0000000002f); + } } } } \ No newline at end of file diff --git a/Assets/Scripts/Devices/Lidar.cs b/Assets/Scripts/Devices/Lidar.cs index d1a9939c..2248b069 100644 --- a/Assets/Scripts/Devices/Lidar.cs +++ b/Assets/Scripts/Devices/Lidar.cs @@ -60,6 +60,10 @@ public partial class Lidar : Device private LaserCamData[] laserCamData; + private float laserStartAngle; + private float laserEndAngle; + private float laserTotalAngle; + void OnRenderImage(RenderTexture source, RenderTexture destination) { if (depthMaterial) @@ -123,6 +127,8 @@ protected override void InitializeMessages() laserScan.Ranges = new double[samples]; laserScan.Intensities = new double[samples]; + Array.Clear(laserScan.Ranges, 0, (int)samples); + Array.Clear(laserScan.Intensities, 0, (int)samples); laserHAngleResolution = (float)(laserScan.AngleStep * Mathf.Rad2Deg); laserVAngleResolution = (float)(laserScan.VerticalAngleStep * Mathf.Rad2Deg); @@ -154,7 +160,7 @@ private void SetupLaserCamera() var renderTextrueWidth = Mathf.CeilToInt(laserCameraHFov / laserHAngleResolution); var aspectRatio = Mathf.Tan(laserCameraVFov / 2 * Mathf.Deg2Rad) / Mathf.Tan(laserCameraHFov / 2 * Mathf.Deg2Rad); - var renderTextrueHeight = Mathf.RoundToInt(renderTextrueWidth * aspectRatio); + var renderTextrueHeight = Mathf.CeilToInt(renderTextrueWidth * aspectRatio); var targetDepthRT = new RenderTexture(renderTextrueWidth, renderTextrueHeight, 24, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear) { name = "LidarDepthTexture" @@ -178,29 +184,37 @@ private void SetupLaserCameraData() for (var index = 0; index < numberOfLaserCamData; index++) { var data = new LaserCamData(); - data.AllocateBuffer(index, targetDepthRT.width, targetDepthRT.height); - data.CenterAngle = laserCameraRotationAngle * index; + data.angleResolutionH = laserHAngleResolution; + data.maxHAngleHalf = laserCameraHFovHalf; + data.maxHAngleHalfTangent = Mathf.Tan(laserCameraHFovHalf * Mathf.Deg2Rad); + data.centerAngle = laserCameraRotationAngle * index; + data.AllocateBuffer(targetDepthRT.width, targetDepthRT.height); laserCamData[index] = data; } + + laserStartAngle = defaultRotationOffset + (float)angleMin; + laserEndAngle = defaultRotationOffset + (float)angleMax; + laserTotalAngle = (float)(angleMax - angleMin); } private IEnumerator LaserCameraWorker() { var axisRotation = Vector3.zero; - var waitForSeconds = new WaitForSeconds(UpdatePeriod * adjustCapturingRate); var readbacks = new AsyncGPUReadbackRequest[numberOfLaserCamData]; + var sw = new Stopwatch(); while (true) { + sw.Restart(); + for (var dataIndex = 0; dataIndex < numberOfLaserCamData; dataIndex++) { var data = laserCamData[dataIndex]; - axisRotation.y = data.CenterAngle; + axisRotation.y = data.centerAngle; laserCam.transform.localRotation = Quaternion.Euler(axisRotation); laserCam.enabled = true; - laserCam.Render(); readbacks[dataIndex] = AsyncGPUReadback.Request(laserCam.targetTexture, 0, TextureFormat.RGBA32); @@ -233,13 +247,22 @@ private IEnumerator LaserCameraWorker() } } - yield return waitForSeconds; + for (var dataIndex = 0; dataIndex < numberOfLaserCamData; dataIndex++) + { + yield return null; + var data = laserCamData[dataIndex]; + data.ResolveLaserRanges((float)rangeMax); + } + + sw.Stop(); + + yield return new WaitForSeconds(WaitPeriod((float)sw.Elapsed.TotalSeconds)); } } protected override IEnumerator MainDeviceWorker() { - var waitForSeconds = new WaitForSeconds(UpdatePeriod * adjustCapturingRate); + // var waitForSeconds = new WaitForSeconds(UpdatePeriod * adjustCapturingRate); var sw = new Stopwatch(); while (true) { @@ -247,7 +270,7 @@ protected override IEnumerator MainDeviceWorker() GenerateMessage(); sw.Stop(); - yield return waitForSeconds; //new WaitForSeconds(WaitPeriod((float)sw.Elapsed.TotalSeconds)); + yield return new WaitForSeconds(WaitPeriod((float)sw.Elapsed.TotalSeconds)); } } @@ -255,29 +278,60 @@ protected override void GenerateMessage() { var lidarPosition = lidarLink.position + transform.localPosition; var lidarRotation = lidarLink.rotation; + var laserScan = laserScanStamped.Scan; DeviceHelper.SetVector3d(laserScan.WorldPose.Position, lidarPosition); DeviceHelper.SetQuaternion(laserScan.WorldPose.Orientation, lidarRotation); - var startAngle = defaultRotationOffset + (float)angleMin; - for (var hScanIndex = 0; hScanIndex < laserScanStamped.Scan.Count; hScanIndex++) - { - var rayAngleH = ((laserHAngleResolution * hScanIndex)) + startAngle; + var srcBufferOffset = 0; + var dstBufferOffset = 0; + var copyLength = 0; + var doCopy = true; - var convertedRayAngleH = (rayAngleH >= -laserCameraHFovHalf) ? rayAngleH : (360 + rayAngleH); - var dataIndexByAngle = (uint)Mathf.Round(convertedRayAngleH / laserCameraHFov); - - var laserScanData = laserCamData[dataIndexByAngle]; - - var depthData = laserScanData.GetDepthData(convertedRayAngleH); - - var rayDistance = (depthData > 0) ? depthData * (float)rangeMax : Mathf.Infinity; + for (var dataIndex = 0; dataIndex < numberOfLaserCamData; dataIndex++) + { + doCopy = true; + var data = laserCamData[dataIndex]; + var outputBufferLength = data.output.Length; + var dataStartAngle = data.StartAngle; + var dataEndAngle = data.EndAngle; + var dataTotalAngle = dataEndAngle - dataStartAngle; + + // start side of laser angle + if (dataStartAngle < laserStartAngle) + { + srcBufferOffset = 0; + var srcLengthratio = Mathf.Abs((dataStartAngle - laserStartAngle) / dataTotalAngle); + copyLength = outputBufferLength - Mathf.FloorToInt(outputBufferLength * srcLengthratio); + dstBufferOffset = (int)samples - copyLength; + } + // middle of laser angle + else if (dataStartAngle >= laserStartAngle && dataEndAngle < laserEndAngle) + { + srcBufferOffset = 0; + copyLength = outputBufferLength; + dstBufferOffset = (int)samples - (Mathf.CeilToInt(samples * ((dataStartAngle - laserStartAngle) / laserTotalAngle)) + copyLength); + } + // end side of laser angle + else if (dataEndAngle > laserEndAngle) + { + var srcLengthRatio = (laserEndAngle - dataStartAngle) / dataTotalAngle; + copyLength = Mathf.FloorToInt(outputBufferLength * srcLengthRatio); + srcBufferOffset = outputBufferLength - copyLength; + dstBufferOffset = 0; + } + else + { + Debug.LogWarning("Something wrong data in Laser...."); + doCopy = false; + } - // Store the laser data CCW - var scanIndexCcw = (uint)laserScanStamped.Scan.Count - hScanIndex - 1; - laserScan.Ranges[scanIndexCcw] = (double)rayDistance; - laserScan.Intensities[scanIndexCcw] = 0.0f; + if (doCopy) + { + // Store CCW direction for ROS2 sensor data + Array.Copy(data.output, srcBufferOffset, laserScan.Ranges, dstBufferOffset, copyLength); + } } DeviceHelper.SetCurrentTime(laserScanStamped.Time); @@ -305,7 +359,11 @@ protected override IEnumerator OnVisualize() var rayAngleH = ((laserHAngleResolution * hScanIndex)) + startAngle; var rayRotation = Quaternion.AngleAxis((float)(rayAngleH), lidarLink.up) * lidarLink.forward; var rayStart = (rayRotation * (float)rangeMin) + lidarSensorWorldPosition; - var rayDistance = (rangeData[hScanIndex] == Mathf.Infinity) ? (float)rangeMax : (rangeData[hScanIndex] - (float)rangeMin); + + var ccwIndex = (uint)rangeData.Length - hScanIndex - 1; + var rayData = rangeData[ccwIndex]; + + var rayDistance = (rayData == Mathf.Infinity) ? (float)rangeMax : (rayData - (float)rangeMin); var rayDirection = rayRotation * rayDistance; Debug.DrawRay(rayStart, rayDirection, rayColor, visualDrawDuration, true); @@ -320,7 +378,6 @@ public float[] GetRangeData() try { var temp = Array.ConvertAll(laserScanStamped.Scan.Ranges, item => (float)item); - Array.Reverse(temp); return temp; } catch From 9c0981d323a4c0a49a2899d112df73b4871cfd7e Mon Sep 17 00:00:00 2001 From: Hyunseok Yang Date: Mon, 10 Aug 2020 22:38:20 +0900 Subject: [PATCH 6/6] Update app version info in Project settings : 1.5.0 -> 1.5.1 --- ProjectSettings/ProjectSettings.asset | 218 +++++++++++++------------- 1 file changed, 109 insertions(+), 109 deletions(-) diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 8ef72520..82cf28e7 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -124,7 +124,7 @@ PlayerSettings: 16:10: 1 16:9: 1 Others: 1 - bundleVersion: 1.5.0 + bundleVersion: 1.5.1 preloadedAssets: [] metroInputSource: 0 wsaTransparentSwapchain: 0 @@ -173,7 +173,7 @@ PlayerSettings: AndroidMinSdkVersion: 19 AndroidTargetSdkVersion: 0 AndroidPreferredInstallLocation: 1 - aotOptions: + aotOptions: stripEngineCode: 1 iPhoneStrippingLevel: 0 iPhoneScriptCallOptimization: 0 @@ -213,7 +213,7 @@ PlayerSettings: rgba: 0 iOSLaunchScreenFillPct: 100 iOSLaunchScreenSize: 100 - iOSLaunchScreenCustomXibPath: + iOSLaunchScreenCustomXibPath: iOSLaunchScreeniPadType: 0 iOSLaunchScreeniPadImage: {fileID: 0} iOSLaunchScreeniPadBackgroundColor: @@ -221,9 +221,9 @@ PlayerSettings: rgba: 0 iOSLaunchScreeniPadFillPct: 100 iOSLaunchScreeniPadSize: 100 - iOSLaunchScreeniPadCustomXibPath: + iOSLaunchScreeniPadCustomXibPath: iOSUseLaunchScreenStoryboard: 0 - iOSLaunchScreenCustomStoryboardPath: + iOSLaunchScreenCustomStoryboardPath: iOSDeviceRequirements: [] iOSURLSchemes: [] iOSBackgroundModes: 0 @@ -231,9 +231,9 @@ PlayerSettings: metalEditorSupport: 1 metalAPIValidation: 1 iOSRenderExtraFrameOnPause: 0 - appleDeveloperTeamID: - iOSManualSigningProvisioningProfileID: - tvOSManualSigningProvisioningProfileID: + appleDeveloperTeamID: + iOSManualSigningProvisioningProfileID: + tvOSManualSigningProvisioningProfileID: iOSManualSigningProvisioningProfileType: 0 tvOSManualSigningProvisioningProfileType: 0 appleEnableAutomaticSigning: 0 @@ -241,13 +241,13 @@ PlayerSettings: iOSAutomaticallyDetectAndAddCapabilities: 1 appleEnableProMotion: 0 clonedFromGUID: c0afd0d1d80e3634a9dac47e8a0426ea - templatePackageId: + templatePackageId: templateDefaultScene: Assets/Scenes/MainScene.unity AndroidTargetArchitectures: 1 AndroidSplashScreenScale: 0 androidSplashScreen: {fileID: 0} AndroidKeystoreName: '{inproject}: ' - AndroidKeyaliasName: + AndroidKeyaliasName: AndroidBuildApkPerCpuArchitecture: 0 AndroidTVCompatibility: 0 AndroidIsGame: 1 @@ -305,7 +305,7 @@ PlayerSettings: m_Width: 16 m_Height: 16 m_Kind: 0 - - m_BuildTarget: + - m_BuildTarget: m_Icons: - serializedVersion: 2 m_Icon: {fileID: 2800000, guid: 42491c491c989c4f2a78e1338a397f7e, type: 3} @@ -410,47 +410,47 @@ PlayerSettings: enableInternalProfiler: 0 logObjCUncaughtExceptions: 1 enableCrashReportAPI: 0 - cameraUsageDescription: - locationUsageDescription: - microphoneUsageDescription: - switchNetLibKey: + cameraUsageDescription: + locationUsageDescription: + microphoneUsageDescription: + switchNetLibKey: switchSocketMemoryPoolSize: 6144 switchSocketAllocatorPoolSize: 128 switchSocketConcurrencyLimit: 14 switchScreenResolutionBehavior: 2 switchUseCPUProfiler: 0 switchApplicationID: 0x01004b9000490000 - switchNSODependencies: - switchTitleNames_0: - switchTitleNames_1: - switchTitleNames_2: - switchTitleNames_3: - switchTitleNames_4: - switchTitleNames_5: - switchTitleNames_6: - switchTitleNames_7: - switchTitleNames_8: - switchTitleNames_9: - switchTitleNames_10: - switchTitleNames_11: - switchTitleNames_12: - switchTitleNames_13: - switchTitleNames_14: - switchPublisherNames_0: - switchPublisherNames_1: - switchPublisherNames_2: - switchPublisherNames_3: - switchPublisherNames_4: - switchPublisherNames_5: - switchPublisherNames_6: - switchPublisherNames_7: - switchPublisherNames_8: - switchPublisherNames_9: - switchPublisherNames_10: - switchPublisherNames_11: - switchPublisherNames_12: - switchPublisherNames_13: - switchPublisherNames_14: + switchNSODependencies: + switchTitleNames_0: + switchTitleNames_1: + switchTitleNames_2: + switchTitleNames_3: + switchTitleNames_4: + switchTitleNames_5: + switchTitleNames_6: + switchTitleNames_7: + switchTitleNames_8: + switchTitleNames_9: + switchTitleNames_10: + switchTitleNames_11: + switchTitleNames_12: + switchTitleNames_13: + switchTitleNames_14: + switchPublisherNames_0: + switchPublisherNames_1: + switchPublisherNames_2: + switchPublisherNames_3: + switchPublisherNames_4: + switchPublisherNames_5: + switchPublisherNames_6: + switchPublisherNames_7: + switchPublisherNames_8: + switchPublisherNames_9: + switchPublisherNames_10: + switchPublisherNames_11: + switchPublisherNames_12: + switchPublisherNames_13: + switchPublisherNames_14: switchIcons_0: {fileID: 0} switchIcons_1: {fileID: 0} switchIcons_2: {fileID: 0} @@ -481,11 +481,11 @@ PlayerSettings: switchSmallIcons_12: {fileID: 0} switchSmallIcons_13: {fileID: 0} switchSmallIcons_14: {fileID: 0} - switchManualHTML: - switchAccessibleURLs: - switchLegalInformation: + switchManualHTML: + switchAccessibleURLs: + switchLegalInformation: switchMainThreadStackSize: 1048576 - switchPresenceGroupId: + switchPresenceGroupId: switchLogoHandling: 0 switchReleaseVersion: 0 switchDisplayVersion: 1.0.0 @@ -493,7 +493,7 @@ PlayerSettings: switchTouchScreenUsage: 0 switchSupportedLanguagesMask: 0 switchLogoType: 0 - switchApplicationErrorCodeCategory: + switchApplicationErrorCodeCategory: switchUserAccountSaveDataSize: 0 switchUserAccountSaveDataJournalSize: 0 switchApplicationAttribute: 0 @@ -513,14 +513,14 @@ PlayerSettings: switchRatingsInt_10: 0 switchRatingsInt_11: 0 switchRatingsInt_12: 0 - switchLocalCommunicationIds_0: - switchLocalCommunicationIds_1: - switchLocalCommunicationIds_2: - switchLocalCommunicationIds_3: - switchLocalCommunicationIds_4: - switchLocalCommunicationIds_5: - switchLocalCommunicationIds_6: - switchLocalCommunicationIds_7: + switchLocalCommunicationIds_0: + switchLocalCommunicationIds_1: + switchLocalCommunicationIds_2: + switchLocalCommunicationIds_3: + switchLocalCommunicationIds_4: + switchLocalCommunicationIds_5: + switchLocalCommunicationIds_6: + switchLocalCommunicationIds_7: switchParentalControl: 0 switchAllowsScreenshot: 1 switchAllowsVideoCapturing: 1 @@ -544,34 +544,34 @@ PlayerSettings: switchNetworkInterfaceManagerInitializeEnabled: 1 switchPlayerConnectionEnabled: 1 ps4NPAgeRating: 12 - ps4NPTitleSecret: - ps4NPTrophyPackPath: + ps4NPTitleSecret: + ps4NPTrophyPackPath: ps4ParentalLevel: 11 ps4ContentID: ED1633-NPXX51362_00-0000000000000000 ps4Category: 0 ps4MasterVersion: 01.00 ps4AppVersion: 01.00 ps4AppType: 0 - ps4ParamSfxPath: + ps4ParamSfxPath: ps4VideoOutPixelFormat: 0 ps4VideoOutInitialWidth: 1920 ps4VideoOutBaseModeInitialWidth: 1920 ps4VideoOutReprojectionRate: 60 - ps4PronunciationXMLPath: - ps4PronunciationSIGPath: - ps4BackgroundImagePath: - ps4StartupImagePath: - ps4StartupImagesFolder: - ps4IconImagesFolder: - ps4SaveDataImagePath: - ps4SdkOverride: - ps4BGMPath: - ps4ShareFilePath: - ps4ShareOverlayImagePath: - ps4PrivacyGuardImagePath: - ps4NPtitleDatPath: + ps4PronunciationXMLPath: + ps4PronunciationSIGPath: + ps4BackgroundImagePath: + ps4StartupImagePath: + ps4StartupImagesFolder: + ps4IconImagesFolder: + ps4SaveDataImagePath: + ps4SdkOverride: + ps4BGMPath: + ps4ShareFilePath: + ps4ShareOverlayImagePath: + ps4PrivacyGuardImagePath: + ps4NPtitleDatPath: ps4RemotePlayKeyAssignment: -1 - ps4RemotePlayKeyMappingDir: + ps4RemotePlayKeyMappingDir: ps4PlayTogetherPlayerCount: 0 ps4EnterButtonAssignment: 1 ps4ApplicationParam1: 0 @@ -599,9 +599,9 @@ PlayerSettings: ps4ScriptOptimizationLevel: 0 ps4Audio3dVirtualSpeakerCount: 14 ps4attribCpuUsage: 0 - ps4PatchPkgPath: - ps4PatchLatestPkgPath: - ps4PatchChangeinfoPath: + ps4PatchPkgPath: + ps4PatchLatestPkgPath: + ps4PatchChangeinfoPath: ps4PatchDayOne: 0 ps4attribUserManagement: 0 ps4attribMoveSupport: 0 @@ -614,18 +614,18 @@ PlayerSettings: ps4attribEyeToEyeDistanceSettingVR: 0 ps4IncludedModules: [] ps4attribVROutputEnabled: 0 - monoEnv: + monoEnv: splashScreenBackgroundSourceLandscape: {fileID: 0} splashScreenBackgroundSourcePortrait: {fileID: 0} blurSplashScreenBackground: 1 - spritePackerPolicy: + spritePackerPolicy: webGLMemorySize: 16 webGLExceptionSupport: 1 webGLNameFilesAsHashes: 0 webGLDataCaching: 1 webGLDebugSymbols: 0 - webGLEmscriptenArgs: - webGLModulesDirectory: + webGLEmscriptenArgs: + webGLModulesDirectory: webGLTemplate: APPLICATION:Default webGLAnalyzeBuildSize: 0 webGLUseEmbeddedResources: 0 @@ -642,7 +642,7 @@ PlayerSettings: Standalone: 1 incrementalIl2cppBuild: {} allowUnsafeCode: 0 - additionalIl2CppArgs: + additionalIl2CppArgs: scriptingRuntimeVersion: 1 gcIncremental: 1 gcWBarrierValidation: 0 @@ -651,15 +651,15 @@ PlayerSettings: m_RenderingPath: 1 m_MobileRenderingPath: 1 metroPackageName: CLOiSim - metroPackageVersion: - metroCertificatePath: - metroCertificatePassword: - metroCertificateSubject: - metroCertificateIssuer: + metroPackageVersion: + metroCertificatePath: + metroCertificatePassword: + metroCertificateSubject: + metroCertificateIssuer: metroCertificateNotAfter: 0000000000000000 metroApplicationDescription: CLOiSim wsaImages: {} - metroTileShortName: + metroTileShortName: metroTileShowName: 0 metroMediumTileShowName: 0 metroLargeTileShowName: 0 @@ -674,22 +674,22 @@ PlayerSettings: metroSplashScreenUseBackgroundColor: 0 platformCapabilities: {} metroTargetDeviceFamilies: {} - metroFTAName: + metroFTAName: metroFTAFileTypes: [] - metroProtocolName: - XboxOneProductId: - XboxOneUpdateKey: - XboxOneSandboxId: - XboxOneContentId: - XboxOneTitleId: - XboxOneSCId: - XboxOneGameOsOverridePath: - XboxOnePackagingOverridePath: - XboxOneAppManifestOverridePath: + metroProtocolName: + XboxOneProductId: + XboxOneUpdateKey: + XboxOneSandboxId: + XboxOneContentId: + XboxOneTitleId: + XboxOneSCId: + XboxOneGameOsOverridePath: + XboxOnePackagingOverridePath: + XboxOneAppManifestOverridePath: XboxOneVersion: 1.0.0.0 XboxOnePackageEncryption: 0 XboxOnePackageUpdateGranularity: 2 - XboxOneDescription: + XboxOneDescription: XboxOneLanguage: - enus XboxOneCapability: [] @@ -701,8 +701,8 @@ PlayerSettings: XboxOneAllowedProductIds: [] XboxOnePersistentLocalStorageSize: 0 XboxOneXTitleMemory: 8 - XboxOneOverrideIdentityName: - XboxOneOverrideIdentityPublisher: + XboxOneOverrideIdentityName: + XboxOneOverrideIdentityPublisher: vrEditorSettings: daydream: daydreamIconForeground: {fileID: 0} @@ -714,16 +714,16 @@ PlayerSettings: Hub: 0 UNet: 1 luminIcon: - m_Name: - m_ModelFolderPath: - m_PortalFolderPath: + m_Name: + m_ModelFolderPath: + m_PortalFolderPath: luminCert: - m_CertPath: + m_CertPath: m_SignPackage: 1 luminIsChannelApp: 0 luminVersion: m_VersionCode: 1 - m_VersionName: + m_VersionName: apiCompatibilityLevel: 6 cloudProjectId: 73a56b8e-7805-4cf3-ae10-497db8ccebcf framebufferDepthMemorylessMode: 0