00001 #ifndef NXT_COLOR_DISPLAY_H 00002 #define NXT_COLOR_DISPLAY_H 00003 00004 #include "rviz/display.h" 00005 #include "rviz/helpers/color.h" 00006 #include "rviz/properties/forwards.h" 00007 00008 #include <nxt_msgs/Color.h> 00009 00010 #include <message_filters/subscriber.h> 00011 #include <tf/message_filter.h> 00012 00013 #include <boost/shared_ptr.hpp> 00014 00015 namespace ogre_tools 00016 { 00017 class Shape; 00018 } 00019 00020 00021 namespace Ogre 00022 { 00023 class SceneNode; 00024 } 00025 00026 namespace nxt_rviz_plugin 00027 { 00028 00033 class NXTColorDisplay : public rviz::Display 00034 { 00035 public: 00036 NXTColorDisplay( const std::string& name, rviz::VisualizationManager* manager ); 00037 virtual ~NXTColorDisplay(); 00038 00039 void setTopic( const std::string& topic ); 00040 const std::string& getTopic() { return topic_; } 00041 00042 void setAlpha( float alpha ); 00043 float getAlpha() { return alpha_; } 00044 00045 void setDisplayLength( float displayLength ); 00046 float getDisplayLength() { return displayLength_; } 00047 00048 // Overrides from Display 00049 virtual void targetFrameChanged() {} 00050 virtual void fixedFrameChanged(); 00051 virtual void createProperties(); 00052 virtual void update(float wall_dt, float ros_dt); 00053 virtual void reset(); 00054 00055 static const char* getTypeStatic() { return "Color"; } 00056 virtual const char* getType() const { return getTypeStatic(); } 00057 static const char* getDescription(); 00058 00059 protected: 00060 void subscribe(); 00061 void unsubscribe(); 00062 void clear(); 00063 void incomingMessage(const nxt_msgs::Color::ConstPtr& msg); 00064 void processMessage(const nxt_msgs::Color::ConstPtr& msg); 00065 00066 // overrides from Display 00067 virtual void onEnable(); 00068 virtual void onDisable(); 00069 00070 std::string topic_; 00071 float alpha_; 00072 float displayLength_; 00073 00074 uint32_t messages_received_; 00075 00076 Ogre::SceneNode* scene_node_; 00077 ogre_tools::Shape* cylinder_; 00078 00079 message_filters::Subscriber<nxt_msgs::Color> sub_; 00080 tf::MessageFilter<nxt_msgs::Color> tf_filter_; 00081 nxt_msgs::Color::ConstPtr current_message_; 00082 00083 rviz::ROSTopicStringPropertyWPtr topic_property_; 00084 rviz::FloatPropertyWPtr alpha_property_; 00085 rviz::FloatPropertyWPtr display_property_; 00086 }; 00087 00088 } // namespace nxt_rviz_plugin 00089 00090 #endif /* NXT_COLOR_DISPLAY_H */ 00091