|
@@ -8,6 +8,7 @@
|
|
#pragma once
|
|
#pragma once
|
|
|
|
|
|
#include <Atom/Feature/Utils/FrameCaptureBus.h>
|
|
#include <Atom/Feature/Utils/FrameCaptureBus.h>
|
|
|
|
+#include <AzCore/std/containers/span.h>
|
|
#include <ROS2/ROS2GemUtilities.h>
|
|
#include <ROS2/ROS2GemUtilities.h>
|
|
#include <chrono>
|
|
#include <chrono>
|
|
#include <rclcpp/publisher.hpp>
|
|
#include <rclcpp/publisher.hpp>
|
|
@@ -25,7 +26,8 @@ namespace ROS2
|
|
//! @param verticalFov - vertical field of view of camera sensor
|
|
//! @param verticalFov - vertical field of view of camera sensor
|
|
//! @param width - camera image width in pixels
|
|
//! @param width - camera image width in pixels
|
|
//! @param height - camera image height in pixels
|
|
//! @param height - camera image height in pixels
|
|
- CameraSensorDescription(const AZStd::string& cameraName, float verticalFov, int width, int height);
|
|
|
|
|
|
+ //! @param entityId - entityId of camera sensor
|
|
|
|
+ CameraSensorDescription(const AZStd::string& cameraName, float verticalFov, int width, int height, AZ::EntityId entityId);
|
|
|
|
|
|
const float m_verticalFieldOfViewDeg; //!< camera vertical field of view
|
|
const float m_verticalFieldOfViewDeg; //!< camera vertical field of view
|
|
const int m_width; //!< camera image width in pixels
|
|
const int m_width; //!< camera image width in pixels
|
|
@@ -35,7 +37,7 @@ namespace ROS2
|
|
const float m_aspectRatio; //!< camera image aspect ratio; equal to (width / height)
|
|
const float m_aspectRatio; //!< camera image aspect ratio; equal to (width / height)
|
|
const AZ::Matrix4x4 m_viewToClipMatrix; //!< camera view to clip space transform matrix; derived from other parameters
|
|
const AZ::Matrix4x4 m_viewToClipMatrix; //!< camera view to clip space transform matrix; derived from other parameters
|
|
const AZStd::array<double, 9> m_cameraIntrinsics; //!< camera intrinsics; derived from other parameters
|
|
const AZStd::array<double, 9> m_cameraIntrinsics; //!< camera intrinsics; derived from other parameters
|
|
-
|
|
|
|
|
|
+ const AZ::EntityId m_entityId; //! Entity Id that is owning this sensor.
|
|
private:
|
|
private:
|
|
AZ::Matrix4x4 MakeViewToClipMatrix() const;
|
|
AZ::Matrix4x4 MakeViewToClipMatrix() const;
|
|
|
|
|
|
@@ -57,11 +59,11 @@ namespace ROS2
|
|
virtual ~CameraSensor();
|
|
virtual ~CameraSensor();
|
|
|
|
|
|
//! Publish Image Message frame from rendering pipeline
|
|
//! Publish Image Message frame from rendering pipeline
|
|
- //! @param publisher - ROS2 publisher to publish image in future
|
|
|
|
|
|
+ //! @param publishers - ROS2 publishers to publish image in future : color, depth ...
|
|
//! @param header - header with filled message information (frame, timestamp, seq)
|
|
//! @param header - header with filled message information (frame, timestamp, seq)
|
|
//! @param cameraPose - current camera pose from which the rendering should take place
|
|
//! @param cameraPose - current camera pose from which the rendering should take place
|
|
- void RequestMessagePublication(
|
|
|
|
- std::shared_ptr<rclcpp::Publisher<sensor_msgs::msg::Image>> publisher,
|
|
|
|
|
|
+ virtual void RequestMessagePublication(
|
|
|
|
+ AZStd::span<std::shared_ptr<rclcpp::Publisher<sensor_msgs::msg::Image>>> publishers,
|
|
const AZ::Transform& cameraPose,
|
|
const AZ::Transform& cameraPose,
|
|
const std_msgs::msg::Header& header);
|
|
const std_msgs::msg::Header& header);
|
|
|
|
|
|
@@ -69,16 +71,17 @@ namespace ROS2
|
|
[[nodiscard]] const CameraSensorDescription& GetCameraSensorDescription() const;
|
|
[[nodiscard]] const CameraSensorDescription& GetCameraSensorDescription() const;
|
|
|
|
|
|
private:
|
|
private:
|
|
- //! Request a frame from the rendering pipeline
|
|
|
|
|
|
+ //! Publish Image Message frame from rendering pipeline
|
|
|
|
+ //! @param publisher - ROS2 publisher to publish image in future
|
|
|
|
+ //! @param header - header with filled message information (frame, timestamp, seq)
|
|
//! @param cameraPose - current camera pose from which the rendering should take place
|
|
//! @param cameraPose - current camera pose from which the rendering should take place
|
|
- //! @param callback - callback function object that will be called when capture is ready
|
|
|
|
- //! it's argument is readback structure containing, among other thins, captured image
|
|
|
|
- void RequestFrame(
|
|
|
|
- const AZ::Transform& cameraPose, AZStd::function<void(const AZ::RPI::AttachmentReadback::ReadbackResult& result)> callback);
|
|
|
|
|
|
+ void RequestMessagePublication(
|
|
|
|
+ std::shared_ptr<rclcpp::Publisher<sensor_msgs::msg::Image>> publisher,
|
|
|
|
+ const AZ::Transform& cameraPose,
|
|
|
|
+ const std_msgs::msg::Header& header);
|
|
|
|
|
|
CameraSensorDescription m_cameraSensorDescription;
|
|
CameraSensorDescription m_cameraSensorDescription;
|
|
AZStd::vector<AZStd::string> m_passHierarchy;
|
|
AZStd::vector<AZStd::string> m_passHierarchy;
|
|
- AZ::RPI::RenderPipelinePtr m_pipeline;
|
|
|
|
AZ::RPI::ViewPtr m_view;
|
|
AZ::RPI::ViewPtr m_view;
|
|
AZ::RPI::Scene* m_scene = nullptr;
|
|
AZ::RPI::Scene* m_scene = nullptr;
|
|
const AZ::Transform AtomToRos{ AZ::Transform::CreateFromQuaternion(
|
|
const AZ::Transform AtomToRos{ AZ::Transform::CreateFromQuaternion(
|
|
@@ -87,6 +90,26 @@ namespace ROS2
|
|
virtual AZStd::string GetPipelineTypeName() const = 0; //! Type of returned data eg Color, Depth, Optical flow
|
|
virtual AZStd::string GetPipelineTypeName() const = 0; //! Type of returned data eg Color, Depth, Optical flow
|
|
|
|
|
|
protected:
|
|
protected:
|
|
|
|
+ AZ::RPI::RenderPipelinePtr m_pipeline;
|
|
|
|
+ AZStd::string m_pipelineName;
|
|
|
|
+
|
|
|
|
+ //! Request a frame from the rendering pipeline
|
|
|
|
+ //! @param cameraPose - current camera pose from which the rendering should take place
|
|
|
|
+ //! @param callback - callback function object that will be called when capture is ready.
|
|
|
|
+ //! It's argument is readback structure containing, among other things, a captured image
|
|
|
|
+ void RequestFrame(
|
|
|
|
+ const AZ::Transform& cameraPose, AZStd::function<void(const AZ::RPI::AttachmentReadback::ReadbackResult& result)> callback);
|
|
|
|
+
|
|
|
|
+ //! Request an additional frame from the rendering pipeline
|
|
|
|
+ //! @param callback - callback function object that will be called when capture is ready.
|
|
|
|
+ //! It's argument is readback structure containing, among other things, a captured image
|
|
|
|
+ //! @param passName - pass name in pipeline, eg `DepthToLinearDepthPass`
|
|
|
|
+ //! @param slotName - slot name in selected pass, eg `Output`
|
|
|
|
+ void RequestAdditionalFrame(
|
|
|
|
+ AZStd::function<void(const AZ::RPI::AttachmentReadback::ReadbackResult& result)> callback,
|
|
|
|
+ const AZStd::string& passName,
|
|
|
|
+ const AZStd::string& slotName);
|
|
|
|
+
|
|
//! Read and setup Atom Passes
|
|
//! Read and setup Atom Passes
|
|
void SetupPasses();
|
|
void SetupPasses();
|
|
};
|
|
};
|
|
@@ -113,4 +136,19 @@ namespace ROS2
|
|
AZStd::string GetPipelineTypeName() const override;
|
|
AZStd::string GetPipelineTypeName() const override;
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+ //! Implementation of camera sensors that runs pipeline which produces color image and readbacks a depth image from pipeline
|
|
|
|
+ class CameraRGBDSensor : public CameraColorSensor
|
|
|
|
+ {
|
|
|
|
+ public:
|
|
|
|
+ CameraRGBDSensor(const CameraSensorDescription& cameraSensorDescription);
|
|
|
|
+
|
|
|
|
+ // CameraSensor overrides
|
|
|
|
+ void RequestMessagePublication(
|
|
|
|
+ AZStd::span<std::shared_ptr<rclcpp::Publisher<sensor_msgs::msg::Image>>> publishers,
|
|
|
|
+ const AZ::Transform& cameraPose,
|
|
|
|
+ const std_msgs::msg::Header& header) override;
|
|
|
|
+
|
|
|
|
+ private:
|
|
|
|
+ void ReadBackDepth(AZStd::function<void(const AZ::RPI::AttachmentReadback::ReadbackResult& result)> callback);
|
|
|
|
+ };
|
|
} // namespace ROS2
|
|
} // namespace ROS2
|