00001 00060 #ifndef SHAPE_MARKER_H_ 00061 #define SHAPE_MARKER_H_ 00062 00063 00064 //################## 00065 //#### includes #### 00066 // standard includes 00067 #include <stdio.h> 00068 #include <sstream> 00069 #include <math.h> 00070 #include <stdlib.h> 00071 #include <vector> 00072 #include <algorithm> 00073 // ROS includes 00074 #include <ros/ros.h> 00075 //#include <sensor_msgs/PointCloud2.h> 00076 #include <visualization_msgs/Marker.h> 00077 #include <visualization_msgs/MarkerArray.h> 00078 #include <visualization_msgs/InteractiveMarker.h> 00079 #include <visualization_msgs/InteractiveMarkerControl.h> 00080 //#include <visualization_msgs/MenuEntry.h> 00081 #include <interactive_markers/interactive_marker_server.h> 00082 #include <interactive_markers/menu_handler.h> 00083 00084 // PCL includes 00085 #include <pcl/pcl_config.h> 00086 #ifdef PCL_VERSION_COMPARE 00087 #include <pcl/common/transforms.h> 00088 #else 00089 #include <pcl/common/transform.h> 00090 #endif 00091 #include <pcl/common/eigen.h> 00092 #include <pcl/point_cloud.h> 00093 #include <pcl/ros/conversions.h> 00094 #include <pcl/point_types.h> 00095 00096 //#include <boost/bind.hpp> 00097 //#include <boost/make_shared.hpp> 00098 #include <boost/shared_ptr.hpp> 00099 00100 // external includes 00101 #include <Eigen/Core> 00102 00103 //#include <cob_3d_mapping_msgs/ShapeArray.h> 00104 //#include <cob_3d_mapping_common/polypartition.h> 00105 #include <cob_3d_mapping_msgs/ModifyMap.h> 00106 #include <cob_3d_mapping_common/ros_msg_conversions.h> 00107 #include "cob_3d_mapping_common/polygon.h" 00108 #include "cob_3d_mapping_common/cylinder.h" 00109 //#include <cob_3d_visualization/shape_visualization.h> 00110 00111 //#define PI 3.14159265 00112 00113 //using namespace cob_3d_mapping ; 00114 class ShapeMarker 00115 { 00116 public: 00117 00118 ShapeMarker(boost::shared_ptr<interactive_markers::InteractiveMarkerServer> im_server, 00119 cob_3d_mapping_msgs::Shape& shape,std::vector<unsigned int>& moved_shapes_indices,std::vector<unsigned int>& interacted_shapes, 00120 std::vector<unsigned int>& deleted_markers_indices, bool arrows,bool deleted); 00121 ~ShapeMarker() 00122 { 00123 if(im_server_->erase(marker_.name)){ 00124 // ROS_INFO("Marker %s erased",marker_.name.c_str()); 00125 stringstream ss; 00126 ss << "normal_" << shape_.id; 00127 im_server_->erase(ss.str()); 00128 ss.str(""); 00129 ss.clear(); 00130 ss << "centroid_" << shape_.id; 00131 im_server_->erase(ss.str()); 00132 } 00133 } 00134 00143 void triangle_refinement(list<TPPLPoly>& i_list,list<TPPLPoly>& o_list); 00144 void getShape (cob_3d_mapping_msgs::Shape& shape); 00149 bool getArrows(); 00154 bool setArrows(); 00159 bool getDeleted(); 00164 bool setDeleted(); 00169 unsigned int getID() ; 00174 void enableMovement (const visualization_msgs::InteractiveMarkerFeedbackConstPtr& feedback) ; 00178 void displayArrows() ; 00183 void hideArrows(int flag_untick) ; 00187 void createShapeMenu () ; 00192 void deleteMarker(const visualization_msgs::InteractiveMarkerFeedbackConstPtr& feedback) ; 00199 TPPLPoint msgToPoint2D (const pcl::PointXYZ &point) ; 00207 void createMarker (visualization_msgs::InteractiveMarkerControl& im_ctrl); 00211 void createInteractiveMarker () ; 00217 void displayNormalCB (const visualization_msgs::InteractiveMarkerFeedbackConstPtr& feedback) ; 00221 void displayNormal(); 00226 void hideNormal(int flag_untick); 00232 void displaySymAxisCB (const visualization_msgs::InteractiveMarkerFeedbackConstPtr& feedback) ; 00236 void displaySymAxis(); 00241 void hideSymAxis(int flag_untick); 00247 void displayCentroidCB (const visualization_msgs::InteractiveMarkerFeedbackConstPtr& feedback) ; 00251 void displayCentroid(); 00255 void hideCentroid(int flag_untick); 00261 void displayOriginCB (const visualization_msgs::InteractiveMarkerFeedbackConstPtr& feedback) ; 00265 void displayOrigin(); 00269 void hideOrigin(int flag_untick); 00275 void displayContourCB(const visualization_msgs::InteractiveMarkerFeedbackConstPtr& feedback) ; 00279 void displayContour(); 00283 void hideContour(int flag_untick); 00288 void resetMarker(); 00289 00290 void displayIDCB(const visualization_msgs::InteractiveMarkerFeedbackConstPtr& feedback); 00291 void displayID(); 00292 void hideID(int flag_untick); 00293 00294 visualization_msgs::Marker& getMarker() {return marker;}; 00295 visualization_msgs::MarkerArray& getContourMarker() {return contour_marker_;}; 00296 visualization_msgs::MarkerArray& getDeleteContourMarker() {return delete_contour_marker_;}; 00297 00298 00299 00300 00301 protected: 00302 visualization_msgs::InteractiveMarker marker_ ; 00303 visualization_msgs::InteractiveMarker imarker_ ; 00304 visualization_msgs::InteractiveMarker deleted_imarker_ ; 00305 visualization_msgs::Marker marker; 00306 visualization_msgs::MarkerArray contour_marker_; 00307 visualization_msgs::MarkerArray delete_contour_marker_; 00308 00309 // ros::NodeHandle nh_; 00310 // ros::Subscriber feedback_sub_ ; 00311 // ros::Publisher marker_pub_ ; 00312 00313 visualization_msgs::InteractiveMarkerControl im_ctrl; 00314 00315 boost::shared_ptr<interactive_markers::InteractiveMarkerServer> im_server_; 00316 cob_3d_mapping_msgs::Shape shape_; 00317 00318 00319 interactive_markers::MenuHandler menu_handler_; 00320 00321 Eigen::Affine3f transformation_; 00322 Eigen::Affine3f transformation_inv_; 00323 // int shape_ctr_ ; 00324 00325 00326 // int shape_ctr_ ; 00327 unsigned int id_; 00328 std::vector<unsigned int>& moved_shapes_indices_ ; 00329 std::vector<unsigned int>& interacted_shapes_ ; 00330 std::vector<unsigned int>& deleted_markers_indices_ ; 00331 // unsigned int& deleted_ ; 00332 00333 00334 bool arrows_; 00335 bool deleted_ ; 00336 // cob_3d_mapping_msgs::ModifyMap::Request req ; 00337 // cob_3d_mapping_msgs::ModifyMap::Response res; 00338 // // 00339 // Eigen::Quaternionf quatInit ; 00340 // Eigen::Vector3f oldCentroid ; 00341 // Eigen::Matrix4f transInit; 00342 // Eigen::Affine3f affineInit; 00343 // Eigen::Matrix4f transInitInv; 00344 00345 }; 00346 00347 00348 00349 00350 #endif /* SHAPE_MARKER_H_ */