Skip to content

Commit

Permalink
Add regression test for Radar
Browse files Browse the repository at this point in the history
  • Loading branch information
msz-rai committed Mar 18, 2024
1 parent 7e0f19c commit cef1cbc
Show file tree
Hide file tree
Showing 2 changed files with 242 additions and 20 deletions.
71 changes: 52 additions & 19 deletions Assets/Tests/PlayMode/Sensors/SensorsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,13 @@ public class SensorsTest

// LiDAR
RGLUnityPlugin.LidarSensor lidarSensor;
ROS2.ISubscription<sensor_msgs.msg.PointCloud2> lidarSubscription;
List<sensor_msgs.msg.PointCloud2> lidarMessages;

// Radar
RGLUnityPlugin.RadarSensor radarSensor;

// LiDAR & Radar
ROS2.ISubscription<sensor_msgs.msg.PointCloud2> pointCloudSubscription;
List<sensor_msgs.msg.PointCloud2> pointCloudMessages;

// IMU
ImuSensor imuSensor;
Expand Down Expand Up @@ -67,45 +72,73 @@ public IEnumerator Setup()

gnssSensor = GameObject.FindObjectOfType<GnssSensor>();
lidarSensor = GameObject.FindObjectOfType<RGLUnityPlugin.LidarSensor>();
radarSensor = GameObject.FindObjectOfType<RGLUnityPlugin.RadarSensor>();
imuSensor = GameObject.FindObjectOfType<ImuSensor>();

yield return null;
}

[UnityTest]
public IEnumerator LiDAR()
private void CreatePointCloud2Subscription(PointCloud2Publisher rglRosPublisher)
{
Assert.NotNull(lidarSensor);
RglLidarPublisher lidarRos2Publisher = lidarSensor.GetComponent<RglLidarPublisher>();

Assert.AreEqual(((byte)lidarRos2Publisher.qos.reliabilityPolicy) , ((byte)ROS2.ReliabilityPolicy.QOS_POLICY_RELIABILITY_BEST_EFFORT));

QoSSettings QosSettingsLidar = new QoSSettings()
QoSSettings qosSettingsLidar = new QoSSettings()
{
ReliabilityPolicy = ROS2.ReliabilityPolicy.QOS_POLICY_RELIABILITY_BEST_EFFORT,
DurabilityPolicy = ROS2.DurabilityPolicy.QOS_POLICY_DURABILITY_VOLATILE,
HistoryPolicy = ROS2.HistoryPolicy.QOS_POLICY_HISTORY_KEEP_LAST,
Depth = 1,
};

pointCloudMessages = new List<sensor_msgs.msg.PointCloud2>(); // Clear messages
pointCloudSubscription?.Dispose(); // Dispose previous subscription
pointCloudSubscription = SimulatorROS2Node.CreateSubscription<sensor_msgs.msg.PointCloud2>(
rglRosPublisher.topic, msg =>
{
pointCloudMessages.Add(msg);
}, qosSettingsLidar.GetQoSProfile());
}

[UnityTest]
public IEnumerator LiDAR()
{
Assert.NotNull(lidarSensor);
RglLidarPublisher lidarRos2Publisher = lidarSensor.GetComponent<RglLidarPublisher>();

Assert.AreEqual((byte)lidarRos2Publisher.qos.reliabilityPolicy , (byte)ROS2.ReliabilityPolicy.QOS_POLICY_RELIABILITY_BEST_EFFORT);

Assert.NotZero(lidarRos2Publisher.pointCloud2Publishers.Count);

// Test all LiDAR PointCloud2 publishers
foreach (var publisher in lidarRos2Publisher.pointCloud2Publishers)
{
lidarMessages = new List<sensor_msgs.msg.PointCloud2>();
lidarSubscription?.Dispose();
lidarSubscription = SimulatorROS2Node.CreateSubscription<sensor_msgs.msg.PointCloud2>(
publisher.topic, msg =>
{
lidarMessages.Add(msg);
}, QosSettingsLidar.GetQoSProfile());
CreatePointCloud2Subscription(publisher);
yield return new WaitForSeconds(testDuration);

Assert.IsNotEmpty(pointCloudMessages);
Assert.AreEqual(pointCloudMessages.Count, (int)(testDuration * lidarSensor.AutomaticCaptureHz));
}
}

