Skip to content

Commit

Permalink
Added frame_id parameter to lidar sensor
Browse files Browse the repository at this point in the history
Signed-off-by: ahcorde <ahcorde@gmail.com>
  • Loading branch information
ahcorde committed Feb 18, 2022
1 parent 5d24d67 commit 858c394
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/Lidar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ class ignition::sensors::LidarPrivate

/// \brief Sdf sensor.
public: sdf::Lidar sdfLidar;

/// \brief frame id
public: std::string frame_id;
};

//////////////////////////////////////////////////
Expand Down Expand Up @@ -166,6 +169,17 @@ bool Lidar::Load(const sdf::Sensor &_sdf)
}
}

sdf::ElementPtr element = _sdf.Element();
// Get the background color, if specified.
if (element->HasElement("frame_id"))
{
this->dataPtr->frame_id = element->Get<std::string>("frame_id");
}
else
{
this->dataPtr->frame_id = this->Name();
}

this->initialized = true;
return true;
}
Expand Down Expand Up @@ -232,7 +246,7 @@ bool Lidar::PublishLidarScan(const ignition::common::Time &_now)
auto frame = this->dataPtr->laserMsg.mutable_header()->add_data();
frame->set_key("frame_id");
frame->add_value(this->Name());
this->dataPtr->laserMsg.set_frame(this->Name());
this->dataPtr->laserMsg.set_frame(this->dataPtr->frame_id);

// Store the latest laser scans into laserMsg
msgs::Set(this->dataPtr->laserMsg.mutable_world_pose(),
Expand Down

0 comments on commit 858c394

Please sign in to comment.