Skip to content

Commit d09b8d2

Browse files
Add reflectivity support
Signed-off-by: Aleksander Kamiński <[email protected]>
1 parent 122b41e commit d09b8d2

File tree

5 files changed

+28
-4
lines changed

5 files changed

+28
-4
lines changed

Code/FindRGL.cmake

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
set(RGL_VERSION 0.19.0)
14+
set(RGL_VERSION 0.20.0)
1515
set(RGL_TAG v${RGL_VERSION})
1616

1717
# Metadata files used to determine if RGL download is required
1818
set(RGL_VERSION_METADATA_FILE ${CMAKE_CURRENT_BINARY_DIR}/RGL_VERSION)
19-
set(ROS_DISTRO_METADATA_FILE ${CMAKE_CURRENT_BINARY_DIR}/ROS_DISTRO)
2019

2120
set(ROS_DISTRO $ENV{ROS_DISTRO})
2221
set(RGL_LINUX_ZIP_FILENAME_BASE RGL-core-linux-x64)
@@ -42,7 +41,6 @@ if (NOT EXISTS ${RGL_DOWNLOAD_IN_PROGRESS_FILE})
4241

4342
# Read metadata
4443
set(RGL_VERSION_METADATA " ")
45-
set(ROS_DISTRO_METADATA " ")
4644
if (EXISTS ${RGL_VERSION_METADATA_FILE})
4745
file(READ ${RGL_VERSION_METADATA_FILE} RGL_VERSION_METADATA)
4846
endif ()

Code/Source/Lidar/LidarRaycaster.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ namespace RGL
118118
m_rglRaycastResults.m_fields.push_back(RGL_FIELD_RING_ID_U16);
119119
}
120120

121+
if (ROS2::IsFlagEnabled(ROS2::RaycastResultFlags::Reflectivity, flags))
122+
{
123+
m_rglRaycastResults.m_fields.push_back(RGL_FIELD_REFLECTIVITY_F32);
124+
}
125+
121126
m_graph.ConfigureFieldNodes(m_rglRaycastResults.m_fields.data(), m_rglRaycastResults.m_fields.size());
122127
m_graph.SetIsCompactEnabled(!m_returnNonHits);
123128
}
@@ -190,6 +195,11 @@ namespace RGL
190195
AZStd::copy(m_rglRaycastResults.m_ringId.begin(), m_rglRaycastResults.m_ringId.end(), ring.value().begin());
191196
}
192197

198+
if (auto reflectivity = raycastResults.GetFieldSpan<ROS2::RaycastResultFlags::Reflectivity>(); reflectivity.has_value())
199+
{
200+
AZStd::copy(m_rglRaycastResults.m_reflectivity.begin(), m_rglRaycastResults.m_reflectivity.end(), reflectivity.value().begin());
201+
}
202+
193203
return AZ::Success(m_raycastResults.value());
194204
}
195205

@@ -308,6 +318,18 @@ namespace RGL
308318
}
309319
}
310320

321+
if (results.IsFieldPresent<ROS2::RaycastResultFlags::Reflectivity>())
322+
{
323+
if (!resultsSize.has_value())
324+
{
325+
resultsSize = rglResults.m_reflectivity.size();
326+
}
327+
else if (resultsSize != rglResults.m_reflectivity.size())
328+
{
329+
return AZStd::nullopt;
330+
}
331+
}
332+
311333
return resultsSize;
312334
}
313335
} // namespace RGL

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

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

Code/Source/Lidar/PipelineGraph.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ namespace RGL
155155
case RGL_FIELD_RING_ID_U16:
156156
success = success && GetResult(results.m_ringId, RGL_FIELD_RING_ID_U16);
157157
break;
158+
case RGL_FIELD_REFLECTIVITY_F32:
159+
success = success && GetResult(results.m_reflectivity, RGL_FIELD_REFLECTIVITY_F32);
160+
break;
158161
default:
159162
success = false;
160163
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
@@ -40,6 +40,7 @@ namespace RGL
4040
AZStd::vector<int32_t> m_packedRglEntityId;
4141
AZStd::vector<int32_t> m_isHit;
4242
AZStd::vector<uint16_t> m_ringId;
43+
AZStd::vector<float> m_reflectivity;
4344
};
4445

4546
struct Nodes

0 commit comments

Comments
 (0)