@@ -251,15 +251,6 @@ bool RgbdCameraSensor::Load(const sdf::Sensor &_sdf)
251251 if (!this ->AdvertiseInfo (this ->Topic () + " /camera_info" ))
252252 return false ;
253253
254- // Initialize the point message.
255- // \todo(anyone) The true value in the following function call forces
256- // the xyz and rgb fields to be aligned to memory boundaries. This is need
257- // by ROS1: https://github.com/ros/common_msgs/pull/77. Ideally, memory
258- // alignment should be configured.
259- msgs::InitPointCloudPacked (this ->dataPtr ->pointMsg , this ->FrameId (), true ,
260- {{" xyz" , msgs::PointCloudPacked::Field::FLOAT32},
261- {" rgb" , msgs::PointCloudPacked::Field::FLOAT32}});
262-
263254 if (this ->Scene ())
264255 {
265256 this ->CreateCameras ();
@@ -390,6 +381,16 @@ bool RgbdCameraSensor::CreateCameras()
390381 std::placeholders::_1, std::placeholders::_2, std::placeholders::_3,
391382 std::placeholders::_4, std::placeholders::_5));
392383
384+ // Initialize the point message.
385+ // \todo(anyone) The true value in the following function call forces
386+ // the xyz and rgb fields to be aligned to memory boundaries. This is need
387+ // by ROS1: https://github.com/ros/common_msgs/pull/77. Ideally, memory
388+ // alignment should be configured.
389+ msgs::InitPointCloudPacked (this ->dataPtr ->pointMsg , this ->OpticalFrameId (),
390+ true ,
391+ {{" xyz" , msgs::PointCloudPacked::Field::FLOAT32},
392+ {" rgb" , msgs::PointCloudPacked::Field::FLOAT32}});
393+
393394 // Set the values of the point message based on the camera information.
394395 this ->dataPtr ->pointMsg .set_width (this ->ImageWidth ());
395396 this ->dataPtr ->pointMsg .set_height (this ->ImageHeight ());
0 commit comments