From 4d2ae188117486fbdc4b3a3df3fe25d539a8800d Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Thu, 6 Jun 2024 15:17:22 +0800 Subject: [PATCH] Set rendering sensor pose (#439) --------- Signed-off-by: Ian Chen --- src/BoundingBoxCameraSensor.cc | 1 + src/CameraSensor.cc | 4 +--- src/DepthCameraSensor.cc | 2 +- src/GpuLidarSensor.cc | 4 +--- src/RgbdCameraSensor.cc | 1 + src/SegmentationCameraSensor.cc | 1 + src/ThermalCameraSensor.cc | 2 +- src/WideAngleCameraSensor.cc | 4 +--- 8 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/BoundingBoxCameraSensor.cc b/src/BoundingBoxCameraSensor.cc index cc2444f9..ced59079 100644 --- a/src/BoundingBoxCameraSensor.cc +++ b/src/BoundingBoxCameraSensor.cc @@ -321,6 +321,7 @@ bool BoundingBoxCameraSensor::CreateCamera() this->dataPtr->boundingboxCamera->SetVisibilityMask( sdfCamera->VisibilityMask()); this->dataPtr->boundingboxCamera->SetBoundingBoxType(this->dataPtr->type); + this->dataPtr->boundingboxCamera->SetLocalPose(this->Pose()); // Add the camera to the scene this->Scene()->RootVisual()->AddChild(this->dataPtr->rgbCamera); diff --git a/src/CameraSensor.cc b/src/CameraSensor.cc index c9d821bc..b0f558a7 100644 --- a/src/CameraSensor.cc +++ b/src/CameraSensor.cc @@ -212,6 +212,7 @@ bool CameraSensor::CreateCamera() this->dataPtr->camera->SetNearClipPlane(cameraSdf->NearClip()); this->dataPtr->camera->SetFarClipPlane(cameraSdf->FarClip()); this->dataPtr->camera->SetVisibilityMask(cameraSdf->VisibilityMask()); + this->dataPtr->camera->SetLocalPose(this->Pose()); this->AddSensor(this->dataPtr->camera); const std::map noises = { @@ -453,9 +454,6 @@ bool CameraSensor::Update(const std::chrono::steady_clock::duration &_now) std::lock_guard lock(this->dataPtr->mutex); - // move the camera to the current pose - this->dataPtr->camera->SetLocalPose(this->Pose()); - if (this->HasInfoConnections()) { // publish the camera info message diff --git a/src/DepthCameraSensor.cc b/src/DepthCameraSensor.cc index 31b9b028..52f88d8c 100644 --- a/src/DepthCameraSensor.cc +++ b/src/DepthCameraSensor.cc @@ -350,7 +350,7 @@ bool DepthCameraSensor::CreateCamera() this->dataPtr->depthCamera->SetFarClipPlane(far); this->dataPtr->depthCamera->SetVisibilityMask( cameraSdf->VisibilityMask()); - + this->dataPtr->depthCamera->SetLocalPose(this->Pose()); this->AddSensor(this->dataPtr->depthCamera); const std::map noises = { diff --git a/src/GpuLidarSensor.cc b/src/GpuLidarSensor.cc index ff3e9aa1..0e98cddc 100644 --- a/src/GpuLidarSensor.cc +++ b/src/GpuLidarSensor.cc @@ -194,9 +194,6 @@ bool GpuLidarSensor::CreateLidar() return false; } - this->dataPtr->gpuRays->SetWorldPosition(this->Pose().Pos()); - this->dataPtr->gpuRays->SetWorldRotation(this->Pose().Rot()); - this->dataPtr->gpuRays->SetNearClipPlane(this->RangeMin()); this->dataPtr->gpuRays->SetFarClipPlane(this->RangeMax()); @@ -214,6 +211,7 @@ bool GpuLidarSensor::CreateLidar() this->dataPtr->gpuRays->SetRayCount(this->RayCount()); this->dataPtr->gpuRays->SetVerticalRayCount( this->VerticalRayCount()); + this->dataPtr->gpuRays->SetLocalPose(this->Pose()); this->Scene()->RootVisual()->AddChild( this->dataPtr->gpuRays); diff --git a/src/RgbdCameraSensor.cc b/src/RgbdCameraSensor.cc index e0d742e4..7f3fd69b 100644 --- a/src/RgbdCameraSensor.cc +++ b/src/RgbdCameraSensor.cc @@ -326,6 +326,7 @@ bool RgbdCameraSensor::CreateCameras() } this->dataPtr->depthCamera->SetVisibilityMask(cameraSdf->VisibilityMask()); + this->dataPtr->depthCamera->SetLocalPose(this->Pose()); this->AddSensor(this->dataPtr->depthCamera); diff --git a/src/SegmentationCameraSensor.cc b/src/SegmentationCameraSensor.cc index 6ebadb6b..92b5a983 100644 --- a/src/SegmentationCameraSensor.cc +++ b/src/SegmentationCameraSensor.cc @@ -369,6 +369,7 @@ bool SegmentationCameraSensor::CreateCamera() this->dataPtr->camera->SetFarClipPlane(sdfCamera->FarClip()); this->dataPtr->camera->SetAspectRatio(aspectRatio); this->dataPtr->camera->SetHFOV(angle); + this->dataPtr->camera->SetLocalPose(this->Pose()); // Add the camera to the scene this->Scene()->RootVisual()->AddChild(this->dataPtr->camera); diff --git a/src/ThermalCameraSensor.cc b/src/ThermalCameraSensor.cc index 717caf6b..d0aec077 100644 --- a/src/ThermalCameraSensor.cc +++ b/src/ThermalCameraSensor.cc @@ -300,7 +300,7 @@ bool ThermalCameraSensor::CreateCamera() this->dataPtr->thermalCamera->SetMinTemperature(this->dataPtr->minTemp); this->dataPtr->thermalCamera->SetMaxTemperature(this->dataPtr->maxTemp); this->dataPtr->thermalCamera->SetLinearResolution(this->dataPtr->resolution); - + this->dataPtr->thermalCamera->SetLocalPose(this->Pose()); this->AddSensor(this->dataPtr->thermalCamera); const std::map noises = { diff --git a/src/WideAngleCameraSensor.cc b/src/WideAngleCameraSensor.cc index ab879200..94b935d6 100644 --- a/src/WideAngleCameraSensor.cc +++ b/src/WideAngleCameraSensor.cc @@ -240,6 +240,7 @@ bool WideAngleCameraSensor::CreateCamera() this->dataPtr->camera->SetNearClipPlane(cameraSdf->NearClip()); this->dataPtr->camera->SetFarClipPlane(cameraSdf->FarClip()); this->dataPtr->camera->SetVisibilityMask(cameraSdf->VisibilityMask()); + this->dataPtr->camera->SetLocalPose(this->Pose()); rendering::CameraLens lens; std::string lensType = cameraSdf->LensType(); @@ -413,9 +414,6 @@ bool WideAngleCameraSensor::Update( return false; } - // move the camera to the current pose - this->dataPtr->camera->SetLocalPose(this->Pose()); - // render only if necessary if (!this->dataPtr->pub.HasConnections() && this->dataPtr->imageEvent.ConnectionCount() <= 0 &&