Skip to content

Made it possible to initialize LiDARSensor later so that it works with the built app. #197

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

Merged
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,16 @@ public class DepthBufferLiDARSensor : LiDARSensor

protected override void Init()
{
base.Init();
if (scanPattern == null)
{
return;
}
Initialize();
}

public override void Initialize()
{
base.Initialize();
_transform = this.transform;
SetupCamera();
LoadScanData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ public abstract class LiDARSensor : UnitySensor, IPointCloudInterface<PointXYZI>
public int pointsNum { get => _pointsNumPerScan; }

protected override void Init()
{
if (_scanPattern == null)
{
return;
}
Initialize();
}

public virtual void Initialize()
{
_pointsNumPerScan = Mathf.Clamp(_pointsNumPerScan, 1, scanPattern.size);
_pointCloud = new PointCloud<PointXYZI>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,16 @@ public class RaycastLiDARSensor : LiDARSensor

protected override void Init()
{
base.Init();
if (scanPattern == null)
{
return;
}
Initialize();
}

public override void Initialize()
{
base.Initialize();

_transform = this.transform;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ public class LiDARPointCloud2MsgPublisher : PointCloud2MsgPublisher<PointXYZI>

private void Awake()
{
if (_source == null)
{
Debug.LogError("Source is not set.");
return;
}
_serializer.SetSource(_source as IPointCloudInterface<PointXYZI>);
}
}
Expand Down
Loading