Skip to content

Commit

Permalink
[FIX] frame_id for depth camera point cloud in Fortress
Browse files Browse the repository at this point in the history
Fixes #239 and husarion/rosbot_ros#55 for Gazebo Fortress

## Summary

Using `ignition_frame_id` did not change the frame id in the depth camera point cloud message.

With this fix, the depth camera point cloud message's frame id will be updated according to the set `ignition_frame_id`.

Signed-off-by: Keith Valentin <[email protected]>
  • Loading branch information
MrKeith99 authored Aug 13, 2024
1 parent d9d2fc7 commit f967916
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/DepthCameraSensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,13 @@ bool DepthCameraSensor::Load(const sdf::Sensor &_sdf)
// 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,
msgs::InitPointCloudPacked(
this->dataPtr->pointMsg,
this->OpticalFrameId(),
true,
{{"xyz", msgs::PointCloudPacked::Field::FLOAT32},
{"rgb", msgs::PointCloudPacked::Field::FLOAT32}});

if (this->Scene())
{
this->CreateCamera();
Expand Down Expand Up @@ -554,9 +557,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();
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 f967916

Please sign in to comment.