kinfu.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2017, Kentaro Wada and JSK Lab
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of Kentaro Wada and JSK Lab nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
35 #ifndef JSK_PCL_ROS_KINFU_H_
36 #define JSK_PCL_ROS_KINFU_H_
37 
38 #include <pcl/console/parse.h>
39 #include <pcl/gpu/kinfu_large_scale/kinfu.h>
40 #include <pcl/gpu/kinfu_large_scale/marching_cubes.h>
41 #include <pcl/gpu/kinfu_large_scale/raycaster.h>
42 #include <pcl/gpu/containers/initialization.h>
43 #include <pcl/surface/texture_mapping.h>
44 #include <pcl/point_cloud.h>
45 #include <pcl/point_types.h>
46 #include <pcl/common/angles.h>
47 
48 #include <dynamic_reconfigure/server.h>
52 #include <jsk_topic_tools/connection_based_nodelet.h>
55 #include <std_srvs/Empty.h>
56 #include <sensor_msgs/Image.h>
57 #include <sensor_msgs/PointCloud2.h>
58 #include <jsk_rviz_plugins/OverlayText.h>
61 
62 #include "jsk_pcl_ros/KinfuConfig.h"
63 
64 // defined in pcl/gpu/kinfu_large_scale/src/kinfu.cpp
65 namespace pcl
66 {
67  namespace gpu
68  {
69  namespace kinfuLS
70  {
71  void paint3DView (const KinfuTracker::View& rgb24, KinfuTracker::View& view, float colors_weight = 0.5f);
72  }
73  }
74 }
75 
76 namespace jsk_pcl_ros
77 {
78  class Kinfu: public jsk_topic_tools::ConnectionBasedNodelet
79  {
80  public:
82  sensor_msgs::CameraInfo, sensor_msgs::Image> SyncPolicy;
84  sensor_msgs::CameraInfo, sensor_msgs::Image, sensor_msgs::Image> SyncPolicyWithColor;
85  typedef jsk_pcl_ros::KinfuConfig Config;
86 
87  Kinfu(): ConnectionBasedNodelet(), frame_idx_(0) {}
88  virtual ~Kinfu();
89  protected:
90  virtual void onInit();
91  virtual void subscribe();
92  virtual void unsubscribe();
93 
94  void initKinfu(const sensor_msgs::CameraInfo::ConstPtr& caminfo_msg);
95  void update(const sensor_msgs::CameraInfo::ConstPtr& caminfo_msg,
96  const sensor_msgs::Image::ConstPtr& depth_msg);
97  void update(const sensor_msgs::CameraInfo::ConstPtr& caminfo_msg,
98  const sensor_msgs::Image::ConstPtr& depth_msg,
99  const sensor_msgs::Image::ConstPtr& rgb_msg);
100  bool resetCallback(std_srvs::Empty::Request& req, std_srvs::Empty::Response& res);
101 
103  virtual void configCallback(Config &config, uint32_t level);
104 
105  pcl::PolygonMesh createPolygonMesh();
106  pcl::PolygonMesh createPolygonMesh(const jsk_recognition_msgs::BoundingBox& box_msg,
107  const std::string& ground_frame_id);
108  pcl::TextureMesh convertToTextureMesh(const pcl::PolygonMesh& triangles,
109  const std::vector<cv::Mat> textures,
110  pcl::texture_mapping::CameraVector cameras);
111  bool saveMeshCallback(std_srvs::Empty::Request& req, std_srvs::Empty::Response& res);
113  jsk_recognition_msgs::SaveMesh::Request& req, jsk_recognition_msgs::SaveMesh::Response& res);
114 
116  pcl::gpu::kinfuLS::MarchingCubes::Ptr marching_cubes_;
117  pcl::gpu::kinfuLS::KinfuTracker::View colors_device_;
118  pcl::gpu::kinfuLS::RayCaster::Ptr raycaster_;
119  std::vector<cv::Mat> textures_;
120  pcl::texture_mapping::CameraVector cameras_;
121 
122  int device_;
125  bool slam_;
126  std::string fixed_frame_id_;
129 
131  std::string save_dir_;
132 
134 
136  Eigen::Affine3f odom_init_to_kinfu_origin_;
137 
143 
149 
151 
155 
156  private:
157  };
158 
159 } // namespace jsk_pcl_ros
160 
161 #endif // JSK_PCL_ROS_KINFU_H_
jsk_pcl_ros::Kinfu::onInit
virtual void onInit()
Definition: kinfu_nodelet.cpp:83
jsk_pcl_ros::Kinfu::marching_cubes_
pcl::gpu::kinfuLS::MarchingCubes::Ptr marching_cubes_
Definition: kinfu.h:116
pcl
jsk_pcl_ros::Kinfu::kinfu_
boost::shared_ptr< pcl::gpu::kinfuLS::KinfuTracker > kinfu_
Definition: kinfu.h:115
jsk_pcl_ros::Kinfu::configCallback
virtual void configCallback(Config &config, uint32_t level)
Definition: kinfu_nodelet.cpp:129
jsk_pcl_ros::Kinfu::convertToTextureMesh
pcl::TextureMesh convertToTextureMesh(const pcl::PolygonMesh &triangles, const std::vector< cv::Mat > textures, pcl::texture_mapping::CameraVector cameras)
Definition: kinfu_nodelet.cpp:549
ros::Publisher
jsk_pcl_ros::Kinfu::cameras_
pcl::texture_mapping::CameraVector cameras_
Definition: kinfu.h:120
jsk_pcl_ros::Kinfu::integrate_color_
bool integrate_color_
Definition: kinfu.h:124
jsk_pcl_ros::Kinfu::auto_reset_
bool auto_reset_
Definition: kinfu.h:123
boost::shared_ptr
jsk_pcl_ros::Kinfu::n_textures_
int n_textures_
Definition: kinfu.h:127
jsk_pcl_ros::Kinfu::tf_listener_
boost::shared_ptr< tf::TransformListener > tf_listener_
Definition: kinfu.h:135
jsk_pcl_ros::Kinfu::SyncPolicy
message_filters::sync_policies::ExactTime< sensor_msgs::CameraInfo, sensor_msgs::Image > SyncPolicy
Definition: kinfu.h:82
jsk_pcl_ros::Kinfu::pub_rendered_image_
ros::Publisher pub_rendered_image_
Definition: kinfu.h:147
jsk_pcl_ros::Kinfu::initKinfu
void initKinfu(const sensor_msgs::CameraInfo::ConstPtr &caminfo_msg)
Definition: kinfu_nodelet.cpp:136
jsk_pcl_ros::Kinfu::colors_device_
pcl::gpu::kinfuLS::KinfuTracker::View colors_device_
Definition: kinfu.h:117
jsk_pcl_ros::Kinfu::textures_
std::vector< cv::Mat > textures_
Definition: kinfu.h:119
jsk_pcl_ros::Kinfu::pub_depth_
ros::Publisher pub_depth_
Definition: kinfu.h:146
jsk_pcl_ros::Kinfu::sub_depth_
message_filters::Subscriber< sensor_msgs::Image > sub_depth_
Definition: kinfu.h:139
jsk_pcl_ros::Kinfu::save_dir_
std::string save_dir_
Definition: kinfu.h:131
jsk_pcl_ros::Kinfu::raycaster_
pcl::gpu::kinfuLS::RayCaster::Ptr raycaster_
Definition: kinfu.h:118
tf_listener_singleton.h
jsk_pcl_ros::Kinfu::device_
int device_
Definition: kinfu.h:122
jsk_pcl_ros::Kinfu
Definition: kinfu.h:78
jsk_pcl_ros::Kinfu::saveMeshCallback
bool saveMeshCallback(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res)
Definition: kinfu_nodelet.cpp:514
transform_broadcaster.h
message_filters::Subscriber< sensor_msgs::CameraInfo >
ros::ServiceServer
jsk_pcl_ros::Kinfu::~Kinfu
virtual ~Kinfu()
Definition: kinfu_nodelet.cpp:116
jsk_pcl_ros::Kinfu::saveMeshWithContextCallback
bool saveMeshWithContextCallback(jsk_recognition_msgs::SaveMesh::Request &req, jsk_recognition_msgs::SaveMesh::Response &res)
Definition: kinfu_nodelet.cpp:478
jsk_pcl_ros::Kinfu::pub_cloud_
ros::Publisher pub_cloud_
Definition: kinfu.h:145
message_filters::sync_policies::ApproximateTime
jsk_pcl_ros
Definition: add_color_from_image.h:51
jsk_pcl_ros::Kinfu::fixed_frame_id_
std::string fixed_frame_id_
Definition: kinfu.h:126
tf::TransformBroadcaster
pcl::gpu::kinfuLS::paint3DView
void paint3DView(const KinfuTracker::View &rgb24, KinfuTracker::View &view, float colors_weight=0.5f)
subscriber.h
jsk_pcl_ros::Kinfu::srv_save_mesh_
ros::ServiceServer srv_save_mesh_
Definition: kinfu.h:153
jsk_pcl_ros::Kinfu::volume_size_
float volume_size_
Definition: kinfu.h:128
jsk_pcl_ros::Kinfu::sync_
boost::shared_ptr< message_filters::Synchronizer< SyncPolicy > > sync_
Definition: kinfu.h:141
jsk_pcl_ros::Kinfu::mutex_
boost::mutex mutex_
Definition: kinfu.h:133
pcl_conversion_util.h
exact_time.h
jsk_pcl_ros::Kinfu::resetCallback
bool resetCallback(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res)
Definition: kinfu_nodelet.cpp:467
jsk_pcl_ros::Kinfu::createPolygonMesh
pcl::PolygonMesh createPolygonMesh()
Definition: kinfu_nodelet.cpp:637
jsk_pcl_ros::Kinfu::subscribe
virtual void subscribe()
Definition: kinfu_nodelet.cpp:173
jsk_pcl_ros::Kinfu::pub_status_
ros::Publisher pub_status_
Definition: kinfu.h:148
jsk_pcl_ros::Kinfu::tf_broadcaster_
tf::TransformBroadcaster tf_broadcaster_
Definition: kinfu.h:150
jsk_pcl_ros::Kinfu::update
void update(const sensor_msgs::CameraInfo::ConstPtr &caminfo_msg, const sensor_msgs::Image::ConstPtr &depth_msg)
Definition: kinfu_nodelet.cpp:201
dump_depth_error.f
f
Definition: dump_depth_error.py:39
jsk_pcl_ros::Kinfu::Config
jsk_pcl_ros::KinfuConfig Config
Definition: kinfu.h:85
jsk_pcl_ros::Kinfu::Kinfu
Kinfu()
Definition: kinfu.h:87
jsk_pcl_ros::Kinfu::srv_save_mesh_with_context_
ros::ServiceServer srv_save_mesh_with_context_
Definition: kinfu.h:154
approximate_time.h
mutex
boost::mutex mutex
global mutex.
Definition: depth_camera_error_visualization.cpp:86
jsk_pcl_ros::Kinfu::slam_
bool slam_
Definition: kinfu.h:125
jsk_pcl_ros::Kinfu::sub_color_
message_filters::Subscriber< sensor_msgs::Image > sub_color_
Definition: kinfu.h:140
jsk_pcl_ros::Kinfu::pub_camera_pose_
ros::Publisher pub_camera_pose_
Definition: kinfu.h:144
message_filters::sync_policies::ExactTime
jsk_pcl_ros::Kinfu::SyncPolicyWithColor
message_filters::sync_policies::ApproximateTime< sensor_msgs::CameraInfo, sensor_msgs::Image, sensor_msgs::Image > SyncPolicyWithColor
Definition: kinfu.h:84
jsk_pcl_ros::Kinfu::sub_camera_info_
message_filters::Subscriber< sensor_msgs::CameraInfo > sub_camera_info_
Definition: kinfu.h:138
jsk_pcl_ros::Kinfu::odom_init_to_kinfu_origin_
Eigen::Affine3f odom_init_to_kinfu_origin_
Definition: kinfu.h:136
jsk_pcl_ros::Kinfu::srv_
boost::shared_ptr< dynamic_reconfigure::Server< Config > > srv_
Definition: kinfu.h:102
jsk_pcl_ros::Kinfu::srv_reset_
ros::ServiceServer srv_reset_
Definition: kinfu.h:152
jsk_pcl_ros::Kinfu::unsubscribe
virtual void unsubscribe()
Definition: kinfu_nodelet.cpp:196
sample_pointcloud_localization_client.req
req
Definition: sample_pointcloud_localization_client.py:15
jsk_pcl_ros::Kinfu::frame_idx_
int frame_idx_
Definition: kinfu.h:130
jsk_pcl_ros::Kinfu::sync_with_color_
boost::shared_ptr< message_filters::Synchronizer< SyncPolicyWithColor > > sync_with_color_
Definition: kinfu.h:142
sample_empty_service_caller.res
res
Definition: sample_empty_service_caller.py:14
pcl_conversions.h


jsk_pcl_ros
Author(s): Yohei Kakiuchi
autogenerated on Tue Jan 7 2025 04:05:45