Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to override range (single value) for non-uniform range LiDARs #371

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ MonoBehaviour:
- topic: lidar/pointcloud_ex
publish: 1
fieldsPreset: 2
fields: 01000000030000000c0000000b0000000a00000009000000080000000e000000
fields: 01000000030000000c0000000b000000090000000a000000080000000e000000
radarScanPublishers: []
--- !u!114 &9115279251508973176
MonoBehaviour:
Expand Down Expand Up @@ -1215,3 +1215,7 @@ MonoBehaviour:
distanceNoiseStDevBase: 0.02
distanceNoiseStDevRisePerMeter: 0
distanceNoiseMean: 0
rangeOverride:
enable: 0
minRange: 0
maxRange: 0
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ MonoBehaviour:
- topic: lidar/pointcloud_ex
publish: 1
fieldsPreset: 2
fields: 01000000030000000c0000000b0000000a00000009000000080000000e000000
fields: 01000000030000000c0000000b000000090000000a000000080000000e000000
radarScanPublishers: []
--- !u!114 &2398431948632788025
MonoBehaviour:
Expand Down Expand Up @@ -1118,6 +1118,10 @@ MonoBehaviour:
distanceNoiseStDevBase: 0.02
distanceNoiseStDevRisePerMeter: 0
distanceNoiseMean: 0
rangeOverride:
enable: 0
minRange: 0
maxRange: 0
highResolutionModeEnabled: 0
--- !u!1 &8835314765314878244
GameObject:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ MonoBehaviour:
- topic: lidar/pointcloud_ex
publish: 1
fieldsPreset: 2
fields: 01000000030000000c0000000b0000000a00000009000000080000000e000000
fields: 01000000030000000c0000000b000000090000000a000000080000000e000000
radarScanPublishers: []
--- !u!114 &7675420128049466981
MonoBehaviour:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ MonoBehaviour:
- topic: lidar/pointcloud_ex
publish: 1
fieldsPreset: 2
fields: 01000000030000000c0000000b0000000a00000009000000080000000e000000
fields: 01000000030000000c0000000b000000090000000a000000080000000e000000
radarScanPublishers: []
--- !u!114 &1430391258634731476
MonoBehaviour:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ MonoBehaviour:
- topic: lidar/pointcloud_ex
publish: 1
fieldsPreset: 2
fields: 01000000030000000c0000000b0000000a00000009000000080000000e000000
fields: 01000000030000000c0000000b000000090000000a000000080000000e000000
radarScanPublishers: []
--- !u!114 &1429064023790827067
MonoBehaviour:
Expand Down Expand Up @@ -1484,6 +1484,10 @@ MonoBehaviour:
distanceNoiseStDevBase: 0.02
distanceNoiseStDevRisePerMeter: 0
distanceNoiseMean: 0
rangeOverride:
enable: 0
minRange: 0
maxRange: 0
--- !u!1 &6990615171978804803
GameObject:
m_ObjectHideFlags: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ MonoBehaviour:
- topic: lidar/pointcloud_ex
publish: 1
fieldsPreset: 2
fields: 01000000030000000c0000000b0000000a00000009000000080000000e000000
fields: 01000000030000000c0000000b000000090000000a000000080000000e000000
radarScanPublishers: []
--- !u!114 &4572956135196922574
MonoBehaviour:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ MonoBehaviour:
- topic: lidar/pointcloud_ex
publish: 1
fieldsPreset: 2
fields: 01000000030000000c0000000b0000000a00000009000000080000000e000000
fields: 01000000030000000c0000000b000000090000000a000000080000000e000000
radarScanPublishers: []
--- !u!114 &6422033487030486066
MonoBehaviour:
Expand Down
71 changes: 52 additions & 19 deletions Assets/RGLUnityPlugin/Scripts/LidarModels/LidarConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

using System;
using UnityEngine;
using UnityEngine.Serialization;

namespace RGLUnityPlugin
{
Expand Down Expand Up @@ -81,19 +80,9 @@ public virtual Matrix4x4[] GetRayPoses()
}

/// <summary>
/// Returns ranges for the generated rays.
/// Ranges are retrieved from lasers description. May be overridden.
/// Returns ranges for the generated rays. Must be overridden.
/// </summary>
public virtual Vector2[] GetRayRanges()
{
Vector2[] rayRanges = new Vector2[PointCloudSize];
Vector2[] laserRanges = laserArray.GetLaserRanges();
for (int i = 0; i < HorizontalSteps; i++)
{
Array.Copy(laserRanges, 0, rayRanges, i * laserRanges.Length, laserRanges.Length);
}
return rayRanges;
}
public abstract Vector2[] GetRayRanges();

