From ad260f0e18ac46d4069092fa643ef8c2d13329f7 Mon Sep 17 00:00:00 2001 From: Guillaume Doisy Date: Sun, 17 Apr 2022 15:12:22 +0200 Subject: [PATCH 1/3] Fix https://github.com/ignitionrobotics/ign-sensors/issues/217 Signed-off-by: Guillaume Doisy --- src/GpuLidarSensor.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/GpuLidarSensor.cc b/src/GpuLidarSensor.cc index fcff8834..0272cfa7 100644 --- a/src/GpuLidarSensor.cc +++ b/src/GpuLidarSensor.cc @@ -256,6 +256,14 @@ bool GpuLidarSensor::Update(const std::chrono::steady_clock::duration &_now) // Set the time stamp *this->dataPtr->pointMsg.mutable_header()->mutable_stamp() = msgs::Convert(_now); + // Set frame_id + for (auto i = 0; i < this->dataPtr->pointMsg.mutable_header()->data_size(); ++i) { + if (this->dataPtr->pointMsg.mutable_header()->data(i).key() == "frame_id" + && this->dataPtr->pointMsg.mutable_header()->data(i).value_size() > 0) + { + this->dataPtr->pointMsg.mutable_header()->mutable_data(i)->set_value(0, this->FrameId()); + } + } this->dataPtr->FillPointCloudMsg(this->laserBuffer); From 469f1476566615e56228fc480fa3596db9c87e26 Mon Sep 17 00:00:00 2001 From: Guillaume Doisy Date: Sun, 17 Apr 2022 15:13:04 +0200 Subject: [PATCH 2/3] Apply frame_id to all sensors Signed-off-by: Guillaume Doisy --- src/ForceTorqueSensor.cc | 2 +- src/SegmentationCameraSensor.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ForceTorqueSensor.cc b/src/ForceTorqueSensor.cc index 8cb4d636..20590031 100644 --- a/src/ForceTorqueSensor.cc +++ b/src/ForceTorqueSensor.cc @@ -250,7 +250,7 @@ bool ForceTorqueSensor::Update(const std::chrono::steady_clock::duration &_now) *msg.mutable_header()->mutable_stamp() = msgs::Convert(_now); auto frame = msg.mutable_header()->add_data(); frame->set_key("frame_id"); - frame->add_value(this->Name()); + frame->add_value(this->FrameId()); msgs::Set(msg.mutable_force(), measuredForce); msgs::Set(msg.mutable_torque(), measuredTorque); diff --git a/src/SegmentationCameraSensor.cc b/src/SegmentationCameraSensor.cc index 2af0aee0..4bbcd49a 100644 --- a/src/SegmentationCameraSensor.cc +++ b/src/SegmentationCameraSensor.cc @@ -487,7 +487,7 @@ bool SegmentationCameraSensor::Update( *stamp = msgs::Convert(_now); auto frame = this->dataPtr->coloredMapMsg.mutable_header()->add_data(); frame->set_key("frame_id"); - frame->add_value(this->Name()); + frame->add_value(this->FrameId()); this->dataPtr->labelsMapMsg.CopyFrom(this->dataPtr->coloredMapMsg); From ad8c09dc94ebfa8a0a39a9bd7d9f3243fa98295b Mon Sep 17 00:00:00 2001 From: Guillaume Doisy Date: Mon, 18 Apr 2022 18:59:10 +0200 Subject: [PATCH 3/3] lint Signed-off-by: Guillaume Doisy --- src/GpuLidarSensor.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/GpuLidarSensor.cc b/src/GpuLidarSensor.cc index 0272cfa7..ba3f66c1 100644 --- a/src/GpuLidarSensor.cc +++ b/src/GpuLidarSensor.cc @@ -257,11 +257,16 @@ bool GpuLidarSensor::Update(const std::chrono::steady_clock::duration &_now) *this->dataPtr->pointMsg.mutable_header()->mutable_stamp() = msgs::Convert(_now); // Set frame_id - for (auto i = 0; i < this->dataPtr->pointMsg.mutable_header()->data_size(); ++i) { + for (auto i = 0; + i < this->dataPtr->pointMsg.mutable_header()->data_size(); + ++i) + { if (this->dataPtr->pointMsg.mutable_header()->data(i).key() == "frame_id" && this->dataPtr->pointMsg.mutable_header()->data(i).value_size() > 0) { - this->dataPtr->pointMsg.mutable_header()->mutable_data(i)->set_value(0, this->FrameId()); + this->dataPtr->pointMsg.mutable_header()->mutable_data(i)->set_value( + 0, + this->FrameId()); } }