Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reflectivity support #72

Open
wants to merge 1 commit into
base: feature/configurable-pc-message/alkam
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Code/FindRGL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set(RGL_VERSION 0.19.0)
set(RGL_VERSION 0.20.0)
set(RGL_TAG v${RGL_VERSION})

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

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

# Read metadata
set(RGL_VERSION_METADATA " ")
set(ROS_DISTRO_METADATA " ")
if (EXISTS ${RGL_VERSION_METADATA_FILE})
file(READ ${RGL_VERSION_METADATA_FILE} RGL_VERSION_METADATA)
endif ()
Expand Down
22 changes: 22 additions & 0 deletions Code/Source/Lidar/LidarRaycaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ namespace RGL
m_rglRaycastResults.m_fields.push_back(RGL_FIELD_RING_ID_U16);
}

if (ROS2::IsFlagEnabled(ROS2::RaycastResultFlags::Reflectivity, flags))
{
m_rglRaycastResults.m_fields.push_back(RGL_FIELD_REFLECTIVITY_F32);
}

m_graph.ConfigureFieldNodes(m_rglRaycastResults.m_fields.data(), m_rglRaycastResults.m_fields.size());
m_graph.SetIsCompactEnabled(!m_returnNonHits);
}
Expand Down Expand Up @@ -190,6 +195,11 @@ namespace RGL
AZStd::copy(m_rglRaycastResults.m_ringId.begin(), m_rglRaycastResults.m_ringId.end(), ring.value().begin());
}

if (auto reflectivity = raycastResults.GetFieldSpan<ROS2::RaycastResultFlags::Reflectivity>(); reflectivity.has_value())
{
AZStd::copy(m_rglRaycastResults.m_reflectivity.begin(), m_rglRaycastResults.m_reflectivity.end(), reflectivity.value().begin());
}

return AZ::Success(m_raycastResults.value());
}

Expand Down Expand Up @@ -308,6 +318,18 @@ namespace RGL
}
}

if (results.IsFieldPresent<ROS2::RaycastResultFlags::Reflectivity>())
{
if (!resultsSize.has_value())
{
resultsSize = rglResults.m_reflectivity.size();
}
else if (resultsSize != rglResults.m_reflectivity.size())
{
return AZStd::nullopt;
}
}

return resultsSize;
}
} // namespace RGL
2 changes: 1 addition & 1 deletion Code/Source/Lidar/LidarSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace RGL

using Features = ROS2::LidarSystemFeatures;
static constexpr auto SupportedFeatures = aznumeric_cast<Features>(
Features::EntityExclusion | Features::Noise | Features::Intensity | Features::Segmentation | Features::RingIds);
Features::EntityExclusion | Features::Noise | Features::Intensity | Features::Segmentation | Features::RingIds | Features::Reflectivity);

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

Expand Down
3 changes: 3 additions & 0 deletions Code/Source/Lidar/PipelineGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ namespace RGL
case RGL_FIELD_RING_ID_U16:
success = success && GetResult(results.m_ringId, RGL_FIELD_RING_ID_U16);
break;
case RGL_FIELD_REFLECTIVITY_F32:
success = success && GetResult(results.m_reflectivity, RGL_FIELD_REFLECTIVITY_F32);
break;
default:
success = false;
AZ_Assert(false, AZStd::string::format("Invalid result field type with RGL id %i!", field).c_str());
Expand Down
1 change: 1 addition & 0 deletions Code/Source/Lidar/PipelineGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ namespace RGL
AZStd::vector<int32_t> m_packedRglEntityId;
AZStd::vector<int32_t> m_isHit;
AZStd::vector<uint16_t> m_ringId;
AZStd::vector<float> m_reflectivity;
};

struct Nodes
Expand Down