Class
List
Hierarchy
Modules
Common
Events
Math
Messages
Physics
Rendering
Sensors
Transport
Links
Gazebo Website
Wiki
Tutorials
Download
Report Documentation Issues
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
gazebo
sensors
Sensor.hh
Go to the documentation of this file.
1
/*
2
* Copyright 2012 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
/* 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
31
#include "
gazebo/physics/PhysicsTypes.hh
"
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
"
37
#include "
gazebo/transport/TransportTypes.hh
"
38
39
namespace
gazebo
40
{
41
namespace
sensors
42
{
45
enum
SensorCategory
46
{
47
// IMAGE must be the first element, and it must start with 0. Do not
48
// change this! See SensorManager::sensorContainers for reference.
51
IMAGE
= 0,
52
54
RAY
= 1,
55
57
OTHER
= 2,
58
60
CATEGORY_COUNT
= 3
61
};
62
65
68
class
Sensor
:
public
boost::enable_shared_from_this<Sensor>
69
{
72
public
:
explicit
Sensor
(
SensorCategory
_cat);
73
75
public
:
virtual
~Sensor
();
76
80
public
:
virtual
void
Load
(
const
std::string &_worldName,
81
sdf::ElementPtr
_sdf);
82
85
public
:
virtual
void
Load
(
const
std::string &_worldName);
86
88
public
:
virtual
void
Init
();
89
92
public
:
virtual
void
SetParent
(
const
std::string &_name);
93
97
public
: std::string
GetParentName
()
const
;
98
101
public
:
void
Update
(
bool
_force);
102
108
protected
:
virtual
void
UpdateImpl
(
bool
/*_force*/
) {}
109
112
public
:
double
GetUpdateRate
();
113
116
public
:
void
SetUpdateRate
(
double
_hz);
117
119
public
:
virtual
void
Fini
();
120
123
public
: std::string
GetName
()
const
;
124
127
public
: std::string
GetScopedName
()
const
;
128
131
public
:
virtual
math::Pose
GetPose
()
const
;
132
135
public
:
virtual
void
SetActive
(
bool
_value);
136
139
public
:
virtual
bool
IsActive
();
140
143
public
: std::string
GetType
()
const
;
144
147
public
:
common::Time
GetLastUpdateTime
();
148
151
public
:
common::Time
GetLastMeasurementTime
();
152
156
public
:
bool
GetVisualize
()
const
;
157
160
public
:
virtual
std::string
GetTopic
()
const
;
161
164
public
:
void
FillMsg
(msgs::Sensor &_msg);
165
168
public
: std::string
GetWorldName
()
const
;
169
175
public
:
template
<
typename
T>
176
event::ConnectionPtr
ConnectUpdated
(T _subscriber)
177
{
return
this->updated.
Connect
(_subscriber);}
178
182
public
:
void
DisconnectUpdated
(
event::ConnectionPtr
&_c)
183
{this->updated.
Disconnect
(_c);}
184
188
public
:
SensorCategory
GetCategory
()
const
;
189
191
public
:
void
ResetLastUpdateTime
();
192
195
private
:
void
LoadPlugin(
sdf::ElementPtr
_sdf);
196
198
protected
:
bool
active
;
199
201
protected
:
sdf::ElementPtr
sdf
;
202
204
protected
:
math::Pose
pose
;
205
207
protected
: std::vector<event::ConnectionPtr>
connections
;
208
210
protected
:
transport::NodePtr
node
;
211
213
protected
:
transport::SubscriberPtr
poseSub
;
214
216
protected
: std::string
parentName
;
217
219
protected
: std::vector<SensorPluginPtr>
plugins
;
220
222
protected
:
gazebo::physics::WorldPtr
world
;
223
226
protected
:
common::Time
updatePeriod
;
227
229
protected
:
common::Time
lastUpdateTime
;
230
233
protected
:
common::Time
lastMeasurementTime
;
234
236
private
:
event::EventT<void()>
updated;
237
239
private
:
transport::SubscriberPtr
controlSub;
240
242
private
:
transport::PublisherPtr
sensorPub;
243
245
private
:
SensorCategory
category;
246
};
248
}
249
}
250
#endif