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_;
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)%
jsk_rviz_plugins::AmbientSoundDisplay::updateColorAndAlpha
void updateColorAndAlpha()
Definition: ambient_sound_display.cpp:155
jsk_rviz_plugins::AmbientSoundDisplay::setColor
void setColor(const rviz::Color &color)
Definition: ambient_sound_display.cpp:99
jsk_rviz_plugins::AmbientSoundDisplay::setAlpha
void setAlpha(float alpha)
Definition: ambient_sound_display.cpp:108
jsk_rviz_plugins::AmbientSoundDisplay::onDisable
virtual void onDisable()
Definition: ambient_sound_display.cpp:246
jsk_rviz_plugins::AmbientSoundDisplay::unsubscribe
void unsubscribe()
Definition: ambient_sound_display.cpp:236
Ogre
contact_state_marker.scale
scale
Definition: contact_state_marker.py:91
jsk_rviz_plugins::AmbientSoundDisplay::onEnable
virtual void onEnable()
Definition: ambient_sound_display.cpp:241
jsk_rviz_plugins::AmbientSoundDisplay::createProperties
virtual void createProperties()
Definition: ambient_sound_display.cpp:316
jsk_rviz_plugins::AmbientSoundDisplay::getWidth
float getWidth() const
Definition: ambient_sound_display.h:49
jsk_rviz_plugins::AmbientSoundDisplay::alpha_property_
rviz::FloatPropertyWPtr alpha_property_
Definition: ambient_sound_display.h:107
jsk_rviz_plugins::AmbientSoundDisplay::onInitialize
virtual void onInitialize()
Definition: ambient_sound_display.cpp:35
jsk_rviz_plugins::AmbientSoundDisplay::width_
float width_
Definition: ambient_sound_display.h:102
jsk_rviz_plugins::AmbientSoundDisplay::subscribe
void subscribe()
Definition: ambient_sound_display.cpp:213
jsk_rviz_plugins::AmbientSoundDisplay::sub_
message_filters::Subscriber< jsk_hark_msgs::HarkPower > sub_
Definition: ambient_sound_display.h:93
jsk_rviz_plugins::AmbientSoundDisplay::messages_received_
int messages_received_
Definition: ambient_sound_display.h:95
jsk_rviz_plugins::AmbientSoundDisplay::color_property_
rviz::ColorPropertyWPtr color_property_
Definition: ambient_sound_display.h:105
jsk_rviz_plugins::AmbientSoundDisplay::history_length_property_
rviz::IntPropertyWPtr history_length_property_
Definition: ambient_sound_display.h:108
jsk_rviz_plugins::AmbientSoundDisplay::getScale
float getScale() const
Definition: ambient_sound_display.h:52
jsk_rviz_plugins::AmbientSoundDisplay::fixedFrameChanged
virtual void fixedFrameChanged()
Definition: ambient_sound_display.cpp:254
jsk_rviz_plugins::AmbientSoundDisplay::scale_
float scale_
Definition: ambient_sound_display.h:102
jsk_rviz_plugins::AmbientSoundDisplay::bias_property_
rviz::FloatPropertyWPtr bias_property_
Definition: ambient_sound_display.h:111
display.h
jsk_rviz_plugins::AmbientSoundDisplay::setTopic
void setTopic(const std::string &topic)
Definition: ambient_sound_display.cpp:85
jsk_rviz_plugins::AmbientSoundDisplay::getBias
float getBias() const
Definition: ambient_sound_display.h:55
jsk_rviz_plugins::AmbientSoundDisplay::grad_
float grad_
Definition: ambient_sound_display.h:102
jsk_rviz_plugins::AmbientSoundDisplay::topic_property_
rviz::ROSTopicStringPropertyWPtr topic_property_
Definition: ambient_sound_display.h:106
message_filters::Subscriber< jsk_hark_msgs::HarkPower >
jsk_rviz_plugins::AmbientSoundDisplay::setGrad
void setGrad(float grad)
Definition: ambient_sound_display.cpp:145
rviz::Display
jsk_rviz_plugins::AmbientSoundDisplay::getGrad
float getGrad() const
Definition: ambient_sound_display.h:58
jsk_rviz_plugins::AmbientSoundDisplay::setWidth
void setWidth(float width)
Definition: ambient_sound_display.cpp:117
jsk_rviz_plugins::AmbientSoundDisplay::alpha_
float alpha_
Definition: ambient_sound_display.h:100
jsk_rviz_plugins::AmbientSoundDisplay::clear
void clear()
Definition: ambient_sound_display.cpp:73
jsk_rviz_plugins::AmbientSoundDisplay::color_
rviz::Color color_
Definition: ambient_sound_display.h:98
jsk_rviz_plugins::AmbientSoundDisplay::visuals_
std::vector< AmbientSoundVisual * > visuals_
Definition: ambient_sound_display.h:87
jsk_rviz_plugins::AmbientSoundDisplay
Definition: ambient_sound_display.h:21
jsk_rviz_plugins::AmbientSoundDisplay::getAlpha
float getAlpha()
Definition: ambient_sound_display.h:43
jsk_rviz_plugins::AmbientSoundDisplay::scene_node_
Ogre::SceneNode * scene_node_
Definition: ambient_sound_display.h:90
jsk_rviz_plugins::AmbientSoundDisplay::incomingMessage
void incomingMessage(const jsk_hark_msgs::HarkPower::ConstPtr &msg)
Definition: ambient_sound_display.cpp:261
message_filter.h
jsk_rviz_plugins::AmbientSoundDisplay::scale_property_
rviz::FloatPropertyWPtr scale_property_
Definition: ambient_sound_display.h:110
jsk_rviz_plugins::AmbientSoundDisplay::tf_filter_
tf::MessageFilter< jsk_hark_msgs::HarkPower > * tf_filter_
Definition: ambient_sound_display.h:94
jsk_rviz_plugins::AmbientSoundDisplay::setHistoryLength
void setHistoryLength(int history_length)
Definition: ambient_sound_display.cpp:167
subscriber.h
jsk_rviz_plugins::AmbientSoundDisplay::bias_
float bias_
Definition: ambient_sound_display.h:102
jsk_rviz_plugins::AmbientSoundDisplay::width_property_
rviz::FloatPropertyWPtr width_property_
Definition: ambient_sound_display.h:109
contact_state_marker.alpha
alpha
Definition: contact_state_marker.py:90
jsk_rviz_plugins::AmbientSoundDisplay::history_length_
int history_length_
Definition: ambient_sound_display.h:101
jsk_rviz_plugins::AmbientSoundDisplay::reset
virtual void reset()
Definition: ambient_sound_display.cpp:306
jsk_rviz_plugins::AmbientSoundDisplay::~AmbientSoundDisplay
virtual ~AmbientSoundDisplay()
Definition: ambient_sound_display.cpp:60
tf::MessageFilter< jsk_hark_msgs::HarkPower >
jsk_rviz_plugins::AmbientSoundDisplay::setScale
void setScale(float scale)
Definition: ambient_sound_display.cpp:126
jsk_rviz_plugins::AmbientSoundDisplay::AmbientSoundDisplay
AmbientSoundDisplay()
Definition: ambient_sound_display.cpp:21
jsk_rviz_plugins::AmbientSoundDisplay::topic_
std::string topic_
Definition: ambient_sound_display.h:99
jsk_rviz_plugins::AmbientSoundDisplay::getColor
const rviz::Color & getColor()
Definition: ambient_sound_display.h:40
jsk_rviz_plugins::AmbientSoundDisplay::getHistoryLength
int getHistoryLength() const
Definition: ambient_sound_display.h:46
jsk_rviz_plugins::AmbientSoundDisplay::grad_property_
rviz::FloatPropertyWPtr grad_property_
Definition: ambient_sound_display.h:112
jsk_rviz_plugins
Definition: __init__.py:1
rviz::Color
jsk_rviz_plugins::AmbientSoundDisplay::setBias
void setBias(float bias)
Definition: ambient_sound_display.cpp:136
jsk_rviz_plugins::AmbientSoundDisplay::getTopic
const std::string & getTopic()
Definition: ambient_sound_display.h:37


jsk_rviz_plugins
Author(s): Kei Okada , Yohei Kakiuchi , Shohei Fujii , Ryohei Ueda
autogenerated on Fri Aug 2 2024 08:50:14