All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SonarSensor.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2014 Open Source Robotics Foundation
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 _SONARSENSOR_HH_
19 #define _SONARSENSOR_HH_
20 
21 #include <string>
22 #include <list>
23 
24 #include "gazebo/math/Angle.hh"
25 #include "gazebo/math/Pose.hh"
27 #include "gazebo/sensors/Sensor.hh"
28 
29 namespace gazebo
30 {
33  namespace sensors
34  {
37 
42  class SonarSensor: public Sensor
43  {
45  public: SonarSensor();
46 
48  public: virtual ~SonarSensor();
49 
50  // Documentation inherited
51  public: virtual void Load(const std::string &_worldName);
52 
53  // Documentation inherited
54  public: virtual void Init();
55 
56  // Documentation inherited
57  protected: virtual void UpdateImpl(bool _force);
58 
59  // Documentation inherited
60  protected: virtual void Fini();
61 
62  // Documentation inherited
63  public: virtual std::string GetTopic() const;
64 
67  public: double GetRangeMin() const;
68 
71  public: double GetRangeMax() const;
72 
75  public: double GetRadius() const;
76 
85  public: double GetRange();
86 
87  // Documentation inherited
88  public: virtual bool IsActive();
89 
93  public: template<typename T>
95  {return update.Connect(_subscriber);}
96 
100  {update.Disconnect(_conn);}
101 
103  private: void OnContacts(ConstContactsPtr &_msg);
104 
106  private: physics::CollisionPtr sonarCollision;
107 
109  private: physics::MeshShapePtr sonarShape;
110 
112  private: physics::EntityPtr parentEntity;
113 
115  private: transport::SubscriberPtr contactSub;
116 
118  private: transport::PublisherPtr sonarPub;
119 
121  private: msgs::SonarStamped sonarMsg;
122 
124  private: boost::mutex mutex;
125 
127  typedef std::list<boost::shared_ptr<msgs::Contacts const> > ContactMsgs_L;
128 
130  private: ContactMsgs_L incomingContacts;
131 
133  private: math::Pose sonarMidPose;
134 
136  private: double rangeMin;
137 
139  private: double rangeMax;
140 
142  private: double radius;
143 
146  };
148  }
149 }
150 #endif