[UnityTest]
public IEnumerator Radar()
{
Assert.NotNull(radarSensor);
RglLidarPublisher radarRos2Publisher = radarSensor.GetComponent<RglLidarPublisher>();

Assert.AreEqual((byte)radarRos2Publisher.qos.reliabilityPolicy , (byte)ROS2.ReliabilityPolicy.QOS_POLICY_RELIABILITY_BEST_EFFORT);

Assert.NotZero(radarRos2Publisher.pointCloud2Publishers.Count);

// Test all Radar PointCloud2 publishers
foreach (var publisher in radarRos2Publisher.pointCloud2Publishers)
{
CreatePointCloud2Subscription(publisher);
yield return new WaitForSeconds(testDuration);

Assert.IsNotEmpty(lidarMessages);
Assert.AreEqual(lidarMessages.Count, (int)(testDuration * lidarSensor.AutomaticCaptureHz));
Assert.IsNotEmpty(pointCloudMessages);
Assert.AreEqual(pointCloudMessages.Count, (int)(testDuration * radarSensor.automaticCaptureHz));
}

// TODO: Test RadarScan publishers (radar_msgs_assembly needed)
}

[UnityTest]
Expand Down
191 changes: 190 additions & 1 deletion Assets/Tests/PlayMode/Sensors/SensorsTest.unity
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,68 @@ Transform:
m_CorrespondingSourceObject: {fileID: 3068494487180298279, guid: 9351c3661d105f12f9fe2819a1203053, type: 3}
m_PrefabInstance: {fileID: 1654955254}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &1167984288
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 1802577586}
m_Modifications:
- target: {fileID: 3829000484750794456, guid: 2af2d97e44fa5ea01b418ea17b9847b5, type: 3}
propertyPath: m_Name
value: SmartmicroDRVEGRD169
objectReference: {fileID: 0}
- target: {fileID: 7202717521197378927, guid: 2af2d97e44fa5ea01b418ea17b9847b5, type: 3}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7202717521197378927, guid: 2af2d97e44fa5ea01b418ea17b9847b5, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7202717521197378927, guid: 2af2d97e44fa5ea01b418ea17b9847b5, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7202717521197378927, guid: 2af2d97e44fa5ea01b418ea17b9847b5, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7202717521197378927, guid: 2af2d97e44fa5ea01b418ea17b9847b5, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7202717521197378927, guid: 2af2d97e44fa5ea01b418ea17b9847b5, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7202717521197378927, guid: 2af2d97e44fa5ea01b418ea17b9847b5, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7202717521197378927, guid: 2af2d97e44fa5ea01b418ea17b9847b5, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7202717521197378927, guid: 2af2d97e44fa5ea01b418ea17b9847b5, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7202717521197378927, guid: 2af2d97e44fa5ea01b418ea17b9847b5, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7202717521197378927, guid: 2af2d97e44fa5ea01b418ea17b9847b5, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 2af2d97e44fa5ea01b418ea17b9847b5, type: 3}
--- !u!4 &1238688459 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 7202717521197378927, guid: 2af2d97e44fa5ea01b418ea17b9847b5, type: 3}
m_PrefabInstance: {fileID: 1167984288}
m_PrefabAsset: {fileID: 0}
--- !u!1 &1317237649
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -976,6 +1038,37 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1802577585
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1802577586}
m_Layer: 0
m_Name: Radar
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1802577586
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1802577585}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: 20}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1238688459}
m_Father: {fileID: 0}
m_RootOrder: 8
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1876417759
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1005,7 +1098,103 @@ Transform:
m_Children:
- {fileID: 1321549088}
m_Father: {fileID: 0}
m_RootOrder: 8
m_RootOrder: 9
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &2092000842
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2092000846}
- component: {fileID: 2092000845}
- component: {fileID: 2092000844}
- component: {fileID: 2092000843}
m_Layer: 0
m_Name: Wall
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!65 &2092000843
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2092000842}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 1, y: 1, z: 1}
m_Center: {x: 0, y: 0, z: 0}
--- !u!23 &2092000844
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2092000842}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 257
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 73c176f402d2c2f4d929aa5da7585d17, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!33 &2092000845
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2092000842}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &2092000846
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2092000842}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 40}
m_LocalScale: {x: 10, y: 10, z: 0.1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 10
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &2130635138
GameObject:
Expand Down

0 comments on commit cef1cbc

Please sign in to comment.