ambient_sound_display.h
Go to the documentation of this file.
00001 #ifndef __AMBIENT_SOUND_DISPLAY__
00002 #define __AMBIENT_SOUND_DISPLAY__
00003 
00004 #include <message_filters/subscriber.h>
00005 #include <tf/message_filter.h>
00006 #include <jsk_hark_msgs/HarkPower.h>
00007 #include <rviz/display.h>
00008 
00009 namespace Ogre
00010 {
00011 class SceneNode;
00012 }
00013 
00014 // All the source in this plugin is in its own namespace.  This is not
00015 // required but is good practice.
00016 namespace jsk_rviz_plugins
00017 {
00018 
00019 class AmbientSoundVisual;
00020 
00021 class AmbientSoundDisplay: public rviz::Display
00022 {
00023 public:
00024   // Constructor.  pluginlib::ClassLoader creates instances by calling
00025   // the default constructor, so make sure you have one.
00026   AmbientSoundDisplay();
00027   virtual ~AmbientSoundDisplay();
00028 
00029   // Overrides of public virtual functions from the Display class.
00030   virtual void onInitialize();
00031   virtual void fixedFrameChanged();
00032   virtual void reset();
00033   virtual void createProperties();
00034 
00035   // Setter and getter functions for user-editable properties.
00036   void setTopic(const std::string& topic);
00037   const std::string& getTopic() { return topic_; }
00038 
00039   void setColor( const rviz::Color& color );
00040   const rviz::Color& getColor() { return color_; }
00041 
00042   void setAlpha( float alpha );
00043   float getAlpha() { return alpha_; }
00044 
00045   void setHistoryLength( int history_length );
00046   int getHistoryLength() const { return history_length_; }
00047 
00048   void setWidth( float width );
00049   float getWidth() const { return width_; }
00050 
00051   void setScale( float scale );
00052   float getScale() const { return scale_; }
00053 
00054   void setBias( float bias );
00055   float getBias() const { return bias_; }
00056 
00057   void setGrad( float grad );
00058   float getGrad() const { return grad_; }
00059 
00060   // Overrides of protected virtual functions from Display.  As much
00061   // as possible, when Displays are not enabled, they should not be
00062   // subscribed to incoming data and should not show anything in the
00063   // 3D view.  These functions are where these connections are made
00064   // and broken.
00065 protected:
00066   virtual void onEnable();
00067   virtual void onDisable();
00068 
00069   // Function to handle an incoming ROS message.
00070 private:
00071   void incomingMessage( const jsk_hark_msgs::HarkPower::ConstPtr& msg );
00072 
00073   // Internal helpers which do the work of subscribing and
00074   // unsubscribing from the ROS topic.
00075   void subscribe();
00076   void unsubscribe();
00077 
00078   // A helper to clear this display back to the initial state.
00079   void clear();
00080 
00081   // Helper function to apply color and alpha to all visuals.
00082   void updateColorAndAlpha();
00083 
00084   // Storage for the list of visuals.  This display supports an
00085   // adjustable history length, so we need one visual per history
00086   // item.
00087   std::vector<AmbientSoundVisual*> visuals_;
00088 
00089   // A node in the Ogre scene tree to be the parent of all our visuals.
00090   Ogre::SceneNode* scene_node_;
00091 
00092   // Data input: Subscriber and tf message filter.
00093   message_filters::Subscriber<jsk_hark_msgs::HarkPower> sub_;
00094   tf::MessageFilter<jsk_hark_msgs::HarkPower>* tf_filter_;
00095   int messages_received_;
00096 
00097   // User-editable property variables.
00098   rviz::Color color_;
00099   std::string topic_;
00100   float alpha_;
00101   int history_length_;
00102   float width_,scale_,bias_,grad_;
00103 
00104   // Property objects for user-editable properties.
00105   rviz::ColorPropertyWPtr color_property_;
00106   rviz::ROSTopicStringPropertyWPtr topic_property_;
00107   rviz::FloatPropertyWPtr alpha_property_;
00108   rviz::IntPropertyWPtr history_length_property_;
00109   rviz::FloatPropertyWPtr width_property_;
00110   rviz::FloatPropertyWPtr scale_property_;
00111   rviz::FloatPropertyWPtr bias_property_;
00112   rviz::FloatPropertyWPtr grad_property_;
00113 };
00114 // END_TUTORIAL
00115 
00116 } // end namespace jsk_rviz_plugins
00117 
00118 #endif // __AMBIENT_SOUND_DISPLAY__
00119 // %EndTag(FULL_SOURCE)%


jsk_rviz_plugins
Author(s): Kei Okada , Yohei Kakiuchi , Shohei Fujii , Ryohei Ueda
autogenerated on Wed May 1 2019 02:40:22