Skip to content
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
1 change: 1 addition & 0 deletions Gems/ROS2/Code/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ ly_add_target(
AZ::AzCore
AZ::AzFramework
Gem::Atom_RPI.Public
Gem::Atom_RHI.Reflect
Gem::Atom_Feature_Common.Static
Gem::Atom_Component_DebugCamera.Static
Gem::Atom_AtomBridge.Static
Expand Down
35 changes: 35 additions & 0 deletions Gems/ROS2/Code/Source/Camera/CameraSensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
#include <Atom/RPI.Public/RPISystemInterface.h>
#include <Atom/RPI.Public/RenderPipeline.h>
#include <Atom/RPI.Public/Scene.h>
#include <Atom/RPI.Reflect/Asset/AssetUtils.h>
#include <AzCore/Math/MatrixUtils.h>
#include <AzCore/Settings/SettingsRegistry.h>
#include <AzCore/Component/ComponentApplicationBus.h>
#include <AzFramework/Components/TransformComponent.h>
#include <AzFramework/Scene/SceneSystemInterface.h>
#include <PostProcess/PostProcessFeatureProcessor.h>
Expand Down Expand Up @@ -128,6 +130,39 @@ namespace ROS2
m_view->SetViewToClipMatrix(m_cameraSensorDescription.m_viewToClipMatrix);
m_scene = AZ::RPI::RPISystemInterface::Get()->GetSceneByName(AZ::Name("Main"));

// In console mode, since there is no default pipeline, a BRDF texture needs to be manually initialized.
AZ::ApplicationTypeQuery appType;
AZ::ComponentApplicationBus::Broadcast(&AZ::ComponentApplicationBus::Events::QueryApplicationType, appType);
if (appType.IsConsoleMode())
{
auto brdfpipelineName = AZStd::string::format(
"%sBRDF_Pipeline%s",
m_cameraSensorDescription.m_cameraName.c_str(),
m_entityId.ToString().c_str());
AZ::RPI::RenderPipelineDescriptor brdfPipelineDesc;
brdfPipelineDesc.m_mainViewTagName = "MainCamera";
brdfPipelineDesc.m_name = brdfpipelineName;
brdfPipelineDesc.m_rootPassTemplate = "BRDFTexturePipeline";
brdfPipelineDesc.m_executeOnce = true;

const AZStd::shared_ptr<const AZ::RPI::PassTemplate> brdfTextureTemplate =
AZ::RPI::PassSystemInterface::Get()->GetPassTemplate(AZ::Name("BRDFTextureTemplate"));
AZ::Data::Asset<AZ::RPI::AttachmentImageAsset> brdfImageAsset = AZ::RPI::AssetUtils::LoadAssetById<
AZ::RPI::AttachmentImageAsset>(
brdfTextureTemplate->m_imageAttachments[0].m_assetRef.m_assetId,
AZ::RPI::AssetUtils::TraceLevel::Error);
if (brdfImageAsset.IsReady())
{
m_brdfTexture = AZ::RPI::AttachmentImage::FindOrCreate(brdfImageAsset);
}

if (!m_scene->GetRenderPipeline(AZ::Name(brdfPipelineDesc.m_name)))
{
AZ::RPI::RenderPipelinePtr brdfTexturePipeline = AZ::RPI::RenderPipeline::CreateRenderPipeline(brdfPipelineDesc);
m_scene->AddRenderPipeline(brdfTexturePipeline);
}
}

auto cameraPipelineTypeName = Internal::PipelineNameFromChannelType(GetChannelType());

m_pipelineName = AZStd::string::format(
Expand Down
3 changes: 3 additions & 0 deletions Gems/ROS2/Code/Source/Camera/CameraSensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include <sensor_msgs/msg/camera_info.hpp>
#include <sensor_msgs/msg/image.hpp>
#include <std_msgs/msg/header.hpp>
#include <AtomCore/Instance/Instance.h>
#include <Atom/RPI.Reflect/Image/AttachmentImageAsset.h>

namespace ROS2
{
Expand Down Expand Up @@ -55,6 +57,7 @@ namespace ROS2
AZ::EntityId m_entityId;
AZ::RPI::RenderPipelinePtr m_pipeline;
AZStd::string m_pipelineName;
AZ::Data::Instance<AZ::RPI::AttachmentImage> m_brdfTexture;

//! Request a frame from the rendering pipeline
//! @param cameraPose - current camera pose from which the rendering should take place
Expand Down