Skip to content

Commit

Permalink
Set rendering sensor pose (#439)
Browse files Browse the repository at this point in the history

---------

Signed-off-by: Ian Chen <[email protected]>
  • Loading branch information
iche033 authored Jun 6, 2024
1 parent 3275bb6 commit 4d2ae18
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/BoundingBoxCameraSensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 1 addition & 3 deletions src/CameraSensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<SensorNoiseType, sdf::Noise> noises = {
Expand Down Expand Up @@ -453,9 +454,6 @@ bool CameraSensor::Update(const std::chrono::steady_clock::duration &_now)

std::lock_guard<std::mutex> 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
Expand Down
2 changes: 1 addition & 1 deletion src/DepthCameraSensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<SensorNoiseType, sdf::Noise> noises = {
Expand Down
4 changes: 1 addition & 3 deletions src/GpuLidarSensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand All @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/RgbdCameraSensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ bool RgbdCameraSensor::CreateCameras()
}

this->dataPtr->depthCamera->SetVisibilityMask(cameraSdf->VisibilityMask());
this->dataPtr->depthCamera->SetLocalPose(this->Pose());

this->AddSensor(this->dataPtr->depthCamera);

Expand Down
1 change: 1 addition & 0 deletions src/SegmentationCameraSensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/ThermalCameraSensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<SensorNoiseType, sdf::Noise> noises = {
Expand Down
4 changes: 1 addition & 3 deletions src/WideAngleCameraSensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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 &&
Expand Down

0 comments on commit 4d2ae18

Please sign in to comment.