SonarSensor.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2015 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 #ifndef _GAZEBO_SONARSENSOR_HH_
18 #define _GAZEBO_SONARSENSOR_HH_
19 
20 #include <string>
21 #include <list>
22 #include <ignition/math/Pose3.hh>
23 
25 #include "gazebo/sensors/Sensor.hh"
26 #include "gazebo/util/system.hh"
27 
28 namespace gazebo
29 {
32  namespace sensors
33  {
36 
42  {
44  public: SonarSensor();
45 
47  public: virtual ~SonarSensor();
48 
49  // Documentation inherited
50  public: virtual void Load(const std::string &_worldName);
51 
52  // Documentation inherited
53  public: virtual void Init();
54 
55  // Documentation inherited
56  protected: virtual bool UpdateImpl(bool _force);
57 
58  // Documentation inherited
59  protected: virtual void Fini();
60 
61  // Documentation inherited
62  public: virtual std::string GetTopic() const;
63 
66  public: double GetRangeMin() const;
67 
70  public: double GetRangeMax() const;
71 
74  public: double GetRadius() const;
75 
84  public: double GetRange();
85 
86  // Documentation inherited
87  public: virtual bool IsActive();
88 
92  public: template<typename T>
94  {return update.Connect(_subscriber);}
95 
99  {update.Disconnect(_conn);}
100 
102  private: void OnContacts(ConstContactsPtr &_msg);
103 
105  private: physics::CollisionPtr sonarCollision;
106 
108  private: physics::MeshShapePtr sonarShape;
109 
111  private: physics::EntityPtr parentEntity;
112 
114  private: transport::SubscriberPtr contactSub;
115 
117  private: transport::PublisherPtr sonarPub;
118 
120  private: msgs::SonarStamped sonarMsg;
121 
123  private: boost::mutex mutex;
124 
126  typedef std::list<boost::shared_ptr<msgs::Contacts const> > ContactMsgs_L;
127 
129  private: ContactMsgs_L incomingContacts;
130 
132  private: ignition::math::Pose3d sonarMidPose;
133 
135  private: double rangeMin;
136 
138  private: double rangeMax;
139 
141  private: double radius;
142 
145  };
147  }
148 }
149 #endif
boost::shared_ptr< Connection > ConnectionPtr
Definition: CommonTypes.hh:147
Sensor with sonar cone.
Definition: SonarSensor.hh:41
void DisconnectUpdate(event::ConnectionPtr &_conn)
Disconnect from the update signal.
Definition: SonarSensor.hh:98
boost::shared_ptr< Subscriber > SubscriberPtr
Definition: TransportTypes.hh:53
Forward declarations for transport.
event::EventT< void(msgs::SonarStamped)> update
Update event.
Definition: SonarSensor.hh:144
boost::shared_ptr< Collision > CollisionPtr
Definition: PhysicsTypes.hh:96
boost::shared_ptr< Entity > EntityPtr
Definition: PhysicsTypes.hh:76
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
boost::shared_ptr< MeshShape > MeshShapePtr
Definition: PhysicsTypes.hh:160
boost::shared_ptr< Publisher > PublisherPtr
Definition: TransportTypes.hh:49
Base class for sensors.
Definition: Sensor.hh:69
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:66
event::ConnectionPtr ConnectUpdate(T _subscriber)
Connect a to the new update signal.
Definition: SonarSensor.hh:93