rapid
A ROS robotics library.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
cloud_poser.h
Go to the documentation of this file.
1 #ifndef _RAPID_VIZ_CLOUD_POSER_H_
2 #define _RAPID_VIZ_CLOUD_POSER_H_
3 
4 #include <string>
5 
6 #include "geometry_msgs/Pose.h"
7 #include "interactive_markers/interactive_marker_server.h"
8 #include "pcl/point_cloud.h"
9 #include "pcl/point_types.h"
10 #include "ros/publisher.h"
11 #include "sensor_msgs/PointCloud2.h"
12 #include "transform_graph/graph.h"
13 #include "visualization_msgs/InteractiveMarker.h"
14 #include "visualization_msgs/InteractiveMarkerControl.h"
15 
16 namespace rapid {
17 namespace viz {
18 // CloudPoser is a server for visually adjusting the pose of a point cloud,
19 // which is useful for manually aligning the point cloud with another.
20 //
21 // To use CloudPoser, provide the point cloud and publishers for the point cloud
22 // and interactive marker:
23 //
24 // CloudPoser poser(cloud, cloud_pub, "cloud_poser");
25 //
26 // For best results, the cloud should be supplied in base frame. The interactive
27 // marker to position the object will be in the same frame as the cloud.
28 //
29 // You can set an initial pose offset (in the same frame as the point cloud):
30 // poser.set_pose(pose);
31 // poser.Start();
32 //
33 // You can stop the server to hide the visualization.
34 // poser.Stop();
35 //
36 // You can read the pose offset at any time. The pose offset is the transform
37 // relative to the cloud's pose when it was passed to set_cloud.
38 //
39 // geometry_msgs::Pose pose_out;
40 // poser.GetPose(&pose_out);
41 class CloudPoser {
42  public:
43  CloudPoser(const sensor_msgs::PointCloud2& cloud,
44  const ros::Publisher& cloud_pub, const std::string& im_topic);
45  static std::string int_marker_name();
46 
47  void Start();
48  void Stop();
49 
50  geometry_msgs::Pose pose() const;
51  void set_pose(const geometry_msgs::Pose& pose);
52 
53  private:
54  void ProcessFeedback(
55  const visualization_msgs::InteractiveMarkerFeedbackConstPtr& feedback);
56  void Update();
57 
58  sensor_msgs::PointCloud2 cloud_;
59  ros::Publisher cloud_pub_; // Point cloud publisher
60  interactive_markers::InteractiveMarkerServer im_server_;
61 
62  visualization_msgs::InteractiveMarker int_marker_; // The interactive marker.
63  geometry_msgs::Pose pose_; // The current pose of the marker, which is
64  // positioned at the center of the point cloud.
65  double max_dim_; // The length of the maximum dimension of the point cloud.
66  transform_graph::Graph graph_;
67 };
68 } // namespace viz
69 } // namespace rapid
70 
71 #endif // _RAPID_VIZ_CLOUD_POSER_H_
static std::string int_marker_name()
void set_pose(const geometry_msgs::Pose &pose)
CloudPoser(const sensor_msgs::PointCloud2 &cloud, const ros::Publisher &cloud_pub, const std::string &im_topic)
geometry_msgs::Pose pose() const