@@ -39,7 +39,8 @@ using namespace ignition::sensors;
3939class ignition ::sensors::GpuLidarSensorPrivate
4040{
4141 // / \brief Fill the point cloud packed message
42- public: void FillPointCloudMsg ();
42+ // / \param[in] _laserBuffer Lidar data buffer.
43+ public: void FillPointCloudMsg (const float *_laserBuffer);
4344
4445 // / \brief Rendering camera
4546 public: ignition::rendering::GpuRaysPtr gpuRays;
@@ -248,6 +249,9 @@ bool GpuLidarSensor::Update(const std::chrono::steady_clock::duration &_now)
248249 // / \todo(anyone) It would be nice to remove this copy.
249250 this ->dataPtr ->gpuRays ->Copy (this ->laserBuffer );
250251
252+ // Apply noise before publishing the data.
253+ this ->ApplyNoise ();
254+
251255 this ->PublishLidarScan (_now);
252256
253257 if (this ->dataPtr ->pointPub .HasConnections ())
@@ -257,7 +261,7 @@ bool GpuLidarSensor::Update(const std::chrono::steady_clock::duration &_now)
257261 msgs::Convert (_now);
258262 this ->dataPtr ->pointMsg .set_is_dense (true );
259263
260- this ->dataPtr ->FillPointCloudMsg ();
264+ this ->dataPtr ->FillPointCloudMsg (this -> laserBuffer );
261265
262266 {
263267 this ->AddSequence (this ->dataPtr ->pointMsg .mutable_header ());
@@ -302,7 +306,7 @@ ignition::math::Angle GpuLidarSensor::VFOV() const
302306}
303307
304308// ////////////////////////////////////////////////
305- void GpuLidarSensorPrivate::FillPointCloudMsg ()
309+ void GpuLidarSensorPrivate::FillPointCloudMsg (const float *_laserBuffer )
306310{
307311 IGN_PROFILE (" GpuLidarSensorPrivate::FillPointCloudMsg" );
308312 uint32_t width = this ->pointMsg .width ();
@@ -335,8 +339,8 @@ void GpuLidarSensorPrivate::FillPointCloudMsg()
335339 {
336340 // Index of current point, and the depth value at that point
337341 auto index = j * width * channels + i * channels;
338- float depth = this -> gpuRays -> Data () [index];
339- float intensity = this -> gpuRays -> Data () [index + 1 ];
342+ float depth = _laserBuffer [index];
343+ float intensity = _laserBuffer [index + 1 ];
340344 uint16_t ring = j;
341345
342346 int fieldIndex = 0 ;
0 commit comments