void Start() { Application.targetFrameRate = 200; Sensor = GetComponentInChildren <GPULidar>(); depthCam = GetComponentInChildren <Camera>(); // Calculation of FOV verticalFOV = HigherAngle - LowerAngle; m_VerticalAngularResolution = verticalFOV / (Channels - 1f); horizontalFOV = Time.fixedDeltaTime * 360.0f * RotateFrequency / SuperSample; // Calculation of the Camera Projection Mat Matrix4x4 projMat = depthCam.projectionMatrix; float horizontalMval = 1.0f / (Mathf.Tan((horizontalFOV / 2.0f) * Mathf.Deg2Rad)); float verticalMval = 1.0f / (Mathf.Tan((verticalFOV / 2.0f) * Mathf.Deg2Rad)); projMat[0, 0] = horizontalMval; projMat[1, 1] = verticalMval; depthCam.projectionMatrix = projMat; // target Texture size calculation m_ColumnsPerPhysStep = Mathf.RoundToInt(Time.fixedDeltaTime * RotationAngle * RotateFrequency / AngularResolution) / SuperSample; m_ResWidth = m_ColumnsPerPhysStep; m_ResHeight = Channels; depthCam.targetTexture = new RenderTexture(m_ResWidth, m_ResHeight, 1, RenderTextureFormat.RFloat, RenderTextureReadWrite.Default); RangesSamples = new Texture2D(m_ResWidth, m_ResHeight, TextureFormat.RGBAFloat, false); depthCam.farClipPlane = MeasurementRange; depthCam.nearClipPlane = MinMeasurementRange; // initial direction of the depthCam scan window center cameraRotationAngle = horizontalFOV / 2.0f; Sensor.transform.localEulerAngles = new Vector3(-(HigherAngle + LowerAngle) / 2.0f, cameraRotationAngle, 0); // activtion of the ICD interface if (sendDataOnICD) { vel16ICDinterface = new VelodyneWrapper(ICD_ConfigFile, true); } if (UseThreading) { int bar1ID = iSCentralDispatch.DispatchNewThread("ProcessVelodyne", ProcessVelodyneThread); iSCentralDispatch.SetPriorityForThread(bar1ID, iSCDThreadPriority.VeryHigh); iSCentralDispatch.SetTargetFramerate(100); } }
void Awake() { Sensor = GetComponentInChildren <GPULidar>(); depthCam = Sensor.GetComponent <Camera>(); // Calculation of FOV verticalFOV = HigherAngle - LowerAngle; verticalAngularResolution = verticalFOV / (Channels - 1f); horizontalFOV = Time.fixedDeltaTime * RotationAngle * RotateFrequency / SuperSample; // Calculation of the Camera Projection Mat Matrix4x4 projMat = depthCam.projectionMatrix; float horizontalMval = 1.0f / (Mathf.Tan((horizontalFOV / 2.0f) * Mathf.Deg2Rad)); float verticalMval = 1.0f / (Mathf.Tan((verticalFOV / 2.0f) * Mathf.Deg2Rad)); projMat[0, 0] = horizontalMval; projMat[1, 1] = verticalMval; depthCam.projectionMatrix = projMat; // target Texture size calculation ColumnsPerPhysStep = Mathf.RoundToInt(horizontalFOV / AngularResolution); ResWidth = ColumnsPerPhysStep; ResHeight = Channels; depthCam.targetTexture = new RenderTexture(ResWidth, ResHeight, 1, RenderTextureFormat.RFloat, RenderTextureReadWrite.Default); RangesSamples = new Texture2D(ResWidth, ResHeight, TextureFormat.RGBAFloat, false); depthCam.farClipPlane = MeasurementRange; depthCam.nearClipPlane = MinMeasurementRange; // initial direction of the depthCam scan window center cameraRotationAngle = horizontalFOV / 2.0f; Sensor.transform.localEulerAngles = new Vector3(-(HigherAngle + LowerAngle) / 2.0f, cameraRotationAngle, 0); // activtion of the ICD interface if (sendDataOnICD) { vel16ICDinterface = new VelodyneWrapper(ICD_ConfigFile, true); } }