Skip to content

Commit cd9867d

Browse files
Add ring ID provider support
Signed-off-by: Aleksander Kamiński <[email protected]>
1 parent 1d61a19 commit cd9867d

File tree

6 files changed

+47
-6
lines changed

6 files changed

+47
-6
lines changed

Code/Source/Lidar/LidarRaycaster.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ namespace RGL
113113
m_rglRaycastResults.m_fields.push_back(RGL_FIELD_ENTITY_ID_I32);
114114
}
115115

116+
if (ROS2::IsFlagEnabled(ROS2::RaycastResultFlags::Ring, flags))
117+
{
118+
m_rglRaycastResults.m_fields.push_back(RGL_FIELD_RING_ID_U16);
119+
}
120+
116121
m_graph.ConfigureFieldNodes(m_rglRaycastResults.m_fields.data(), m_rglRaycastResults.m_fields.size());
117122
m_graph.SetIsCompactEnabled(!m_returnNonHits);
118123
}
@@ -180,6 +185,11 @@ namespace RGL
180185
});
181186
}
182187

188+
if (auto ring = raycastResults.GetFieldSpan<ROS2::RaycastResultFlags::Ring>(); ring.has_value())
189+
{
190+
AZStd::copy(m_rglRaycastResults.m_ringId.begin(), m_rglRaycastResults.m_ringId.end(), ring.value().begin());
191+
}
192+
183193
return AZ::Success(m_raycastResults.value());
184194
}
185195

@@ -222,6 +232,11 @@ namespace RGL
222232
m_graph.SetIsCompactEnabled(!returnNonHits);
223233
}
224234

235+
void LidarRaycaster::ConfigureRayRingIds(const AZStd::vector<AZ::s32>& ringIds)
236+
{
237+
m_graph.ConfigureRayRingIds(ringIds);
238+
}
239+
225240
AZStd::optional<size_t> LidarRaycaster::GetRglResultsSize(
226241
const PipelineGraph::RaycastResults& rglResults, const ROS2::RaycastResults& results)
227242
{
@@ -281,6 +296,18 @@ namespace RGL
281296
}
282297
}
283298

299+
if (results.IsFieldPresent<ROS2::RaycastResultFlags::Ring>())
300+
{
301+
if (!resultsSize.has_value())
302+
{
303+
resultsSize = rglResults.m_ringId.size();
304+
}
305+
else if (resultsSize != rglResults.m_ringId.size())
306+
{
307+
return AZStd::nullopt;
308+
}
309+
}
310+
284311
return resultsSize;
285312
}
286313
} // namespace RGL

Code/Source/Lidar/LidarRaycaster.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ namespace RGL
5050
void ExcludeEntities(const AZStd::vector<AZ::EntityId>& excludedEntities) override;
5151
void UpdateNonHitValues();
5252
void ConfigureNonHitReturn(bool returnNonHits) override;
53+
void ConfigureRayRingIds(const AZStd::vector<AZ::s32>& ringIds) override;
5354

5455
private:
5556
AZ::Uuid m_uuid;

Code/Source/Lidar/LidarSystem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace RGL
3030

3131
using Features = ROS2::LidarSystemFeatures;
3232
static constexpr auto SupportedFeatures = aznumeric_cast<Features>(
33-
Features::EntityExclusion | Features::Noise | Features::Intensity | Features::Segmentation);
33+
Features::EntityExclusion | Features::Noise | Features::Intensity | Features::Segmentation | Features::RingIds);
3434

3535
ROS2::LidarSystemRequestBus::Handler::BusConnect(AZ_CRC(name));
3636

