Fawkes API  Fawkes Development Version
visualization_thread.h
00001 
00002 /***************************************************************************
00003  *  visualization_thread.h - Visualization via rviz
00004  *
00005  *  Created: Fri Nov 11 00:11:23 2011
00006  *  Copyright  2011  Tim Niemueller [www.niemueller.de]
00007  ****************************************************************************/
00008 
00009 /*  This program is free software; you can redistribute it and/or modify
00010  *  it under the terms of the GNU General Public License as published by
00011  *  the Free Software Foundation; either version 2 of the License, or
00012  *  (at your option) any later version.
00013  *
00014  *  This program is distributed in the hope that it will be useful,
00015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  *  GNU Library General Public License for more details.
00018  *
00019  *  Read the full text in the LICENSE.GPL file in the doc directory.
00020  */
00021 
00022 #ifndef __PLUGINS_PERCEPTION_TABLETOP_OBJECTS_VISUALIZATION_THREAD_H_
00023 #define __PLUGINS_PERCEPTION_TABLETOP_OBJECTS_VISUALIZATION_THREAD_H_
00024 
00025 #ifndef HAVE_VISUAL_DEBUGGING
00026 #  error TabletopVisualizationThread was disabled by build flags
00027 #endif
00028 
00029 #include "visualization_thread_base.h"
00030 
00031 #include <core/threading/thread.h>
00032 #include <core/threading/mutex.h>
00033 #include <aspect/tf.h>
00034 #include <aspect/configurable.h>
00035 #include <plugins/ros/aspect/ros.h>
00036 
00037 namespace ros {
00038   class Publisher;
00039 }
00040 
00041 class TabletopVisualizationThread
00042 : public TabletopVisualizationThreadBase,
00043   public fawkes::Thread,
00044   public fawkes::TransformAspect,
00045   public fawkes::ConfigurableAspect,
00046   public fawkes::ROSAspect
00047 {
00048  public:
00049   TabletopVisualizationThread();
00050 
00051   virtual void init();
00052   virtual void loop();
00053   virtual void finalize();
00054 
00055   virtual void visualize(const std::string &frame_id,
00056                          Eigen::Vector4f &table_centroid,
00057                          Eigen::Vector4f &normal,
00058                          V_Vector4f &table_hull_vertices,
00059                          V_Vector4f &table_model_vertices,
00060                          V_Vector4f &good_table_hull_edges,
00061                          V_Vector4f &centroids) throw();
00062 
00063  private:
00064   void triangulate_hull();
00065 
00066  private:
00067   fawkes::Mutex mutex_;
00068   std::string frame_id_;
00069   Eigen::Vector4f table_centroid_;
00070   Eigen::Vector4f normal_;
00071   V_Vector4f table_hull_vertices_;
00072   V_Vector4f table_model_vertices_;
00073   V_Vector4f good_table_hull_edges_;
00074   V_Vector4f table_triangle_vertices_;
00075   V_Vector4f centroids_;
00076   ros::Publisher *vispub_;
00077 #ifdef USE_POSEPUB
00078   ros::Publisher *posepub_;
00079 #endif
00080   size_t last_id_num_;
00081 
00082   bool         cfg_show_frustrum_;
00083   float        cfg_horizontal_va_;
00084   float        cfg_vertical_va_;
00085   bool         cfg_show_cvxhull_vertices_;
00086   bool         cfg_show_cvxhull_line_highlighting_;
00087   bool         cfg_show_cvxhull_vertex_ids_;
00088   unsigned int cfg_duration_;
00089  public:
00090   EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00091 };
00092 
00093 
00094 #endif