@@ -71,15 +71,15 @@ PointCloudRGB cloud_xyz_rgb_;
71
71
void cloud_cb (const sensor_msgs::PointCloud2ConstPtr& cloud)
72
72
{
73
73
m_.lock ();
74
- ROS_INFO_STREAM (" Pointcloud viewer has received a pointcloud ." );
74
+ ROS_INFO_STREAM (" [PointCloudViewer:] Pointcloud received." );
75
75
cloud_ = cloud;
76
76
m_.unlock ();
77
77
}
78
78
79
79
void keyboardEventOccurred (const pcl::visualization::KeyboardEvent& event, void * nothing)
80
80
{
81
81
if (event.getKeySym () == " space" && event.keyDown ()) {
82
- ROS_INFO (" Saving pointcloud, please wait..." );
82
+ ROS_INFO (" [PointCloudViewer:] Saving pointcloud, please wait..." );
83
83
save_cloud_ = true ;
84
84
}
85
85
}
@@ -156,23 +156,14 @@ void updateVisualization()
156
156
// Initialize the camera view
157
157
if (!viewer_initialized_)
158
158
{
159
- pcl::computeMeanAndCovarianceMatrix (cloud_xyz_rgb_ , covariance_matrix, xyz_centroid);
159
+ pcl::computeMeanAndCovarianceMatrix (cloud_xyz_ , covariance_matrix, xyz_centroid);
160
160
viewer.initCameraParameters ();
161
161
viewer.setCameraPosition (xyz_centroid (0 ), xyz_centroid (1 ), xyz_centroid (2 )+3.0 , 0 , -1 , 0 );
162
162
ROS_INFO_STREAM (" [PointCloudViewer:] Point cloud viewer camera initialized in: [" <<
163
163
xyz_centroid (0 ) << " , " << xyz_centroid (1 ) << " , " << xyz_centroid (2 )+3.0 << " ]" );
164
164
viewer_initialized_ = true ;
165
165
}
166
166
167
- // Some xyz_rgb point clouds have incorrect rgb field. Detect and convert to xyz.
168
- if (pcl::getFieldIndex (cloud_xyz_rgb_, " rgb" , fields) != -1 )
169
- {
170
- if (cloud_xyz_rgb_.points [0 ].rgb == 0 )
171
- {
172
- pcl::copyPointCloud (cloud_xyz_rgb_, cloud_xyz_);
173
- }
174
- }
175
-
176
167
// Show the xyz point cloud
177
168
PointCloudColorHandlerGenericField<Point> color_handler (cloud_xyz_.makeShared (), " z" );
178
169
if (!color_handler.isCapable ())
@@ -211,15 +202,15 @@ void saveCallback(const ros::WallTimerEvent&)
211
202
}
212
203
}
213
204
214
- void sigIntHandler (int sig)
215
- {
216
- exit (0 );
217
- }
205
+ // void sigIntHandler(int sig)
206
+ // {
207
+ // exit(0);
208
+ // }
218
209
219
210
/* ---[ */
220
211
int main (int argc, char ** argv)
221
212
{
222
- ros::init (argc, argv, " pointcloud_viewer" , ros::init_options::NoSigintHandler);
213
+ ros::init (argc, argv, " pointcloud_viewer" ); // , ros::init_options::NoSigintHandler);
223
214
ros::NodeHandle nh;
224
215
ros::NodeHandle nh_priv (" ~" );
225
216
viewer_initialized_ = false ;
@@ -232,9 +223,9 @@ int main(int argc, char** argv)
232
223
// Create a ROS subscriber
233
224
ros::Subscriber sub = nh.subscribe (" input" , 30 , cloud_cb);
234
225
235
- ROS_INFO (" Subscribing to %s for PointCloud2 messages..." , nh.resolveName (" input" ).c_str ());
226
+ ROS_INFO (" [PointCloudViewer:] Subscribing to %s for PointCloud2 messages..." , nh.resolveName (" input" ).c_str ());
236
227
237
- signal (SIGINT, sigIntHandler);
228
+ // signal(SIGINT, sigIntHandler);
238
229
boost::thread visualization_thread (&updateVisualization);
239
230
save_timer_ = nh.createWallTimer (ros::WallDuration (1 ), &saveCallback);
240
231
0 commit comments