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 #include "gazebo/util/system.hh"
29 
30 namespace gazebo
31 {
34  namespace sensors
35  {
38 
44  {
46  public: SonarSensor();
47 
49  public: virtual ~SonarSensor();
50 
51  // Documentation inherited
52  public: virtual void Load(const std::string &_worldName);
53 
54  // Documentation inherited
55  public: virtual void Init();
56 
57  // Documentation inherited
58  protected: virtual bool UpdateImpl(bool _force);
59 
60  // Documentation inherited
61  protected: virtual void Fini();
62 
63  // Documentation inherited
64  public: virtual std::string GetTopic() const;
65 
68  public: double GetRangeMin() const;
69 
72  public: double GetRangeMax() const;
73 
76  public: double GetRadius() const;
77 
86  public: double GetRange();
87 
88  // Documentation inherited
89  public: virtual bool IsActive();
90 
94  public: template<typename T>
96  {return update.Connect(_subscriber);}
97 
101  {update.Disconnect(_conn);}
102 
104  private: void OnContacts(ConstContactsPtr &_msg);
105 
107  private: physics::CollisionPtr sonarCollision;
108 
110  private: physics::MeshShapePtr sonarShape;
111 
113  private: physics::EntityPtr parentEntity;
114 
116  private: transport::SubscriberPtr contactSub;
117 
119  private: transport::PublisherPtr sonarPub;
120 
122  private: msgs::SonarStamped sonarMsg;
123 
125  private: boost::mutex mutex;
126 
128  typedef std::list<boost::shared_ptr<msgs::Contacts const> > ContactMsgs_L;
129 
131  private: ContactMsgs_L incomingContacts;
132 
134  private: math::Pose sonarMidPose;
135 
137  private: double rangeMin;
138 
140  private: double rangeMax;
141 
143  private: double radius;
144 
147  };
149  }
150 }
151 #endif