/// <summary>
/// Returns time offsets for the generated rays.
Expand Down Expand Up @@ -160,7 +149,51 @@ protected bool ValidateWithModel(BaseLidarConfiguration gold)
/// It allows the definition of the lidar with different ranges for each laser (channel).
/// </summary>
[Serializable]
public class LaserBasedRangeLidarConfiguration : BaseLidarConfiguration { }
public class LaserBasedRangeLidarConfiguration : BaseLidarConfiguration
{
[Serializable]
public class RangeOverride
{
[Tooltip("Flag to enable range overriding (single range (min, max) value for all LiDAR rays will be set)")]
public bool enable = false;

[Tooltip("Minimum range of the sensor")]
[Min(0)] public float minRange = 0.0f;

[Tooltip("Maximum range of the sensor")]
[Min(0)] public float maxRange = 0.0f;
}

public RangeOverride rangeOverride = new RangeOverride();

/// <summary>
/// Final form of GetRayRanges that handles range override (single range (min, max) value for all LiDAR rays).
/// If range override is disabled, GetRayLaserBasedRanges is called.
/// </summary>
public sealed override Vector2[] GetRayRanges()
{
if (rangeOverride.enable)
{
return new Vector2[1] {new Vector2(rangeOverride.minRange, rangeOverride.maxRange)};
}

return GetRayLaserBasedRanges();
}

/// <summary>
/// Ranges are retrieved from lasers description. May be overridden.
/// </summary>
public virtual Vector2[] GetRayLaserBasedRanges()
{
Vector2[] rayRanges = new Vector2[PointCloudSize];
Vector2[] laserRanges = laserArray.GetLaserRanges();
for (int i = 0; i < HorizontalSteps; i++)
{
Array.Copy(laserRanges, 0, rayRanges, i * laserRanges.Length, laserRanges.Length);
}
return rayRanges;
}
}

/// <summary>
/// Lidar configuration for uniformly distributed rays along the horizontal axis with a uniform range for all the rays.
Expand All @@ -175,7 +208,7 @@ public class UniformRangeLidarConfiguration : BaseLidarConfiguration
[Tooltip("Maximum range of the sensor")]
[Min(0)] public float maxRange;

public override Vector2[] GetRayRanges()
public sealed override Vector2[] GetRayRanges()
{
return new Vector2[1] {new Vector2(minRange, maxRange)};
}
Expand All @@ -195,9 +228,9 @@ gold is UniformRangeLidarConfiguration goldTyped &&
/// It contains properties and ray-generating methods specific to this lidar.
/// </summary>
[Serializable]
public class HesaiAT128LidarConfiguration : BaseLidarConfiguration
public class HesaiAT128LidarConfiguration : LaserBasedRangeLidarConfiguration
{
public override Vector2[] GetRayRanges()
public override Vector2[] GetRayLaserBasedRanges()
{
// All channels fire laser pulses that measure the far field (> 7.2 m)
// Additionally, the NF-enabled channels also fire laser pulses that measure only the near field (0.5 to 7.2 m), at a time other
Expand Down Expand Up @@ -234,7 +267,7 @@ public override bool ValidateWithModel(LidarModel model)
/// It contains properties and ray-generating methods specific to this lidar.
/// </summary>
[Serializable]
public class HesaiQT128C2XLidarConfiguration : BaseLidarConfiguration
public class HesaiQT128C2XLidarConfiguration : LaserBasedRangeLidarConfiguration
{
private static int hesaiQT128LasersBankLength = 32;

Expand Down Expand Up @@ -280,7 +313,7 @@ public override bool ValidateWithModel(LidarModel model)
/// It contains properties and ray-generating methods specific to this lidar.
/// </summary>
[Serializable]
public class HesaiPandar128E4XLidarConfiguration : BaseLidarConfiguration
public class HesaiPandar128E4XLidarConfiguration : LaserBasedRangeLidarConfiguration
{
// High resolution mode changes laser array
public override LaserArray laserArray
Expand Down
13 changes: 10 additions & 3 deletions docs/Components/Sensors/LiDARSensor/LiDARSensor/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,16 @@ horizontal and vertical beam divergence values (as they would be set to 0). Note
- `Max Random Period` - upper bound of time period in seconds used in random mode

- *Additional options (available for some Lidar Model Preset)*
- `Min Range` - minimum range of the sensor (if not avaiable, the range is different for each laser in `Laser Array`)
- `Max Range` - maximum range of the sensor (if not avaiable, the range is different for each laser in `Laser Array`)
- `High Resolution Mode Enabled` - whether to activate high resolution mode (available for `Hesai Pandar 128E4X` LiDAR model)
- Uniform range LiDARs
- `Min Range` - minimum range of the sensor
- `Max Range` - maximum range of the sensor
- Non-uniform range LiDARs
- *Range Override Params*:
- `Enable` - enable/disable range overriding (if disabled, ranges are determined based on the laser ranges described in `Laser Array`)
- `Min Range` - minimum range of the sensor
- `Max Range` - maximum range of the sensor
- Hesai Pandar 128E4X
- `High Resolution Mode Enabled` - whether to activate high resolution mode

#### Output Data
`LidarSensor` provides public methods to extend this pipeline with additional `RGL` nodes.
Expand Down
Loading