|
@@ -23,6 +23,7 @@ namespace ROS2
|
|
|
{
|
|
|
CameraSensorDescription::CameraSensorDescription(const AZStd::string& cameraName, float verticalFov, int width, int height)
|
|
|
: m_verticalFieldOfViewDeg(verticalFov)
|
|
|
+ , m_verticalFieldOfViewRad(AZ::DegToRad(m_verticalFieldOfViewDeg))
|
|
|
, m_width(width)
|
|
|
, m_height(height)
|
|
|
, m_cameraName(cameraName)
|
|
@@ -63,9 +64,9 @@ namespace ROS2
|
|
|
// (cx, cy).
|
|
|
const auto w = static_cast<double>(m_width);
|
|
|
const auto h = static_cast<double>(m_height);
|
|
|
- const double horizontalFoV = 2.0 * AZStd::atan(AZStd::tan(m_verticalFieldOfViewDeg / 2.0) / m_aspectRatio);
|
|
|
+ const double horizontalFoV = 2.0 * AZStd::atan(AZStd::tan(m_verticalFieldOfViewRad / 2.0) * m_aspectRatio);
|
|
|
const double focalLengthX = w / (2.0 * AZStd::tan(horizontalFoV / 2.0));
|
|
|
- const double focalLengthY = h / (2.0 * AZStd::tan(m_verticalFieldOfViewDeg / 2.0));
|
|
|
+ const double focalLengthY = h / (2.0 * AZStd::tan(m_verticalFieldOfViewRad / 2.0));
|
|
|
return { focalLengthX, 0.0, w / 2.0, 0.0, focalLengthY, h / 2.0, 0.0, 0.0, 1.0 };
|
|
|
}
|
|
|
|
|
@@ -127,7 +128,7 @@ namespace ROS2
|
|
|
void CameraSensor::RequestFrame(
|
|
|
const AZ::Transform& cameraPose, std::function<void(const AZ::RPI::AttachmentReadback::ReadbackResult& result)> callback)
|
|
|
{
|
|
|
- AZ::Transform inverse = cameraPose.GetInverse();
|
|
|
+ AZ::Transform inverse = (cameraPose * kAtomToRos).GetInverse();
|
|
|
m_view->SetWorldToViewMatrix(AZ::Matrix4x4::CreateFromQuaternionAndTranslation(inverse.GetRotation(), inverse.GetTranslation()));
|
|
|
|
|
|
AZ::Render::FrameCaptureId captureId = AZ::Render::InvalidFrameCaptureId;
|