8
8
9
9
namespace AGXUnity . Sensor
10
10
{
11
+ public interface IModelData { }
12
+
13
+ [ Serializable ]
14
+ public class OusterData : IModelData
15
+ {
16
+ public LidarModelOusterOS . ChannelCount ChannelCount = LidarModelOusterOS . ChannelCount . ch_32 ;
17
+ public LidarModelOusterOS . BeamSpacing BeamSpacing = LidarModelOusterOS . BeamSpacing . Uniform ;
18
+ public LidarModelOusterOS . LidarMode LidarMode = LidarModelOusterOS . LidarMode . Mode_512x20 ;
19
+ }
20
+
21
+ [ Serializable ]
22
+ public class GenericSweepData : IModelData
23
+ {
24
+ public float Frequency = 10.0f ;
25
+ public float HorizontalFoV = 360.0f ;
26
+ public float VerticalFoV = 35.0f ;
27
+ public float HorizontalResolution = 0.5f ;
28
+ public float VerticalResolution = 0.5f ;
29
+ }
30
+
11
31
public enum LidarModelPreset
12
32
{
13
33
NONE ,
@@ -34,7 +54,29 @@ public class LidarSensor : ScriptComponent
34
54
* The Model, or preset, of this Lidar.
35
55
* Changing this will assign Model specific properties to this Lidar.
36
56
*/
37
- public LidarModelPreset LidarModelPreset = LidarModelPreset . LidarModelOusterOS1 ;
57
+ [ SerializeField ]
58
+ private LidarModelPreset m_lidarModelPreset = LidarModelPreset . LidarModelOusterOS1 ;
59
+
60
+ public LidarModelPreset LidarModelPreset
61
+ {
62
+ get => m_lidarModelPreset ;
63
+ set
64
+ {
65
+ m_lidarModelPreset = value ;
66
+ ModelData = value switch
67
+ {
68
+ LidarModelPreset . LidarModelOusterOS0 => new OusterData ( ) ,
69
+ LidarModelPreset . LidarModelOusterOS1 => new OusterData ( ) ,
70
+ LidarModelPreset . LidarModelOusterOS2 => new OusterData ( ) ,
71
+ LidarModelPreset . LidarModelGeneric360HorizontalSweep => new GenericSweepData ( ) ,
72
+ LidarModelPreset . NONE => null ,
73
+ } ;
74
+ }
75
+ }
76
+
77
+
78
+ [ field: SerializeReference ]
79
+ public IModelData ModelData { get ; private set ; } = new OusterData ( ) ;
38
80
39
81
/**
40
82
* The minimum and maximum range of the Lidar Sensor [m].
@@ -183,19 +225,27 @@ private LidarModel CreateLidarModel( LidarModelPreset preset )
183
225
184
226
switch ( preset ) {
185
227
case LidarModelPreset . LidarModelGeneric360HorizontalSweep :
186
- lidarModel = new LidarModelGeneric360HorizontalSweep ( 10f ) ; // TODO Default frequency for now, implement lidar settings
228
+ GenericSweepData sweepData = ModelData as GenericSweepData ;
229
+ lidarModel = new LidarModelHorizontalSweep (
230
+ Mathf . Deg2Rad * new agx . Vec2 ( sweepData . HorizontalFoV , sweepData . VerticalFoV ) ,
231
+ Mathf . Deg2Rad * new agx . Vec2 ( sweepData . HorizontalResolution , sweepData . VerticalResolution ) ,
232
+ sweepData . Frequency
233
+ ) ; // TODO Default frequency for now, implement lidar settings
187
234
break ;
188
235
189
236
case LidarModelPreset . LidarModelOusterOS0 :
190
- lidarModel = new LidarModelOusterOS0 ( ) ;
237
+ OusterData ousterData = ModelData as OusterData ;
238
+ lidarModel = new LidarModelOusterOS0 ( ousterData . ChannelCount , ousterData . BeamSpacing , ousterData . LidarMode ) ;
191
239
break ;
192
240
193
241
case LidarModelPreset . LidarModelOusterOS1 :
194
- lidarModel = new LidarModelOusterOS1 ( ) ;
242
+ ousterData = ModelData as OusterData ;
243
+ lidarModel = new LidarModelOusterOS1 ( ousterData . ChannelCount , ousterData . BeamSpacing , ousterData . LidarMode ) ;
195
244
break ;
196
245
197
246
case LidarModelPreset . LidarModelOusterOS2 :
198
- lidarModel = new LidarModelOusterOS2 ( ) ;
247
+ ousterData = ModelData as OusterData ;
248
+ lidarModel = new LidarModelOusterOS2 ( ousterData . ChannelCount , ousterData . BeamSpacing , ousterData . LidarMode ) ;
199
249
break ;
200
250
201
251
case LidarModelPreset . NONE :
0 commit comments