ambient_sound_display.h
Go to the documentation of this file.
1 #ifndef __AMBIENT_SOUND_DISPLAY__
2 #define __AMBIENT_SOUND_DISPLAY__
3 
5 #include <tf/message_filter.h>
6 #include <jsk_hark_msgs/HarkPower.h>
7 #include <rviz/display.h>
8 
9 namespace Ogre
10 {
11 class SceneNode;
12 }
13 
14 // All the source in this plugin is in its own namespace. This is not
15 // required but is good practice.
16 namespace jsk_rviz_plugins
17 {
18 
19 class AmbientSoundVisual;
20 
22 {
23 public:
24  // Constructor. pluginlib::ClassLoader creates instances by calling
25  // the default constructor, so make sure you have one.
27  virtual ~AmbientSoundDisplay();
28 
29  // Overrides of public virtual functions from the Display class.
30  virtual void onInitialize();
31  virtual void fixedFrameChanged();
32  virtual void reset();
33  virtual void createProperties();
34 
35  // Setter and getter functions for user-editable properties.
36  void setTopic(const std::string& topic);
37  const std::string& getTopic() { return topic_; }
38 
39  void setColor( const rviz::Color& color );
40  const rviz::Color& getColor() { return color_; }
41 
42  void setAlpha( float alpha );
43  float getAlpha() { return alpha_; }
44 
45  void setHistoryLength( int history_length );
46  int getHistoryLength() const { return history_length_; }
47 
48  void setWidth( float width );
49  float getWidth() const { return width_; }
50 
51  void setScale( float scale );
52  float getScale() const { return scale_; }
53 
54  void setBias( float bias );
55  float getBias() const { return bias_; }
56 
57  void setGrad( float grad );
58  float getGrad() const { return grad_; }
59 
60  // Overrides of protected virtual functions from Display. As much
61  // as possible, when Displays are not enabled, they should not be
62  // subscribed to incoming data and should not show anything in the
63  // 3D view. These functions are where these connections are made
64  // and broken.
65 protected:
66  virtual void onEnable();
67  virtual void onDisable();
68 
69  // Function to handle an incoming ROS message.
70 private:
71  void incomingMessage( const jsk_hark_msgs::HarkPower::ConstPtr& msg );
72 
73  // Internal helpers which do the work of subscribing and
74  // unsubscribing from the ROS topic.
75  void subscribe();
76  void unsubscribe();
77 
78  // A helper to clear this display back to the initial state.
79  void clear();
80 
81  // Helper function to apply color and alpha to all visuals.
82  void updateColorAndAlpha();
83 
84  // Storage for the list of visuals. This display supports an
85  // adjustable history length, so we need one visual per history
86  // item.
87  std::vector<AmbientSoundVisual*> visuals_;
88 
89  // A node in the Ogre scene tree to be the parent of all our visuals.
90  Ogre::SceneNode* scene_node_;
91 
92  // Data input: Subscriber and tf message filter.
96 
97  // User-editable property variables.
99  std::string topic_;
100  float alpha_;
102  float width_,scale_,bias_,grad_;
103 
104  // Property objects for user-editable properties.
105  rviz::ColorPropertyWPtr color_property_;
106  rviz::ROSTopicStringPropertyWPtr topic_property_;
107  rviz::FloatPropertyWPtr alpha_property_;
108  rviz::IntPropertyWPtr history_length_property_;
109  rviz::FloatPropertyWPtr width_property_;
110  rviz::FloatPropertyWPtr scale_property_;
111  rviz::FloatPropertyWPtr bias_property_;
112  rviz::FloatPropertyWPtr grad_property_;
113 };
114 // END_TUTORIAL
115 
116 } // end namespace jsk_rviz_plugins
117 
118 #endif // __AMBIENT_SOUND_DISPLAY__
119 // %EndTag(FULL_SOURCE)%
msg
rviz::ROSTopicStringPropertyWPtr topic_property_
tf::MessageFilter< jsk_hark_msgs::HarkPower > * tf_filter_
width
void subscribe()
topic
std::vector< AmbientSoundVisual * > visuals_
void unsubscribe()
message_filters::Subscriber< jsk_hark_msgs::HarkPower > sub_


jsk_rviz_plugins
Author(s): Kei Okada , Yohei Kakiuchi , Shohei Fujii , Ryohei Ueda
autogenerated on Thu Jun 1 2023 02:45:58