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 PUBLISHER_SONAR_HPP
19 #define PUBLISHER_SONAR_HPP
20 
21 /*
22 * ROS includes
23 */
24 #include <ros/ros.h>
25 #include <sensor_msgs/Range.h>
26 
27 namespace naoqi
28 {
29 namespace publisher
30 {
31 
33 {
34 public:
35  SonarPublisher( const std::vector<std::string>& topics );
36 
37  inline std::string topic() const
38  {
39  return "sonar";
40  }
41 
42  inline bool isInitialized() const
43  {
44  return is_initialized_;
45  }
46 
47  void publish( const std::vector<sensor_msgs::Range>& sonar_msgs );
48 
49  void reset( ros::NodeHandle& nh );
50 
51  inline bool isSubscribed() const
52  {
53  if (is_initialized_ == false) return false;
54  for(std::vector<ros::Publisher>::const_iterator it = pubs_.begin(); it != pubs_.end(); ++it)
55  if (it->getNumSubscribers())
56  return true;
57  return false;
58  }
59 
60 private:
61  std::vector<std::string> topics_;
62  std::vector<ros::Publisher> pubs_;
64 
65 };
66 
67 } //publisher
68 } //naoqi
69 
70 #endif
bool isSubscribed() const
Definition: sonar.hpp:51
std::vector< ros::Publisher > pubs_
Definition: sonar.hpp:62
void reset(ros::NodeHandle &nh)
Definition: sonar.cpp:48
Definition: audio.cpp:29
bool isInitialized() const
Definition: sonar.hpp:42
std::string topic() const
Definition: sonar.hpp:37
bool is_initialized_
Definition: sonar.hpp:63
SonarPublisher(const std::vector< std::string > &topics)
Definition: sonar.cpp:28
Definition: sonar.hpp:32
void publish(const std::vector< sensor_msgs::Range > &sonar_msgs)
Definition: sonar.cpp:34
std::vector< std::string > topics_
Definition: sonar.hpp:61