grab_result.cpp
Go to the documentation of this file.
1 #include <ros/ros.h>
2 #include <pr2_tilt_laser_interface/GetSnapshotActionResult.h>
3 #include <pr2_tilt_laser_interface/GetSnapshotActionFeedback.h>
4 #include <sensor_msgs/PointCloud2.h>
5 #include <pcl/io/pcd_io.h>
6 
8 void
9  resultCallback(const pr2_tilt_laser_interface::GetSnapshotActionResultConstPtr& action_result)
10 {
11  if (action_result->result.cloud.height*action_result->result.cloud.height == 0)
12  return;
13  pub.publish (action_result->result.cloud);
14  ROS_INFO ("Published point cloud from action result!\n");
15 }
16 
17 void
18  feedbackCallback(const pr2_tilt_laser_interface::GetSnapshotActionFeedbackConstPtr& action_feedback)
19 {
20  if (action_feedback->feedback.cloud.height*action_feedback->feedback.cloud.height == 0)
21  return;
22  pub.publish (action_feedback->feedback.cloud);
23  ROS_INFO ("Published point cloud from action feedback!\n");
24 }
25 
26 int
27  main (int argc, char** argv)
28 {
29  ros::init (argc, argv, "result_grabber");
30  ros::NodeHandle nh;
31  pub = nh.advertise<sensor_msgs::PointCloud2>("snapshot", 1, true);
32  ros::Subscriber result_subscriber = nh.subscribe("get_laser_snapshot/result", 1, resultCallback);
33  ros::Subscriber feedback_subscriber = nh.subscribe("get_laser_snapshot/feedback", 1, feedbackCallback);
34 
35  ROS_INFO ("Waiting for cloud to come in over ROS");
36  ros::spin();
37 
38 
39  //while (nh.ok ())
40  //{
41  //ROS_INFO ("Waiting for cloud to come in over ROS");
42  //pr2_tilt_laser_interface::GetSnapshotActionResultConstPtr action_result = ros::topic::waitForMessage<pr2_tilt_laser_interface::GetSnapshotActionResult>("get_laser_snapshot/result");
43  //sensor_msgs::PointCloud2 cloud = action_result->result.cloud;
44 
45  //pub.publish (cloud);
46  //ROS_INFO ("Published the point cloud!\n");
47  //ros::spinOnce ();
48  //ros::Duration (0.5).sleep ();
49  //}
50 
51  return (0);
52 }
ros::Publisher pub
Definition: grab_result.cpp:7
void publish(const boost::shared_ptr< M > &message) const
void feedbackCallback(const pr2_tilt_laser_interface::GetSnapshotActionFeedbackConstPtr &action_feedback)
Definition: grab_result.cpp:18
int main(int argc, char **argv)
Definition: grab_result.cpp:27
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
ROSCPP_DECL void spin(Spinner &spinner)
#define ROS_INFO(...)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
void resultCallback(const pr2_tilt_laser_interface::GetSnapshotActionResultConstPtr &action_result)
Definition: grab_result.cpp:9


pr2_tilt_laser_interface
Author(s): Radu Rusu, Wim Meeusen, Vijay Pradeep
autogenerated on Fri Jun 7 2019 22:06:44