naoqidriver
sonar.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2015 Aldebaran
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 
18 #ifndef SONAR_RECORDER_HPP
19 #define SONAR_RECORDER_HPP
20 
21 /*
22 * BOOST includes
23 */
24 #include <boost/circular_buffer.hpp>
25 
26 /*
27 * LOCAL includes
28 */
30 #include "../helpers/recorder_helpers.hpp"
31 
32 /*
33 * ROS includes
34 */
35 #include <sensor_msgs/Range.h>
36 
37 namespace naoqi
38 {
39 namespace recorder
40 {
41 
43 {
44 
45 public:
46  SonarRecorder( const std::vector<std::string>& topics, float buffer_frequency = 0 );
47 
48  void write(const std::vector<sensor_msgs::Range>& sonar_msgs );
49 
50  void reset( boost::shared_ptr<naoqi::recorder::GlobalRecorder> gr, float conv_frequency );
51 
52  void bufferize(const std::vector<sensor_msgs::Range>& sonar_msgs );
53 
54  void writeDump(const ros::Time& time);
55 
56  void setBufferDuration(float duration);
57 
58  inline std::string topic() const
59  {
60  return "sonar";
61  }
62 
63  inline bool isInitialized() const
64  {
65  return is_initialized_;
66  }
67 
68  inline void subscribe( bool state)
69  {
70  is_subscribed_ = state;
71  }
72 
73  inline bool isSubscribed() const
74  {
75  return is_subscribed_;
76  }
77 
78 protected:
79  std::string topic_;
80 
81  boost::circular_buffer< std::vector<sensor_msgs::Range> > buffer_;
82  size_t buffer_size_;
84 
85  boost::mutex mutex_;
86 
89 
90  boost::shared_ptr<naoqi::recorder::GlobalRecorder> gr_;
91  std::vector<std::string> topics_;
92 
95  int counter_;
97 
98 }; // class
99 
100 } //publisher
101 } // naoqi
102 
103 #endif
bool isInitialized() const
Definition: sonar.hpp:63
void bufferize(const std::vector< sensor_msgs::Range > &sonar_msgs)
Definition: sonar.cpp:82
int max_counter_
Definition: sonar.hpp:96
void subscribe(bool state)
Definition: sonar.hpp:68
Definition: sonar.hpp:42
bool isSubscribed() const
Definition: sonar.hpp:73
float buffer_frequency_
Definition: sonar.hpp:93
void reset(boost::shared_ptr< naoqi::recorder::GlobalRecorder > gr, float conv_frequency)
Definition: sonar.cpp:64
float buffer_duration_
Definition: sonar.hpp:83
boost::circular_buffer< std::vector< sensor_msgs::Range > > buffer_
Definition: sonar.hpp:81
Definition: audio.cpp:29
void setBufferDuration(float duration)
Definition: sonar.cpp:96
bool is_initialized_
Definition: sonar.hpp:87
size_t buffer_size_
Definition: sonar.hpp:82
bool is_subscribed_
Definition: sonar.hpp:88
boost::mutex mutex_
Definition: sonar.hpp:85
std::vector< std::string > topics_
Definition: sonar.hpp:91
float conv_frequency_
Definition: sonar.hpp:94
boost::shared_ptr< naoqi::recorder::GlobalRecorder > gr_
Definition: sonar.hpp:90
SonarRecorder(const std::vector< std::string > &topics, float buffer_frequency=0)
Definition: sonar.cpp:28
void writeDump(const ros::Time &time)
Definition: sonar.cpp:54
void write(const std::vector< sensor_msgs::Range > &sonar_msgs)
Definition: sonar.cpp:35
std::string topic() const
Definition: sonar.hpp:58
int counter_
Definition: sonar.hpp:95
std::string topic_
Definition: sonar.hpp:79