Skip to content

Commit

Permalink
Merge from gz-sensors7
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Chen <[email protected]>
  • Loading branch information
iche033 committed Sep 26, 2023
2 parents cf62d0f + ec52913 commit 1caa53b
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 17 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/triage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Add ticket to inbox
uses: technote-space/create-project-card-action@v1
uses: actions/[email protected]
with:
PROJECT: Core development
COLUMN: Inbox
GITHUB_TOKEN: ${{ secrets.TRIAGE_TOKEN }}
CHECK_ORG_PROJECT: true
project-url: https://github.com/orgs/gazebosim/projects/7
github-token: ${{ secrets.TRIAGE_TOKEN }}

32 changes: 32 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,38 @@

## Gazebo Sensors 7

### Gazebo Sensors 7.3.0 (2023-09-26)

1. Infrastructure
* [Pull request #372](https://github.com/gazebosim/gz-sensors/pull/372)
* [Pull request #371](https://github.com/gazebosim/gz-sensors/pull/371)

1. Expose optical frame in CameraSensor so it can be set in DepthCameraSensor
* [Pull request #362](https://github.com/gazebosim/gz-sensors/pull/362)

1. Fix CameraSensor to check if element is null before access
* [Pull request #361](https://github.com/gazebosim/gz-sensors/pull/361)

1. Support protobuf >= 22
* [Pull request #351](https://github.com/gazebosim/gz-sensors/pull/351)

1. Minor cleanup - lint, typos
* [Pull request #352](https://github.com/gazebosim/gz-sensors/pull/352)
* [Pull request #344](https://github.com/gazebosim/gz-sensors/pull/344)

1. Fix frame_id for depth camera point cloud
* [Pull request #350](https://github.com/gazebosim/gz-sensors/pull/350)

1. Add support for bayer images to camera sensor
* [Pull request #336](https://github.com/gazebosim/gz-sensors/pull/336)

1. Fix flaky trigger camera test
* [Pull request #346](https://github.com/gazebosim/gz-sensors/pull/346)

1. Generate default trigger topic name if empty
* [Pull request #343](https://github.com/gazebosim/gz-sensors/pull/343)


### Gazebo Sensors 7.2.0 (2023-04-13)

1. Cleanup resources in CameraSensor destructor
Expand Down
4 changes: 4 additions & 0 deletions include/gz/sensors/CameraSensor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ namespace gz
/// \return True if there are info subscribers, false otherwise
public: virtual bool HasInfoConnections() const;

/// \brief Get the camera optical frame
/// \return The camera optical frame
public: const std::string& OpticalFrameId() const;

/// \brief Advertise camera info topic.
/// \return True if successful.
protected: bool AdvertiseInfo();
Expand Down
9 changes: 8 additions & 1 deletion src/CameraSensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ bool CameraSensor::CreateCamera()
this->dataPtr->camera->SetAspectRatio(static_cast<double>(width)/height);
this->dataPtr->camera->SetHFOV(angle);

if (cameraSdf->Element()->HasElement("distortion")) {
if (cameraSdf->Element() != nullptr &&
cameraSdf->Element()->HasElement("distortion")) {
this->dataPtr->distortion =
ImageDistortionFactory::NewDistortionModel(*cameraSdf, "camera");
this->dataPtr->distortion->Load(*cameraSdf);
Expand Down Expand Up @@ -920,6 +921,12 @@ bool CameraSensor::HasInfoConnections() const
return this->dataPtr->infoPub && this->dataPtr->infoPub.HasConnections();
}

//////////////////////////////////////////////////
const std::string& CameraSensor::OpticalFrameId() const
{
return this->dataPtr->opticalFrameId;
}

//////////////////////////////////////////////////
math::Matrix4d CameraSensorPrivate::BuildProjectionMatrix(
double _imageWidth, double _imageHeight,
Expand Down
26 changes: 15 additions & 11 deletions src/DepthCameraSensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -299,15 +299,6 @@ bool DepthCameraSensor::Load(const sdf::Sensor &_sdf)
gzdbg << "Points for [" << this->Name() << "] advertised on ["
<< this->Topic() << "/points]" << std::endl;

// 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
// by ROS1: https://github.com/ros/common_msgs/pull/77. Ideally, memory
// alignment should be configured.
msgs::InitPointCloudPacked(this->dataPtr->pointMsg, this->FrameId(), true,
{{"xyz", msgs::PointCloudPacked::Field::FLOAT32},
{"rgb", msgs::PointCloudPacked::Field::FLOAT32}});

if (this->Scene())
{
this->CreateCamera();
Expand Down Expand Up @@ -422,6 +413,18 @@ bool DepthCameraSensor::CreateCamera()
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
// by ROS1: https://github.com/ros/common_msgs/pull/77. Ideally, memory
// alignment should be configured.
msgs::InitPointCloudPacked(
this->dataPtr->pointMsg,
this->OpticalFrameId(),
true,
{{"xyz", msgs::PointCloudPacked::Field::FLOAT32},
{"rgb", msgs::PointCloudPacked::Field::FLOAT32}});

// 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 @@ -549,9 +552,10 @@ bool DepthCameraSensor::Update(
rendering::PF_FLOAT32_R));
msg.set_pixel_format_type(msgsFormat);
*msg.mutable_header()->mutable_stamp() = msgs::Convert(_now);
auto frame = msg.mutable_header()->add_data();

auto* frame = msg.mutable_header()->add_data();
frame->set_key("frame_id");
frame->add_value(this->FrameId());
frame->add_value(this->OpticalFrameId());

std::lock_guard<std::mutex> lock(this->dataPtr->mutex);
msg.set_data(this->dataPtr->depthBuffer,
Expand Down

0 comments on commit 1caa53b

Please sign in to comment.