31 #include <ros/publisher.h> 39 #include <sensor_msgs/PointCloud2.h> 40 #include <sensor_msgs/Image.h> 42 #include <sensor_msgs/CameraInfo.h> 46 #include <pcl/point_cloud.h> 47 #include <pcl/point_types.h> 95 pnh.
param(
"queue_size", queueSize, queueSize);
102 pnh.
param(
"approx", approx, approx);
106 ROS_FATAL(
"fixed_frame_id should be set when using approximate " 107 "time synchronization (approx=true)! If the robot " 108 "is moving, it could be \"odom\". If not moving, it " 109 "could be \"base_link\".");
113 ROS_INFO(
" approx=%s", approx?
"true":
"false");
114 ROS_INFO(
" queue_size=%d", queueSize);
117 ROS_INFO(
" fill_holes_size=%d pixels (0=disabled)",
fillHolesSize_);
144 const sensor_msgs::PointCloud2ConstPtr & pointCloud2Msg,
145 const sensor_msgs::CameraInfoConstPtr & cameraInfoMsg)
149 double cloudStamp = pointCloud2Msg->header.stamp.toSec();
150 double infoStamp = cameraInfoMsg->header.stamp.toSec();
157 pointCloud2Msg->header.frame_id,
159 cameraInfoMsg->header.stamp,
160 pointCloud2Msg->header.stamp,
165 if(cloudDisplacement.
isNull())
171 pointCloud2Msg->header.frame_id,
172 cameraInfoMsg->header.frame_id,
173 cameraInfoMsg->header.stamp,
177 if(cloudToCamera.
isNull())
194 ROS_ERROR(
"decimation (%d) not valid for image size %dx%d",
201 pcl::PCLPointCloud2::Ptr cloud(
new pcl::PCLPointCloud2);
206 if(cloud->data.empty())
225 sensor_msgs::PointCloud2 pointCloud2Out;
227 pointCloud2Out.header = cameraInfoMsg->header;
232 depthImage.
header = cameraInfoMsg->header;
247 if( cloudStamp != pointCloud2Msg->header.stamp.toSec() ||
248 infoStamp != cameraInfoMsg->header.stamp.toSec())
250 NODELET_ERROR(
"Input stamps changed between the beginning and the end of the callback! Make " 251 "sure the node publishing the topics doesn't override the same data after publishing them. A " 252 "solution is to use this node within another nodelet manager. Stamps: " 253 "cloud=%f->%f info=%f->%f",
254 cloudStamp, pointCloud2Msg->header.stamp.toSec(),
255 infoStamp, cameraInfoMsg->header.stamp.toSec());
void callback(const sensor_msgs::PointCloud2ConstPtr &pointCloud2Msg, const sensor_msgs::CameraInfoConstPtr &cameraInfoMsg)
std::string getTopic() const
#define NODELET_ERROR(...)
const cv::Size & imageSize() const
void publish(const boost::shared_ptr< M > &message) const
image_transport::Publisher depthImage32Pub_
std::string resolveName(const std::string &name, bool remap=true) const
Publisher advertise(const std::string &base_topic, uint32_t queue_size, bool latch=false)
ros::Publisher pointCloudTransformedPub_
message_filters::Synchronizer< MyApproxSyncPolicy > * approxSync_
message_filters::Subscriber< sensor_msgs::PointCloud2 > pointCloudSub_
rtabmap::Transform getTransform(const std::string &fromFrameId, const std::string &toFrameId, const ros::Time &stamp, tf::TransformListener &listener, double waitForTransform)
uint32_t getNumSubscribers() const
ros::NodeHandle & getPrivateNodeHandle() const
void publish(const sensor_msgs::Image &message) const
image_transport::Publisher depthImage16Pub_
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
tf::TransformListener * listener_
const std::string TYPE_32FC1
rtabmap::CameraModel cameraModelFromROS(const sensor_msgs::CameraInfo &camInfo, const rtabmap::Transform &localTransform=rtabmap::Transform::getIdentity())
const std::string TYPE_16UC1
message_filters::Subscriber< sensor_msgs::CameraInfo > cameraInfoSub_
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
ros::NodeHandle & getNodeHandle() const
uint32_t getNumSubscribers() const
void subscribe(ros::NodeHandle &nh, const std::string &topic, uint32_t queue_size, const ros::TransportHints &transport_hints=ros::TransportHints(), ros::CallbackQueueInterface *callback_queue=0)
void transformPointCloud(const pcl::PointCloud< PointT > &cloud_in, pcl::PointCloud< PointT > &cloud_out, const tf::Transform &transform)
message_filters::sync_policies::ExactTime< sensor_msgs::PointCloud2, sensor_msgs::CameraInfo > MyExactSyncPolicy
cv::Mat RTABMAP_EXP fillDepthHoles(const cv::Mat &depth, int maximumHoleSize=1, float errorRatio=0.02f)
message_filters::Synchronizer< MyExactSyncPolicy > * exactSync_
cv::Mat RTABMAP_EXP projectCloudToCamera(const cv::Size &imageSize, const cv::Mat &cameraMatrixK, const cv::Mat &laserScan, const rtabmap::Transform &cameraTransform)
PLUGINLIB_EXPORT_CLASS(rtabmap_ros::CoreWrapper, nodelet::Nodelet)
cv::Mat RTABMAP_EXP cvtDepthFromFloat(const cv::Mat &depth32F)
virtual ~PointCloudToDepthImage()
sensor_msgs::ImagePtr toImageMsg() const
CameraModel scaled(double scale) const
void toPCL(const ros::Time &stamp, pcl::uint64_t &pcl_stamp)
message_filters::sync_policies::ApproximateTime< sensor_msgs::PointCloud2, sensor_msgs::CameraInfo > MyApproxSyncPolicy
const Transform & localTransform() const
std::string fixedFrameId_