ambient_sound_visual.cpp
Go to the documentation of this file.
1 #include <OGRE/OgreVector3.h>
2 #include <OGRE/OgreSceneNode.h>
3 #include <OGRE/OgreSceneManager.h>
4 
7 
8 #include "ambient_sound_visual.h"
9 
10 namespace jsk_rviz_plugins
11 {
12 
13  // BEGIN_TUTORIAL
14  AmbientSoundVisual::AmbientSoundVisual( Ogre::SceneManager* scene_manager, Ogre::SceneNode* parent_node ): /*{{{*/
15  width_ (0.1),
16  scale_ (1.0),
17  bias_ (28),
18  grad_ (0.4)
19  {
20  scene_manager_ = scene_manager;
21 
22  // Ogre::SceneNode s form a tree, with each node storing the
23  // transform (position and orientation) of itself relative to its
24  // parent. Ogre does the math of combining those transforms when it
25  // is time to render.
26  //
27  // Here we create a node to store the pose of the Imu's header frame
28  // relative to the RViz fixed frame.
29  frame_node_ = parent_node->createChildSceneNode();
30 
31  // We create the arrow object within the frame node so that we can
32  // set its position and direction relative to its header frame.
34  //axes_ = new rviz::Axes( scene_manager_ , frame_node_);
35  }/*}}}*/
36 
38  {
39  // Delete the arrow to make it disappear.
41  //delete axes_;
42 
43  // Destroy the frame node since we don't need it anymore.
44  scene_manager_->destroySceneNode( frame_node_ );
45  }/*}}}*/
46 
47  void AmbientSoundVisual::setMessage( const jsk_hark_msgs::HarkPower::ConstPtr& msg )/*{{{*/
48  {
49  int directions = msg->directions;
50  std::vector<float> powers = msg->powers;
51 
52  //float powers[] = {/*{{{*/
53  //25,25,28,30,34,32,29,25,25,25,
54  //25,25,25,25,25,25,25,25,25,25,
55  //25,25,25,25,25,25,25,25,25,25,
56  //25,25,25,25,25,25,25,25,25,25,
57  //25,25,25,25,25,25,25,25,25,25,
58  //25,25,25,25,25,25,25,25,25,25,
59  //25,25,25,25,25,25,25,25,25,25,
60  //25,25,
61  //};/*}}}*/
62 
63  if ( powers[0] == 0.0 ){ return;}
64  //float min_elem = *std::min_element(powers.begin(),powers.end());
65  //axes_->setOrientation(orientation_);
66  //axes_->setPosition(position_);
69  for (int i = 0; i <= directions ; i++) {
70  float biased_power = (powers[(i%directions)] - bias_) * grad_;
71  if (biased_power <= 0.0) { biased_power = 0.001; }
72  Ogre::Vector3 point = Ogre::Vector3((biased_power*scale_)*cos(i*(2*M_PI/directions)- M_PI), (biased_power*scale_)*sin(i*(2*M_PI/directions) - M_PI), 0);
74  //std::cout << biased_power << " ";
75  }
76  //std::cout << std::endl;
77 
78  //Ogre::ColourValue color;
79  //ambient_sound_power_line_->setColor(color.r, color.g, color.b, color.a);
80  }/*}}}*/
81 
82  // Position and orientation are passed through to the SceneNode.
83  void AmbientSoundVisual::setFramePosition( const Ogre::Vector3& position )/*{{{*/
84  {
85  //ROS_INFO_STREAM("pos: " << position);
86  //frame_node_->setPosition( position ); //<- unnecessary
87  position_ = position;
88  }
89 
90  void AmbientSoundVisual::setFrameOrientation( const Ogre::Quaternion& orientation )
91  {
92  //ROS_INFO_STREAM("orientation: " << orientation);
93  //frame_node_->setOrientation( orientation ); //<- unnecessary
94  orientation_ = orientation;
95  }
96  /*}}}*/
97 
98  // Color is passed through to the Arrow object.
99  /*{{{*/
100  void AmbientSoundVisual::setColor( float r, float g, float b, float a )
101  {
103  }
104 
105  // added by sifi
107  {
108  width_ = w;
109  }
111  {
112  scale_ = s;
113  }
115  {
116  bias_ = b;
117  }
119  {
120  grad_ = g;
121  }
122  /*}}}*/
123 
124  // END_TUTORIAL
125 
126 } // end namespace jsk_rviz_plugins
127 
rviz::BillboardLine::clear
void clear()
rviz::BillboardLine
jsk_rviz_plugins::AmbientSoundVisual::orientation_
Ogre::Quaternion orientation_
Definition: ambient_sound_visual.h:76
rviz::BillboardLine::setLineWidth
void setLineWidth(float width)
axes.h
msg
msg
jsk_rviz_plugins::AmbientSoundVisual::setBias
void setBias(float b)
Definition: ambient_sound_visual.cpp:114
jsk_rviz_plugins::AmbientSoundVisual::ambient_sound_power_line_
rviz::BillboardLine * ambient_sound_power_line_
Definition: ambient_sound_visual.h:64
jsk_rviz_plugins::AmbientSoundVisual::scene_manager_
Ogre::SceneManager * scene_manager_
Definition: ambient_sound_visual.h:73
bounding_box_sample.w
w
Definition: bounding_box_sample.py:29
jsk_rviz_plugins::AmbientSoundVisual::setColor
void setColor(float r, float g, float b, float a)
Definition: ambient_sound_visual.cpp:100
jsk_rviz_plugins::AmbientSoundVisual::grad_
float grad_
Definition: ambient_sound_visual.h:80
jsk_rviz_plugins::AmbientSoundVisual::bias_
float bias_
Definition: ambient_sound_visual.h:80
billboard_line.h
jsk_rviz_plugins::AmbientSoundVisual::AmbientSoundVisual
AmbientSoundVisual(Ogre::SceneManager *scene_manager, Ogre::SceneNode *parent_node)
Definition: ambient_sound_visual.cpp:14
jsk_rviz_plugins::AmbientSoundVisual::position_
Ogre::Vector3 position_
Definition: ambient_sound_visual.h:75
overlay_menu_sample.b
b
Definition: overlay_menu_sample.py:20
jsk_rviz_plugins::AmbientSoundVisual::setMessage
void setMessage(const jsk_hark_msgs::HarkPower::ConstPtr &msg)
Definition: ambient_sound_visual.cpp:47
jsk_rviz_plugins::AmbientSoundVisual::width_
float width_
Definition: ambient_sound_visual.h:80
ambient_sound_visual.h
jsk_rviz_plugins::AmbientSoundVisual::setGrad
void setGrad(float g)
Definition: ambient_sound_visual.cpp:118
bounding_box_sample.r
r
Definition: bounding_box_sample.py:10
jsk_rviz_plugins::AmbientSoundVisual::setWidth
void setWidth(float w)
Definition: ambient_sound_visual.cpp:106
jsk_rviz_plugins::AmbientSoundVisual::setFramePosition
void setFramePosition(const Ogre::Vector3 &position)
Definition: ambient_sound_visual.cpp:83
overlay_menu_sample.g
g
Definition: overlay_menu_sample.py:19
jsk_rviz_plugins::AmbientSoundVisual::frame_node_
Ogre::SceneNode * frame_node_
Definition: ambient_sound_visual.h:69
jsk_rviz_plugins::AmbientSoundVisual::~AmbientSoundVisual
virtual ~AmbientSoundVisual()
Definition: ambient_sound_visual.cpp:37
jsk_rviz_plugins::AmbientSoundVisual::setScale
void setScale(float s)
Definition: ambient_sound_visual.cpp:110
motor_states_temperature_decomposer.s
s
Definition: motor_states_temperature_decomposer.py:79
jsk_rviz_plugins
Definition: __init__.py:1
rviz::BillboardLine::setColor
void setColor(float r, float g, float b, float a) override
jsk_rviz_plugins::AmbientSoundVisual::setFrameOrientation
void setFrameOrientation(const Ogre::Quaternion &orientation)
Definition: ambient_sound_visual.cpp:90
rviz::BillboardLine::addPoint
void addPoint(const Ogre::Vector3 &point)
jsk_rviz_plugins::AmbientSoundVisual::scale_
float scale_
Definition: ambient_sound_visual.h:80


jsk_rviz_plugins
Author(s): Kei Okada , Yohei Kakiuchi , Shohei Fujii , Ryohei Ueda
autogenerated on Mon Jan 22 2024 03:47:13