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 "sdf/sdf.hh"
30 
31 #include "physics/PhysicsTypes.hh"
32 
33 #include "msgs/msgs.hh"
34 #include "common/Events.hh"
35 #include "common/Time.hh"
36 #include "math/Pose.hh"
39 namespace gazebo
40 {
43  namespace sensors
44  {
49  class Sensor : public boost::enable_shared_from_this<Sensor>
50  {
52  public: Sensor();
53 
55  public: virtual ~Sensor();
56 
60  public: virtual void Load(const std::string &_worldName,
61  sdf::ElementPtr _sdf);
62 
65  public: virtual void Load(const std::string &_worldName);
66 
68  public: virtual void Init();
69 
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  public: bool GetVisualize() const;
128 
131  public: virtual std::string GetTopic() const;
132 
135  public: void FillMsg(msgs::Sensor &_msg);
136 
139  public: std::string GetWorldName() const;
140 
143  private: void LoadPlugin(sdf::ElementPtr _sdf);
144 
147  private: void OnControl(ConstWorldControlPtr &_data);
148 
150  protected: bool active;
151  protected: sdf::ElementPtr sdf;
152  protected: math::Pose pose;
153  protected: std::vector<event::ConnectionPtr> connections;
156  private: transport::SubscriberPtr controlSub;
157  private: transport::PublisherPtr sensorPub;
158 
159  protected: std::string parentName;
160  protected: std::vector<SensorPluginPtr> plugins;
161 
165  };
167  }
168 }
169 #endif