diff --git a/Assets/AWSIM/Prefabs/Sensors/RobotecGPULidars/HesaiAT128E2X.prefab b/Assets/AWSIM/Prefabs/Sensors/RobotecGPULidars/HesaiAT128E2X.prefab index e88a1e26d..dbf1b4a3f 100644 --- a/Assets/AWSIM/Prefabs/Sensors/RobotecGPULidars/HesaiAT128E2X.prefab +++ b/Assets/AWSIM/Prefabs/Sensors/RobotecGPULidars/HesaiAT128E2X.prefab @@ -280,10 +280,11 @@ MonoBehaviour: m_EditorClassIdentifier: AutomaticCaptureHz: 10 modelPreset: 8 - returnType: 0 + returnMode: 16777220 applyDistanceGaussianNoise: 1 applyAngularGaussianNoise: 1 applyVelocityDistortion: 0 + simulateBeamDivergence: 0 doValidateConfigurationOnStartup: 1 configuration: id: 0 diff --git a/Assets/AWSIM/Prefabs/Sensors/RobotecGPULidars/HesaiPandar128E4X.prefab b/Assets/AWSIM/Prefabs/Sensors/RobotecGPULidars/HesaiPandar128E4X.prefab index 1077dc924..b0326872b 100644 --- a/Assets/AWSIM/Prefabs/Sensors/RobotecGPULidars/HesaiPandar128E4X.prefab +++ b/Assets/AWSIM/Prefabs/Sensors/RobotecGPULidars/HesaiPandar128E4X.prefab @@ -183,10 +183,11 @@ MonoBehaviour: m_EditorClassIdentifier: AutomaticCaptureHz: 10 modelPreset: 11 - returnType: 0 + returnMode: 16777220 applyDistanceGaussianNoise: 1 applyAngularGaussianNoise: 1 applyVelocityDistortion: 0 + simulateBeamDivergence: 0 doValidateConfigurationOnStartup: 1 configuration: id: 0 diff --git a/Assets/AWSIM/Prefabs/Sensors/RobotecGPULidars/HesaiPandar40P.prefab b/Assets/AWSIM/Prefabs/Sensors/RobotecGPULidars/HesaiPandar40P.prefab index 112fe1339..d1a4da892 100644 --- a/Assets/AWSIM/Prefabs/Sensors/RobotecGPULidars/HesaiPandar40P.prefab +++ b/Assets/AWSIM/Prefabs/Sensors/RobotecGPULidars/HesaiPandar40P.prefab @@ -509,10 +509,11 @@ MonoBehaviour: m_EditorClassIdentifier: AutomaticCaptureHz: 10 modelPreset: 6 - returnType: 0 + returnMode: 16777220 applyDistanceGaussianNoise: 1 applyAngularGaussianNoise: 1 applyVelocityDistortion: 0 + simulateBeamDivergence: 0 doValidateConfigurationOnStartup: 1 configuration: id: 0 diff --git a/Assets/AWSIM/Prefabs/Sensors/RobotecGPULidars/HesaiPandarQT64.prefab b/Assets/AWSIM/Prefabs/Sensors/RobotecGPULidars/HesaiPandarQT64.prefab index c9a003f26..ebe2715ef 100644 --- a/Assets/AWSIM/Prefabs/Sensors/RobotecGPULidars/HesaiPandarQT64.prefab +++ b/Assets/AWSIM/Prefabs/Sensors/RobotecGPULidars/HesaiPandarQT64.prefab @@ -412,10 +412,11 @@ MonoBehaviour: m_EditorClassIdentifier: AutomaticCaptureHz: 10 modelPreset: 5 - returnType: 0 + returnMode: 16777220 applyDistanceGaussianNoise: 1 applyAngularGaussianNoise: 1 applyVelocityDistortion: 0 + simulateBeamDivergence: 0 doValidateConfigurationOnStartup: 1 configuration: id: 0 diff --git a/Assets/AWSIM/Prefabs/Sensors/RobotecGPULidars/HesaiPandarXT32.prefab b/Assets/AWSIM/Prefabs/Sensors/RobotecGPULidars/HesaiPandarXT32.prefab index d9fa0b322..df4802b4f 100644 --- a/Assets/AWSIM/Prefabs/Sensors/RobotecGPULidars/HesaiPandarXT32.prefab +++ b/Assets/AWSIM/Prefabs/Sensors/RobotecGPULidars/HesaiPandarXT32.prefab @@ -280,10 +280,11 @@ MonoBehaviour: m_EditorClassIdentifier: AutomaticCaptureHz: 10 modelPreset: 9 - returnType: 0 + returnMode: 16777220 applyDistanceGaussianNoise: 1 applyAngularGaussianNoise: 1 applyVelocityDistortion: 0 + simulateBeamDivergence: 0 doValidateConfigurationOnStartup: 1 configuration: id: 0 diff --git a/Assets/AWSIM/Prefabs/Sensors/RobotecGPULidars/HesaiQT128C2X.prefab b/Assets/AWSIM/Prefabs/Sensors/RobotecGPULidars/HesaiQT128C2X.prefab index 6d8c72806..389423f5d 100644 --- a/Assets/AWSIM/Prefabs/Sensors/RobotecGPULidars/HesaiQT128C2X.prefab +++ b/Assets/AWSIM/Prefabs/Sensors/RobotecGPULidars/HesaiQT128C2X.prefab @@ -101,10 +101,11 @@ MonoBehaviour: m_EditorClassIdentifier: AutomaticCaptureHz: 10 modelPreset: 10 - returnType: 0 + returnMode: 16777220 applyDistanceGaussianNoise: 1 applyAngularGaussianNoise: 1 applyVelocityDistortion: 0 + simulateBeamDivergence: 0 doValidateConfigurationOnStartup: 1 configuration: id: 0 diff --git a/Assets/AWSIM/Prefabs/Sensors/RobotecGPULidars/OusterOS1-64.prefab b/Assets/AWSIM/Prefabs/Sensors/RobotecGPULidars/OusterOS1-64.prefab index d5c330224..fbec3d587 100644 --- a/Assets/AWSIM/Prefabs/Sensors/RobotecGPULidars/OusterOS1-64.prefab +++ b/Assets/AWSIM/Prefabs/Sensors/RobotecGPULidars/OusterOS1-64.prefab @@ -100,10 +100,11 @@ MonoBehaviour: m_EditorClassIdentifier: AutomaticCaptureHz: 20 modelPreset: 7 - returnType: 0 + returnMode: 16777220 applyDistanceGaussianNoise: 1 applyAngularGaussianNoise: 1 applyVelocityDistortion: 0 + simulateBeamDivergence: 0 doValidateConfigurationOnStartup: 1 configuration: id: 0 diff --git a/Assets/AWSIM/Prefabs/Sensors/RobotecGPULidars/VelodyneVLP16.prefab b/Assets/AWSIM/Prefabs/Sensors/RobotecGPULidars/VelodyneVLP16.prefab index d36b981e6..40ca77d5b 100644 --- a/Assets/AWSIM/Prefabs/Sensors/RobotecGPULidars/VelodyneVLP16.prefab +++ b/Assets/AWSIM/Prefabs/Sensors/RobotecGPULidars/VelodyneVLP16.prefab @@ -101,10 +101,11 @@ MonoBehaviour: m_EditorClassIdentifier: AutomaticCaptureHz: 10 modelPreset: 2 - returnType: 0 + returnMode: 16777220 applyDistanceGaussianNoise: 1 applyAngularGaussianNoise: 1 applyVelocityDistortion: 0 + simulateBeamDivergence: 0 doValidateConfigurationOnStartup: 1 configuration: id: 0 diff --git a/Assets/AWSIM/Prefabs/Sensors/RobotecGPULidars/VelodyneVLP32C.prefab b/Assets/AWSIM/Prefabs/Sensors/RobotecGPULidars/VelodyneVLP32C.prefab index 1b1df1104..f1441aa36 100644 --- a/Assets/AWSIM/Prefabs/Sensors/RobotecGPULidars/VelodyneVLP32C.prefab +++ b/Assets/AWSIM/Prefabs/Sensors/RobotecGPULidars/VelodyneVLP32C.prefab @@ -101,10 +101,11 @@ MonoBehaviour: m_EditorClassIdentifier: AutomaticCaptureHz: 10 modelPreset: 3 - returnType: 0 + returnMode: 16777220 applyDistanceGaussianNoise: 1 applyAngularGaussianNoise: 1 applyVelocityDistortion: 0 + simulateBeamDivergence: 0 doValidateConfigurationOnStartup: 1 configuration: id: 0 diff --git a/Assets/AWSIM/Prefabs/Sensors/RobotecGPULidars/VelodyneVLS128.prefab b/Assets/AWSIM/Prefabs/Sensors/RobotecGPULidars/VelodyneVLS128.prefab index e12d9d657..51f05d0a6 100644 --- a/Assets/AWSIM/Prefabs/Sensors/RobotecGPULidars/VelodyneVLS128.prefab +++ b/Assets/AWSIM/Prefabs/Sensors/RobotecGPULidars/VelodyneVLS128.prefab @@ -509,10 +509,11 @@ MonoBehaviour: m_EditorClassIdentifier: AutomaticCaptureHz: 10 modelPreset: 4 - returnType: 0 + returnMode: 16777220 applyDistanceGaussianNoise: 1 applyAngularGaussianNoise: 1 applyVelocityDistortion: 0 + simulateBeamDivergence: 0 doValidateConfigurationOnStartup: 1 configuration: id: 0 diff --git a/Assets/RGLUnityPlugin/Plugins/Linux/x86_64/libRobotecGPULidar.so b/Assets/RGLUnityPlugin/Plugins/Linux/x86_64/libRobotecGPULidar.so index 2325e899f..5bce7f6f5 100755 Binary files a/Assets/RGLUnityPlugin/Plugins/Linux/x86_64/libRobotecGPULidar.so and b/Assets/RGLUnityPlugin/Plugins/Linux/x86_64/libRobotecGPULidar.so differ diff --git a/Assets/RGLUnityPlugin/Plugins/Windows/x86_64/RobotecGPULidar.dll b/Assets/RGLUnityPlugin/Plugins/Windows/x86_64/RobotecGPULidar.dll index 5d7474240..5e3334e6f 100644 Binary files a/Assets/RGLUnityPlugin/Plugins/Windows/x86_64/RobotecGPULidar.dll and b/Assets/RGLUnityPlugin/Plugins/Windows/x86_64/RobotecGPULidar.dll differ diff --git a/Assets/RGLUnityPlugin/Scripts/LidarSensor.cs b/Assets/RGLUnityPlugin/Scripts/LidarSensor.cs index 4ce328764..d7c0547bb 100644 --- a/Assets/RGLUnityPlugin/Scripts/LidarSensor.cs +++ b/Assets/RGLUnityPlugin/Scripts/LidarSensor.cs @@ -46,8 +46,8 @@ public class LidarSensor : MonoBehaviour [Tooltip("Allows to select one of built-in LiDAR models")] public LidarModel modelPreset = LidarModel.RangeMeter; - [Tooltip("Allows to select between not divergent beams and different multi-return modes")] - public RGLReturnType returnType = RGLReturnType.RGL_RETURN_TYPE_NOT_DIVERGENT; + [Tooltip("Allows to select between LiDAR return modes")] + public RGLReturnMode returnMode = RGLReturnMode.SingleReturnFirst; [Tooltip("Allows to quickly enable/disable distance gaussian noise")] public bool applyDistanceGaussianNoise = true; @@ -58,6 +58,9 @@ public class LidarSensor : MonoBehaviour [Tooltip("Allows to quickly enable/disable velocity distortion")] public bool applyVelocityDistortion = false; + [Tooltip("If disable, both beam divergence values are set to 0. Otherwise, they are set based on LiDAR configuration.")] + public bool simulateBeamDivergence = false; + [Tooltip( "If enabled, validates whether the configuration is the same as the manual for the selected model (only on startup)")] public bool doValidateConfigurationOnStartup = true; @@ -85,7 +88,6 @@ public class LidarSensor : MonoBehaviour private const string lidarPoseNodeId = "LIDAR_POSE"; private const string noiseLidarRayNodeId = "NOISE_LIDAR_RAY"; private const string lidarRaytraceNodeId = "LIDAR_RAYTRACE"; - private const string lidarMRNodeId = "LIDAR_MR"; private const string noiseHitpointNodeId = "NOISE_HITPOINT"; private const string noiseDistanceNodeId = "NOISE_DISTANCE"; private const string pointsCompactNodeId = "POINTS_COMPACT"; @@ -113,7 +115,6 @@ public void Awake() .AddNodeRaysTransform(lidarPoseNodeId, Matrix4x4.identity) .AddNodeGaussianNoiseAngularRay(noiseLidarRayNodeId, 0, 0) .AddNodeRaytrace(lidarRaytraceNodeId) - .AddNodeMultiReturnSwitch(lidarMRNodeId, RGLReturnType.RGL_RETURN_TYPE_NOT_DIVERGENT) .AddNodeGaussianNoiseAngularHitpoint(noiseHitpointNodeId, 0, 0) .AddNodeGaussianNoiseDistance(noiseDistanceNodeId, 0, 0, 0); @@ -144,8 +145,7 @@ public void Start() if (LidarSnowManager.Instance != null) { // Add deactivated node with some initial values. To be activated and updated when validating. - rglGraphLidar.AddNodePointsSimulateSnow(snowNodeId, 0.0f, 1.0f, 0.0001f, 0.0001f, 0.2f, 0.01f, 1, 0.01f, - false, 0.0f); + rglGraphLidar.AddNodePointsSimulateSnow(snowNodeId, 0.0f, 1.0f, 0.0001f, 0.0001f, 0.2f, 0.01f, 1, 0.01f, 0.0f); rglGraphLidar.SetActive(snowNodeId, false); LidarSnowManager.Instance.OnNewConfig += OnValidate; } @@ -199,10 +199,9 @@ private void ApplyConfiguration(BaseLidarConfiguration newConfig) newConfig.noiseParams.angularNoiseMean * Mathf.Deg2Rad, newConfig.noiseParams.angularNoiseStDev * Mathf.Deg2Rad) .UpdateNodeGaussianNoiseDistance(noiseDistanceNodeId, newConfig.noiseParams.distanceNoiseMean, - newConfig.noiseParams.distanceNoiseStDevBase, newConfig.noiseParams.distanceNoiseStDevRisePerMeter) - .UpdateMultiReturnSwitch(lidarMRNodeId, returnType); + newConfig.noiseParams.distanceNoiseStDevBase, newConfig.noiseParams.distanceNoiseStDevRisePerMeter); - if (returnType != RGLReturnType.RGL_RETURN_TYPE_NOT_DIVERGENT) + if (simulateBeamDivergence) { rglGraphLidar.ConfigureNodeRaytraceBeamDivergence(lidarRaytraceNodeId, Mathf.Deg2Rad * newConfig.horizontalBeamDivergence, @@ -212,6 +211,8 @@ private void ApplyConfiguration(BaseLidarConfiguration newConfig) { rglGraphLidar.ConfigureNodeRaytraceBeamDivergence(lidarRaytraceNodeId, 0.0f, 0.0f); } + + rglGraphLidar.ConfigureNodeRaytraceReturnMode(lidarRaytraceNodeId, returnMode); rglGraphLidar.SetActive(noiseDistanceNodeId, applyDistanceGaussianNoise); var angularNoiseType = newConfig.noiseParams.angularNoiseType; @@ -235,8 +236,11 @@ private void ApplyConfiguration(BaseLidarConfiguration newConfig) LidarSnowManager.Instance.Density, newConfig.laserArray.GetLaserRingIds().Length, newConfig.horizontalBeamDivergence * Mathf.Deg2Rad, - LidarSnowManager.Instance.DoSimulateEnergyLoss, - LidarSnowManager.Instance.SnowflakeOccupancyThreshold); + LidarSnowManager.Instance.OccupancyThreshold); + rglGraphLidar.UpdateNodePointsSnowDefaults(snowNodeId, + LidarSnowManager.Instance.SnowflakesId, + LidarSnowManager.Instance.FullBeamIntensity, + 0.0f); // Default, because it is not supported in AWSIM. } rglGraphLidar.SetActive(snowNodeId, LidarSnowManager.Instance.IsSnowEnabled); diff --git a/Assets/RGLUnityPlugin/Scripts/LidarSnowManager.cs b/Assets/RGLUnityPlugin/Scripts/LidarSnowManager.cs index b66ad889f..8c0b08bae 100644 --- a/Assets/RGLUnityPlugin/Scripts/LidarSnowManager.cs +++ b/Assets/RGLUnityPlugin/Scripts/LidarSnowManager.cs @@ -29,6 +29,11 @@ public class LidarSnowManager : MonoBehaviour public delegate void OnNewConfigDelegate(); public OnNewConfigDelegate OnNewConfig; + [field: Header("Base Settings")] + + [field: SerializeField] + public bool IsSnowEnabled { get; private set; } = false; + // Snow model properties [field: SerializeField] [field: Tooltip("The precipitation rate for snow is expressed in rate of equivalent water depth in mm per hour")] @@ -51,15 +56,20 @@ public class LidarSnowManager : MonoBehaviour public float Density { get; private set; } = 0.07f; [field: SerializeField] - [field: Tooltip("If true, a more sophisticated method is used, which takes into account the energy loss of the lidar beam when hitting snowflakes")] - public bool DoSimulateEnergyLoss { get; private set; } = true; - - [field: SerializeField] - [field: Tooltip("Minimal snowflake occupancy (in fraction of ray beam angle) included in energy loss calculation")] + [field: Tooltip("Minimal beam aperture occupancy (ratio) that means a hit, both for snowflakes and for original hit")] [field: Range(0.0f, 1.0f)] - public float SnowflakeOccupancyThreshold { get; private set; } = 0.0f; + public float OccupancyThreshold { get; private set; } = 0.0f; - public bool IsSnowEnabled { get; private set; } = false; + [field: Header("Defaults")] + + [field: SerializeField] + [field: Tooltip("Entity ID that is assigned to cloud points resulting from snowflake hits")] + public int SnowflakesId { get; private set; } = 268435455; // Default RGL entity ID. + + [field: SerializeField] + [field: Tooltip("Initial intensity of each LiDAR laser beam, used to evaluate energy loss based on beam aperture occupancy")] + [field: Min(0.0f)] + public float FullBeamIntensity { get; private set; } = 1.0f; private void Awake() { diff --git a/Assets/RGLUnityPlugin/Scripts/LowLevelWrappers/RGLHelperTypes.cs b/Assets/RGLUnityPlugin/Scripts/LowLevelWrappers/RGLHelperTypes.cs index 649a24a1e..9b342fb68 100644 --- a/Assets/RGLUnityPlugin/Scripts/LowLevelWrappers/RGLHelperTypes.cs +++ b/Assets/RGLUnityPlugin/Scripts/LowLevelWrappers/RGLHelperTypes.cs @@ -41,6 +41,5 @@ public enum RGLNodeType GAUSSIAN_NOISE_ANGULAR_HITPOINT, GAUSSIAN_NOISE_DISTANCE, PUBLISH_ROS2_RADARSCAN, - MULTI_RETURN_SWITCH, }; } diff --git a/Assets/RGLUnityPlugin/Scripts/LowLevelWrappers/RGLNativeAPI.cs b/Assets/RGLUnityPlugin/Scripts/LowLevelWrappers/RGLNativeAPI.cs index f31461cfb..9c050e9c2 100644 --- a/Assets/RGLUnityPlugin/Scripts/LowLevelWrappers/RGLNativeAPI.cs +++ b/Assets/RGLUnityPlugin/Scripts/LowLevelWrappers/RGLNativeAPI.cs @@ -111,6 +111,9 @@ public static class RGLNativeAPI [DllImport("RobotecGPULidar")] public static extern int rgl_node_raytrace_configure_beam_divergence(IntPtr node, float horizontal_divergence, float vertical_divergence); + [DllImport("RobotecGPULidar")] + public static extern int rgl_node_raytrace_configure_return_mode(IntPtr node, RGLReturnMode return_mode); + [DllImport("RobotecGPULidar")] public static extern int rgl_node_points_format(ref IntPtr node, IntPtr fields, int field_count); @@ -149,10 +152,6 @@ public static extern int rgl_node_points_udp_publish( [DllImport("RobotecGPULidar")] public static extern int rgl_node_gaussian_noise_distance(ref IntPtr node, float mean, float st_dev, float st_dev_rise_per_meter); - - [DllImport("RobotecGPULidar")] - public static extern int rgl_node_multi_return_switch(ref IntPtr node, RGLReturnType return_type); - [DllImport("RobotecGPULidar")] public static extern int rgl_node_points_filter_ground(ref IntPtr node, IntPtr sensor_up_vector, float ground_angle_threshold); @@ -177,7 +176,11 @@ public static extern int rgl_node_publish_udp_objectlist(ref IntPtr node, [Marsh [DllImport("RobotecGPULidar")] public static extern int rgl_node_points_simulate_snow(ref IntPtr node, float min_range, float max_range, float rain_rate, float mean_snowflake_diameter, float terminal_velocity, float density, Int32 num_channels, float beam_divergence, - bool simulate_energy_loss, float snowflake_occupancy_threshold); + float occupancy_threshold); + + [DllImport("RobotecGPULidar")] + public static extern int rgl_node_points_simulate_snow_configure_defaults(IntPtr node, int snowflakes_id, float full_beam_intensity, + float snowflakes_laser_retro); [DllImport("RobotecGPULidar")] public static extern int rgl_graph_run(IntPtr node); @@ -485,6 +488,11 @@ public static void NodeRaytraceConfigureBeamDivergence(IntPtr node, float horizo CheckErr(rgl_node_raytrace_configure_beam_divergence(node, horizontalDivergence, verticalDivergence)); } + public static void NodeRaytraceConfigureReturnMode(IntPtr node, RGLReturnMode returnMode) + { + CheckErr(rgl_node_raytrace_configure_return_mode(node, returnMode)); + } + public static void NodePointsFormat(ref IntPtr node, RGLField[] fields) { unsafe @@ -562,11 +570,6 @@ public static void NodeGaussianNoiseDistance(ref IntPtr node, float mean, float CheckErr(rgl_node_gaussian_noise_distance(ref node, mean, stDev, stDevRisePerMeter)); } - public static void NodeMultiReturnSwitch(ref IntPtr node, RGLReturnType return_type) - { - CheckErr(rgl_node_multi_return_switch(ref node, return_type)); - } - public static void NodePointsFilterGround(ref IntPtr node, float groundAngleThreshold) { var upVector = IntoVec3f(new Vector3(0, 1, 0)); @@ -637,10 +640,16 @@ public static void NodePublishUdpObjectList(ref IntPtr node, string deviceIp, st public static void NodePointsSimulateSnow(ref IntPtr node, float minRange, float maxRange, float rainRate, float meanSnowflakeDiameter, float terminalVelocity, float density, Int32 numChannels, float beamDivergence, - bool doSimulateEnergyLoss, float snowflakeOccupancyThreshold) + float occupancyThreshold) { CheckErr(rgl_node_points_simulate_snow(ref node, minRange, maxRange, rainRate, - meanSnowflakeDiameter, terminalVelocity, density, numChannels, beamDivergence, doSimulateEnergyLoss, snowflakeOccupancyThreshold)); + meanSnowflakeDiameter, terminalVelocity, density, numChannels, beamDivergence, occupancyThreshold)); + } + + public static void NodePointsSimulateSnowConfigureDefaults(IntPtr node, int snowflakesId, float fullBeamIntensity, + float snowflakesLaserRetro) + { + CheckErr(rgl_node_points_simulate_snow_configure_defaults(node, snowflakesId, fullBeamIntensity, snowflakesLaserRetro)); } public static void GraphRun(IntPtr node) diff --git a/Assets/RGLUnityPlugin/Scripts/LowLevelWrappers/RGLNativeTypes.cs b/Assets/RGLUnityPlugin/Scripts/LowLevelWrappers/RGLNativeTypes.cs index fa405fab7..80ff042e7 100644 --- a/Assets/RGLUnityPlugin/Scripts/LowLevelWrappers/RGLNativeTypes.cs +++ b/Assets/RGLUnityPlugin/Scripts/LowLevelWrappers/RGLNativeTypes.cs @@ -99,18 +99,33 @@ public enum RGLLidarModel : Int32 RGL_HESAI_PANDAR_XT32 = 8, }; + public enum RGLReturnType : Int32 + { + ReturnStrongest = 1, + ReturnLast = 2, + ReturnSecond = 3, + ReturnFirst = 4, + ReturnSecondStrongest = 5, + } + + public enum RGLReturnCount : Int32 + { + SingleReturn = 1 << 24, + DualReturn = 2 << 24, + } + // Items have been renamed to be displayed in Unity nicer. - public enum RGLReturnMode : UInt32 + public enum RGLReturnMode : Int32 { - /* RGL_RETURN_FIRST */ SingleReturnFirst = 1 << 29, // Three of the most significant bits encode the number of returns - /* RGL_RETURN_SECOND */ SingleReturnSecond, - /* RGL_RETURN_LAST */ SingleReturnLast, - /* RGL_RETURN_STRONGEST */ SingleReturnStrongest, - /* RGL_RETURN_LAST_STRONGEST */ DualReturnLastStrongest = 2 << 29, - /* RGL_RETURN_FIRST_LAST */ DualReturnFirstLast, - /* RGL_RETURN_FIRST_STRONGEST */ DualReturnFirstStrongest, - /* RGL_RETURN_STRONGEST_SECOND_STRONGEST */ DualReturnStrongestSecondStrongest, - /* RGL_RETURN_FIRST_SECOND */ DualReturnFirstSecond, + /* RGL_RETURN_FIRST */ SingleReturnFirst = RGLReturnCount.SingleReturn | RGLReturnType.ReturnFirst, + /* RGL_RETURN_SECOND */ SingleReturnSecond = RGLReturnCount.SingleReturn | RGLReturnType.ReturnSecond, + /* RGL_RETURN_LAST */ SingleReturnLast = RGLReturnCount.SingleReturn | RGLReturnType.ReturnLast, + /* RGL_RETURN_STRONGEST */ SingleReturnStrongest = RGLReturnCount.SingleReturn | RGLReturnType.ReturnStrongest, + /* RGL_RETURN_LAST_STRONGEST */ DualReturnLastStrongest = RGLReturnCount.DualReturn | RGLReturnType.ReturnLast | (RGLReturnType.ReturnStrongest << 8), + /* RGL_RETURN_FIRST_LAST */ DualReturnFirstLast = RGLReturnCount.DualReturn | RGLReturnType.ReturnFirst | (RGLReturnType.ReturnLast << 8), + /* RGL_RETURN_FIRST_STRONGEST */ DualReturnFirstStrongest = RGLReturnCount.DualReturn | RGLReturnType.ReturnFirst | (RGLReturnType.ReturnStrongest << 8), + /* RGL_RETURN_STRONGEST_SECOND_STRONGEST */ DualReturnStrongestSecondStrongest = RGLReturnCount.DualReturn | RGLReturnType.ReturnStrongest | (RGLReturnType.ReturnSecondStrongest << 8), + /* RGL_RETURN_FIRST_SECOND */ DualReturnFirstSecond = RGLReturnCount.DualReturn | RGLReturnType.ReturnFirst | (RGLReturnType.ReturnSecond << 8), }; // Items have been renamed to be displayed in Unity nicer. @@ -163,11 +178,4 @@ public enum RGLExtension : Int32 RGL_EXTENSION_SNOW = 3, RGL_EXTENSION_COUNT }; - - public enum RGLReturnType : Int32 - { - RGL_RETURN_TYPE_NOT_DIVERGENT = 0, - RGL_RETURN_TYPE_FIRST = 1, - RGL_RETURN_TYPE_LAST = 2, - } } diff --git a/Assets/RGLUnityPlugin/Scripts/LowLevelWrappers/RGLNodeSequence.cs b/Assets/RGLUnityPlugin/Scripts/LowLevelWrappers/RGLNodeSequence.cs index 1043f9597..6a8ac1cd6 100644 --- a/Assets/RGLUnityPlugin/Scripts/LowLevelWrappers/RGLNodeSequence.cs +++ b/Assets/RGLUnityPlugin/Scripts/LowLevelWrappers/RGLNodeSequence.cs @@ -338,30 +338,18 @@ public RGLNodeSequence AddNodePublishUdpObjectList(string identifier, string dev public RGLNodeSequence AddNodePointsSimulateSnow(string identifier, float minRange, float maxRange, float rainRate, float meanSnowflakeDiameter, float terminalVelocity, float density, Int32 numChannels, float beamDivergence, - bool doSimulateEnergyLoss, float snowflakeOccupancyThreshold) + float occupancyThreshold) { CheckNodeNotExist(identifier); RGLNodeHandle handle = new RGLNodeHandle(); - RGLNativeAPI.NodePointsSimulateSnow(ref handle.Node, minRange, maxRange, rainRate, - meanSnowflakeDiameter, terminalVelocity, density, numChannels, beamDivergence, doSimulateEnergyLoss, - snowflakeOccupancyThreshold); + RGLNativeAPI.NodePointsSimulateSnow(ref handle.Node, minRange, maxRange, rainRate, meanSnowflakeDiameter, + terminalVelocity, density, numChannels, beamDivergence, occupancyThreshold); handle.Type = RGLNodeType.POINTS_SIMULATE_SNOW; handle.Identifier = identifier; AddNode(handle); return this; } - public RGLNodeSequence AddNodeMultiReturnSwitch(string identifier, RGLReturnType returnType) - { - CheckNodeNotExist(identifier); - RGLNodeHandle handle = new RGLNodeHandle(); - RGLNativeAPI.NodeMultiReturnSwitch(ref handle.Node, returnType); - handle.Type = RGLNodeType.MULTI_RETURN_SWITCH; - handle.Identifier = identifier; - AddNode(handle); - return this; - } - //// UPDATE NODES //// public RGLNodeSequence UpdateNodeRaysFromMat3x4f(string identifier, Matrix4x4[] rays) { @@ -483,19 +471,18 @@ public RGLNodeSequence UpdateNodePointsRadarTrackObjects(string identifier, floa public RGLNodeSequence UpdateNodePointsSimulateSnow(string identifier, float minRange, float maxRange, float rainRate, float meanSnowflakeDiameter, float terminalVelocity, float density, Int32 numChannels, float beamDivergence, - bool doSimulateEnergyLoss, float snowflakeOccupancyThreshold) + float occupancyThreshold) { RGLNodeHandle handle = ValidateNode(identifier, RGLNodeType.POINTS_SIMULATE_SNOW); - RGLNativeAPI.NodePointsSimulateSnow(ref handle.Node, minRange, maxRange, rainRate, - meanSnowflakeDiameter, terminalVelocity, density, numChannels, beamDivergence, doSimulateEnergyLoss, - snowflakeOccupancyThreshold); + RGLNativeAPI.NodePointsSimulateSnow(ref handle.Node, minRange, maxRange, rainRate, meanSnowflakeDiameter, + terminalVelocity, density, numChannels, beamDivergence, occupancyThreshold); return this; } - public RGLNodeSequence UpdateMultiReturnSwitch(string identifier, RGLReturnType returnType) + public RGLNodeSequence UpdateNodePointsSnowDefaults(string identifier, int snowflakesId, float fullBeamIntensity, float snowflakesLaserRetro) { - RGLNodeHandle handle = ValidateNode(identifier, RGLNodeType.MULTI_RETURN_SWITCH); - RGLNativeAPI.NodeMultiReturnSwitch(ref handle.Node, returnType); + RGLNodeHandle handle = ValidateNode(identifier, RGLNodeType.POINTS_SIMULATE_SNOW); + RGLNativeAPI.NodePointsSimulateSnowConfigureDefaults(handle.Node, snowflakesId, fullBeamIntensity, snowflakesLaserRetro); return this; } @@ -522,6 +509,13 @@ public RGLNodeSequence ConfigureNodeRaytraceBeamDivergence(string identifier, fl return this; } + public RGLNodeSequence ConfigureNodeRaytraceReturnMode(string identifier, RGLReturnMode returnMode) + { + RGLNodeHandle handle = ValidateNode(identifier, RGLNodeType.RAYTRACE); + RGLNativeAPI.NodeRaytraceConfigureReturnMode(handle.Node, returnMode); + return this; + } + public RGLNodeSequence SetNodeRadarClasses(string identifier, int[] entityIds, RGLRadarObjectClass[] objectClasses) { RGLNodeHandle handle = ValidateNode(identifier, RGLNodeType.POINTS_RADAR_TRACK_OBJECTS); diff --git a/docs/Components/Sensors/LiDARSensor/LiDARSensor/index.md b/docs/Components/Sensors/LiDARSensor/LiDARSensor/index.md index 22b5e080b..69dfc7ee9 100644 --- a/docs/Components/Sensors/LiDARSensor/LiDARSensor/index.md +++ b/docs/Components/Sensors/LiDARSensor/LiDARSensor/index.md @@ -94,10 +94,21 @@ The pipeline consists of: #### Elements configurable from the editor level - `Automatic Capture Hz` - the rate of sensor processing (default: `10Hz`) - `Model Preset` - allows selecting one of the built-in *LiDAR* models (default: `RangeMeter`) -- `Return Type` - allows selecting multi-return mode (note: this requires more computation). Modes other than "not divergent" require positive beam divergence. +- `Return Mode` - allows selecting LiDAR return mode (default: `Single Return First`). Both single and multi return modes may be selected, including various return types. Return types may be base on distance from LiDAR (e.g. first or last) or on instance [intensity](#intensity-texture) (strongest and second strongest). Note that dual return modes are reasonable only when beam divergence simulation is enabled (see parameter below). If beam divergence simulation is disabled and one of dual return modes is selected, then the same hit point will be returned for each return type (two exactly same hit points for each LiDAR ray). Available return modes are: + - `Single Return First` + - `Single Return Second` + - `Single Return Last` + - `Single Return Strongest` + - `Dual Return Last Strongest` + - `Dual Return First Last` + - `Dual Return First Strongest` + - `Dual Return Strongest Second Strongest` + - `Dual Return First Second` - `Apply Distance Gaussian Noise` - enable/disable distance *Gaussian* noise (default: `true`) - `Apply Angular Gaussian Noise` - enable/disable angular *Gaussian* noise (default: `true`) - `Apply Velocity Distortion` - enable/disable velocity distortion (default: `false`) +- `Simulate Beam Divergence` - enable/disable beam divergence simulation (default: `false`). Setting this to `false` effectively cause RGL to ignore +horizontal and vertical beam divergence values (as they would be set to 0). Note that simulating beam divergence requires significantly more processing power - if you observe any issues with the framerate, it is suggested to disable beam divergence simulation. - *Configuration*: - `Laser Array` - geometry description of lidar's array of lasers, should be prepared on the basis of the manual for a given model of *LiDAR* (default: loaded from `LaserArrayLibrary`) - `Horizontal Resolution` - the horiontal resolution of laser array firings diff --git a/docs/Components/Sensors/LiDARSensor/LiDARSensor/script.png b/docs/Components/Sensors/LiDARSensor/LiDARSensor/script.png index 44349bd38..a1c925a4a 100644 Binary files a/docs/Components/Sensors/LiDARSensor/LiDARSensor/script.png and b/docs/Components/Sensors/LiDARSensor/LiDARSensor/script.png differ