Skip to content

Commit 9a3d0a4

Browse files
Add pointcloud ordering
Signed-off-by: Aleksander Kamiński <[email protected]>
1 parent 933102e commit 9a3d0a4

File tree

5 files changed

+36
-11
lines changed

5 files changed

+36
-11
lines changed

Code/Source/Lidar/LidarRaycaster.cpp

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace RGL
2929

3030
LidarRaycaster::LidarRaycaster(LidarRaycaster&& other)
3131
: m_uuid{ other.m_uuid }
32-
, m_isMaxRangeEnabled{ other.m_isMaxRangeEnabled }
32+
, m_returnNonHits{ other.m_returnNonHits }
3333
, m_range{ other.m_range }
3434
, m_graph{ std::move(other.m_graph) }
3535
, m_rayTransforms{ AZStd::move(other.m_rayTransforms) }
@@ -169,6 +169,18 @@ namespace RGL
169169
Utils::UnpackRglEntityId);
170170
}
171171

172+
if (auto isHit = raycastResults.GetFieldSpan<ROS2::RaycastResultFlags::IsHit>(); isHit.has_value())
173+
{
174+
AZStd::transform(
175+
m_rglRaycastResults.m_isHit.begin(),
176+
m_rglRaycastResults.m_isHit.end(),
177+
isHit.value().begin(),
178+
[](int32_t isHit)
179+
{
180+
return isHit != 0;
181+
});
182+
}
183+
172184
return AZ::Success(m_raycastResults.value());
173185
}
174186

@@ -193,7 +205,7 @@ namespace RGL
193205
float minRangeNonHitValue = -AZStd::numeric_limits<float>::infinity();
194206
float maxRangeNonHitValue = AZStd::numeric_limits<float>::infinity();
195207

196-
if (m_isMaxRangeEnabled && m_range.has_value())
208+
if (m_returnNonHits && m_range.has_value())
197209
{
198210
minRangeNonHitValue = m_range.value().m_min;
199211
maxRangeNonHitValue = m_range.value().m_max;
@@ -202,10 +214,9 @@ namespace RGL
202214
m_graph.ConfigureRaytraceNodeNonHits(minRangeNonHitValue, maxRangeNonHitValue);
203215
}
204216

205-
void LidarRaycaster::ConfigureMaxRangePointAddition(bool addMaxRangePoints)
217+
void LidarRaycaster::ConfigureNonHitReturn(bool returnNonHits)
206218
{
207-
m_isMaxRangeEnabled = addMaxRangePoints;
208-
219+
m_returnNonHits = returnNonHits;
209220
UpdateNonHitValues();
210221

211222
// We need to configure if points should be compacted to minimize the CPU operations when retrieving raycast results.
@@ -259,11 +270,23 @@ namespace RGL
259270
}
260271
}
261272

273+
if (results.IsFieldPresent<ROS2::RaycastResultFlags::IsHit>())
274+
{
275+
if (!resultsSize.has_value())
276+
{
277+
resultsSize = rglResults.m_isHit.size();
278+
}
279+
else if (resultsSize != rglResults.m_isHit.size())
280+
{
281+
return AZStd::nullopt;
282+
}
283+
}
284+
262285
return resultsSize;
263286
}
264287

265288
bool LidarRaycaster::ShouldEnableCompact() const
266289
{
267-
return !m_raycastResults->IsFieldPresent<ROS2::RaycastResultFlags::Range>() && !m_isMaxRangeEnabled;
290+
return !m_raycastResults->IsFieldPresent<ROS2::RaycastResultFlags::Range>() && !m_returnNonHits;
268291
}
269292
} // namespace RGL

Code/Source/Lidar/LidarRaycaster.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ namespace RGL
4949
[[maybe_unused]] float distanceNoiseStdDevRisePerMeter) override;
5050
void ExcludeEntities(const AZStd::vector<AZ::EntityId>& excludedEntities) override;
5151
void UpdateNonHitValues();
52-
void ConfigureMaxRangePointAddition(bool addMaxRangePoints) override;
52+
void ConfigureNonHitReturn(bool returnNonHits) override;
5353

5454
private:
5555
AZ::Uuid m_uuid;
5656

57-
bool m_isMaxRangeEnabled{ false }; //!< Determines whether max range point addition is enabled.
57+
bool m_returnNonHits{ false }; //!< Determines whether max range point addition is enabled.
5858

5959
AZStd::optional<ROS2::RayRange> m_range{};
6060
AZStd::vector<AZ::Matrix3x4> m_rayTransforms{ AZ::Matrix3x4::CreateIdentity() };

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::MaxRangePoints | Features::Noise | Features::Intensity | Features::Segmentation);
33+
Features::EntityExclusion | Features::Noise | Features::Intensity | Features::Segmentation);
3434

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

Code/Source/Lidar/PipelineGraph.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,9 @@ namespace RGL
142142
case RGL_FIELD_ENTITY_ID_I32:
143143
success = success && GetResult(results.m_packedRglEntityId, RGL_FIELD_ENTITY_ID_I32);
144144
break;
145-
case RGL_FIELD_IS_HIT_I32: // Not needed.
146-
continue;
145+
case RGL_FIELD_IS_HIT_I32:
146+
success = success && GetResult(results.m_isHit, RGL_FIELD_IS_HIT_I32);
147+
break;
147148
default:
148149
success = false;
149150
AZ_Assert(false, AZStd::string::format("Invalid result field type with RGL id %i!", field).c_str());

Code/Source/Lidar/PipelineGraph.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ namespace RGL
3838
AZStd::vector<float> m_distance;
3939
AZStd::vector<float> m_intensity;
4040
AZStd::vector<int32_t> m_packedRglEntityId;
41+
AZStd::vector<int32_t> m_isHit;
4142
};
4243

4344
struct Nodes

0 commit comments

Comments
 (0)