All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Sensor.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2012 Nate Koenig
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 /* Desc: Base class for all sensors
18  * Author: Nathan Koenig
19  * Date: 25 May 2007
20  */
21 
22 #ifndef _SENSOR_HH_
23 #define _SENSOR_HH_
24 
25 #include <boost/enable_shared_from_this.hpp>
26 #include <vector>
27 #include <string>
28 
29 #include "gazebo/sdf/sdf.hh"
30 
32 
33 #include "gazebo/msgs/msgs.hh"
34 #include "gazebo/common/Events.hh"
35 #include "gazebo/common/Time.hh"
36 #include "gazebo/math/Pose.hh"
38 
39 namespace gazebo
40 {
41  namespace sensors
42  {
45 
48  class Sensor : public boost::enable_shared_from_this<Sensor>
49  {
51  public: Sensor();
52 
54  public: virtual ~Sensor();
55 
59  public: virtual void Load(const std::string &_worldName,
60  sdf::ElementPtr _sdf);
61 
64  public: virtual void Load(const std::string &_worldName);
65 
67  public: virtual void Init();
68 
71  public: virtual void SetParent(const std::string &_name);
72 
76  public: std::string GetParentName() const;
77 
80  public: void Update(bool _force);
81 
87  protected: virtual void UpdateImpl(bool /*_force*/) {}
88 
91  public: void SetUpdateRate(double _hz);
92 
94  public: virtual void Fini();
95 
98  public: std::string GetName() const;
99 
102  public: std::string GetScopedName() const;
103 
106  public: virtual math::Pose GetPose() const;
107 
110  public: virtual void SetActive(bool _value);
111 
114  public: bool IsActive();
115 
118  public: std::string GetType() const;
119 
123 
127 
131  public: bool GetVisualize() const;
132 
135  public: virtual std::string GetTopic() const;
136 
139  public: void FillMsg(msgs::Sensor &_msg);
140 
143  public: std::string GetWorldName() const;
144 
147  private: void LoadPlugin(sdf::ElementPtr _sdf);
148 
151  private: void OnControl(ConstWorldControlPtr &_data);
152 
154  protected: bool active;
155 
157  protected: sdf::ElementPtr sdf;
158 
160  protected: math::Pose pose;
161 
163  protected: std::vector<event::ConnectionPtr> connections;
164 
167 
170 
172  private: transport::SubscriberPtr controlSub;
173 
175  private: transport::PublisherPtr sensorPub;
176 
178  protected: std::string parentName;
179 
181  protected: std::vector<SensorPluginPtr> plugins;
182 
185 
189 
192 
196  };
198  }
199 }
200 #endif