Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DepthCamera and RGBDCamera - optimize RGB point cloud connection #413

Merged
merged 1 commit into from
Jan 26, 2024
Merged
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
19 changes: 13 additions & 6 deletions src/DepthCameraSensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -407,12 +407,6 @@
std::placeholders::_1, std::placeholders::_2, std::placeholders::_3,
std::placeholders::_4, std::placeholders::_5));

this->dataPtr->pointCloudConnection =
this->dataPtr->depthCamera->ConnectNewRgbPointCloud(
std::bind(&DepthCameraSensor::OnNewRgbPointCloud, this,
std::placeholders::_1, std::placeholders::_2, std::placeholders::_3,
std::placeholders::_4, std::placeholders::_5));

// Initialize the point message.
// \todo(anyone) The true value in the following function call forces
// the xyz and rgb fields to be aligned to memory boundaries. This is need
Expand Down Expand Up @@ -536,6 +530,19 @@
return false;
}

if (this->HasPointConnections() && !this->dataPtr->pointCloudConnection)
{
this->dataPtr->pointCloudConnection =
this->dataPtr->depthCamera->ConnectNewRgbPointCloud(
std::bind(&DepthCameraSensor::OnNewRgbPointCloud, this,
std::placeholders::_1, std::placeholders::_2, std::placeholders::_3,
std::placeholders::_4, std::placeholders::_5));
}
else if (!this->HasPointConnections() && this->dataPtr->pointCloudConnection)
{
this->dataPtr->pointCloudConnection.reset();

Check warning on line 543 in src/DepthCameraSensor.cc

View check run for this annotation

Codecov / codecov/patch

src/DepthCameraSensor.cc#L543

Added line #L543 was not covered by tests
}

// generate sensor data
this->Render();

Expand Down
23 changes: 16 additions & 7 deletions src/RgbdCameraSensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -375,13 +375,6 @@
std::placeholders::_1, std::placeholders::_2, std::placeholders::_3,
std::placeholders::_4, std::placeholders::_5));

this->dataPtr->pointCloudConnection =
this->dataPtr->depthCamera->ConnectNewRgbPointCloud(
std::bind(&RgbdCameraSensorPrivate::OnNewRgbPointCloud,
this->dataPtr.get(),
std::placeholders::_1, std::placeholders::_2, std::placeholders::_3,
std::placeholders::_4, std::placeholders::_5));

// Set the values of the point message based on the camera information.
this->dataPtr->pointMsg.set_width(this->ImageWidth());
this->dataPtr->pointMsg.set_height(this->ImageHeight());
Expand Down Expand Up @@ -472,6 +465,22 @@
return false;
}

if ((this->HasPointConnections() || HasColorConnections()) &&
!this->dataPtr->pointCloudConnection)
{
this->dataPtr->pointCloudConnection =
this->dataPtr->depthCamera->ConnectNewRgbPointCloud(
std::bind(&RgbdCameraSensorPrivate::OnNewRgbPointCloud,

Check warning on line 473 in src/RgbdCameraSensor.cc

View check run for this annotation

Codecov / codecov/patch

src/RgbdCameraSensor.cc#L473

Added line #L473 was not covered by tests
this->dataPtr.get(),
std::placeholders::_1, std::placeholders::_2, std::placeholders::_3,
std::placeholders::_4, std::placeholders::_5));
}
else if (!this->HasPointConnections() && !this->HasColorConnections() &&
this->dataPtr->pointCloudConnection)

Check warning on line 479 in src/RgbdCameraSensor.cc

View check run for this annotation

Codecov / codecov/patch

src/RgbdCameraSensor.cc#L479

Added line #L479 was not covered by tests
{
this->dataPtr->pointCloudConnection.reset();

Check warning on line 481 in src/RgbdCameraSensor.cc

View check run for this annotation

Codecov / codecov/patch

src/RgbdCameraSensor.cc#L481

Added line #L481 was not covered by tests
}

unsigned int width = this->dataPtr->depthCamera->ImageWidth();
unsigned int height = this->dataPtr->depthCamera->ImageHeight();
unsigned int depthSamples = height * width;
Expand Down