Scan Patterns
Some lidars use a MEMS (micro-electromechanical system) to steer the laser beam instead of a motor. To emulate this functionality, use a scan pattern to specify the laser beam origin and direction as a function of time.
This section describes how to use the Generic MEMS 3D Lidar Prefab and the MEMS node to define your own scan pattern.
Define your pattern function
A scan pattern class inherits from ScanPatternHandler
and implements the EvaluatePattern
method. The ScanPatternHandler
provides:
sweepFrequency
: The pattern frequency, that is, how many times it repeats per second.timeOffset
: The time at which the pattern begins, in seconds.
The EvaluatePattern
method computes the laser beam origin and direction as a function of time. The identity quaternion represents a laser beam fired along the positive Z axis of the photosensor.
The MEMS node assumes the function is periodic and may wrap the time around, with a period of 1 / sweepFrequency
seconds.
Here is an example of how to define a circular scan pattern:
using UnityEngine;
public class CircularPattern : ScanPatternHandler
{
public override Pose EvaluatePattern(float t)
{
float degreesPerSecond = 360f * sweepFrequency;
return new Pose(
position: Vector3.zero,
rotation: Quaternion.AngleAxis((t - timeOffset) * degreesPerSecond, Vector3.up)
);
}
}
The MEMS node sets the scan pattern sweepFrequency
and timeOffset
fields, according to its given inputs. For the Generic MEMS 3D Lidar Prefab, you can set the sweep frequency in the properties section of the System Graph Component, in the Inspector window.
Bind your pattern to the MEMS node
The MEMS node uses a scan pattern to move a bound GameObject in the scene. In the case of a MEMS lidar, the MEMS node moves the photosensor. You specify which pattern to use by binding your pattern C# script to the MEMS node binding.
- Add a Generic MEMS 3D Lidar to the scene by dragging the Prefab from SensorSDK's samples into the Hierarchy window.
- Select the lidar GameObject in the Hierarchy window.
- Locate the System Graph Component in the Inspector window.
- Locate the Scan Pattern binding of the MEMS node.
- Drag your scan pattern script onto the Scan Pattern binding.