Code/Source/Lidar/PipelineGraph.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ namespace RGL
2121
{
2222
ConfigureRayPosesNode({ Utils::IdentityTransform });
2323
ConfigureRayRangesNode(0.0f, 1.0f);
24+
ConfigureRayRingIds({ 0 });
2425
ConfigureLidarTransformNode(AZ::Matrix3x4::CreateIdentity());
2526
RGL_CHECK(rgl_node_raytrace(&m_nodes.m_rayTrace, nullptr));
2627
RGL_CHECK(rgl_node_points_compact_by_field(&m_nodes.m_pointsCompact, RGL_FIELD_IS_HIT_I32));
@@ -30,7 +31,8 @@ namespace RGL
3031

3132
// Non-conditional connections
3233
RGL_CHECK(rgl_graph_node_add_child(m_nodes.m_rayPoses, m_nodes.m_rayRanges));
33-
RGL_CHECK(rgl_graph_node_add_child(m_nodes.m_rayRanges, m_nodes.m_lidarTransform));
34+
RGL_CHECK(rgl_graph_node_add_child(m_nodes.m_rayRanges, m_nodes.m_rayRingIds));
35+
RGL_CHECK(rgl_graph_node_add_child(m_nodes.m_rayRingIds, m_nodes.m_lidarTransform));
3436

3537
InitializeConditionalConnections();
3638
}
@@ -80,6 +82,11 @@ namespace RGL
8082
RGL_CHECK(rgl_node_rays_set_range(&m_nodes.m_rayRanges, &range, 1));
8183
}
8284

85+
void PipelineGraph::ConfigureRayRingIds(const AZStd::vector<AZ::s32>& rayRingIds)
86+
{
87+
RGL_CHECK(rgl_node_rays_set_ring_ids(&m_nodes.m_rayRingIds, rayRingIds.data(), rayRingIds.size()));
88+
}
89+
8390
void PipelineGraph::ConfigureFieldNodes(const rgl_field_t* fields, size_t size)
8491
{
8592
RGL_CHECK(rgl_node_points_yield(&m_nodes.m_pointsYield, fields, aznumeric_cast<int32_t>(size)));
@@ -145,6 +152,9 @@ namespace RGL
145152
case RGL_FIELD_IS_HIT_I32:
146153
success = success && GetResult(results.m_isHit, RGL_FIELD_IS_HIT_I32);
147154
break;
155+
case RGL_FIELD_RING_ID_U16:
156+
success = success && GetResult(results.m_ringId, RGL_FIELD_RING_ID_U16);
157+
break;
148158
default:
149159
success = false;
150160
AZ_Assert(false, AZStd::string::format("Invalid result field type with RGL id %i!", field).c_str());

Code/Source/Lidar/PipelineGraph.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,14 @@ namespace RGL
3939
AZStd::vector<float> m_intensity;
4040
AZStd::vector<int32_t> m_packedRglEntityId;
4141
AZStd::vector<int32_t> m_isHit;
42+
AZStd::vector<uint16_t> m_ringId;
4243
};
4344

4445
struct Nodes
4546
{
46-
rgl_node_t m_rayPoses{ nullptr }, m_rayRanges{ nullptr }, m_lidarTransform{ nullptr }, m_angularNoise{ nullptr },
47-
m_rayTrace{ nullptr }, m_distanceNoise{ nullptr }, m_rayTraceYield{ nullptr }, m_pointsCompact{ nullptr },
48-
m_pointsYield{ nullptr };
47+
rgl_node_t m_rayPoses{ nullptr }, m_rayRanges{ nullptr }, m_rayRingIds{ nullptr }, m_lidarTransform{ nullptr },
48+
m_angularNoise{ nullptr }, m_rayTrace{ nullptr }, m_distanceNoise{ nullptr }, m_rayTraceYield{ nullptr },
49+
m_pointsCompact{ nullptr }, m_pointsYield{ nullptr };
4950
};
5051

5152
PipelineGraph();
@@ -58,6 +59,7 @@ namespace RGL
5859

5960
void ConfigureRayPosesNode(const AZStd::vector<rgl_mat3x4f>& rayPoses);
6061
void ConfigureRayRangesNode(float min, float max);
62+
void ConfigureRayRingIds(const AZStd::vector<AZ::s32>& rayRingIds);
6163
void ConfigureFieldNodes(const rgl_field_t* fields, size_t size);
6264
void ConfigureLidarTransformNode(const AZ::Matrix3x4& lidarTransform);
6365
void ConfigureAngularNoiseNode(float angularNoiseStdDev);

static/PipelineGraph.mmd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
flowchart TD
22
RP[Ray Poses] --> RR[Ray Ranges]
3-
RR --> LT[Lidar Transform]
3+
RR --> RRI[Ray Ring Ids]
4+
RRI --> LT[Lidar Transform]
45
LT -->|Noise enabled| AN[Angular Noise]
56
LT -->|Noise disabled| RT[Ray Trace]
67
AN --> RT

0 commit comments

Comments
 (0)