Gazebo Sensors
API Reference
9.2.0
insert_drive_file
Tutorials
library_books
Classes
toc
Namespaces
insert_drive_file
Files
launch
Gazebo Website
Index
List
Hierarchy
Members: All
Members: Functions
Members: Variables
Members: Typedefs
Members: Enumerations
Members: Enumerator
List
Members
Functions
Typedefs
Variables
Enumerations
Enumerator
src
gz-sensors
include
gz
sensors
Manager.hh
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2017 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 GZ_SENSORS_MANAGER_HH_
18
#define GZ_SENSORS_MANAGER_HH_
19
20
#include <chrono>
21
#include <memory>
22
#include <utility>
23
#include <type_traits>
24
#include <sdf/sdf.hh>
25
#include <gz/utils/SuppressWarning.hh>
26
#include <gz/common/Console.hh>
27
#include <gz/sensors/config.hh>
28
#include <gz/sensors/Export.hh>
29
#include <
gz/sensors/Sensor.hh
>
30
#include <
gz/sensors/SensorFactory.hh
>
31
32
namespace
gz
33
{
34
namespace
sensors
35
{
36
// Inline bracket to help doxygen filtering.
37
inline
namespace
GZ_SENSORS_VERSION_NAMESPACE {
38
// Forward declarations
39
class
ManagerPrivate;
40
52
class
GZ_SENSORS_VISIBLE
Manager
53
{
55
public
:
Manager
();
56
58
public
:
virtual
~Manager
();
59
62
public
:
bool
Init
();
63
72
public
:
template
<
typename
SensorType,
typename
SdfType>
73
SensorType *
CreateSensor
(SdfType _sdf)
74
{
75
SensorFactory
sensorFactory;
76
auto
sensor = sensorFactory.
CreateSensor
<SensorType>(_sdf);
77
if
(
nullptr
== sensor)
78
{
79
gzerr <<
"Failed to create sensor."
<<
std::endl
;
80
return
nullptr
;
81
}
82
auto
result = sensor.get();
83
if
(
NO_SENSOR
== this->AddSensor(
std::move
(sensor)))
84
{
85
gzerr <<
"Failed to add sensor."
<<
std::endl
;
86
return
nullptr
;
87
}
88
return
result;
89
}
90
91
97
public
:
SensorId
AddSensor
(
std::unique_ptr<Sensor>
_sensor);
98
102
public
:
gz::sensors::Sensor
*
Sensor
(
103
gz::sensors::SensorId
_id);
104
108
public
:
bool
Remove
(
const
gz::sensors::SensorId
_id);
109
114
public
:
void
RunOnce
(
const
std::chrono::steady_clock::duration &_time,
115
bool
_force =
false
);
116
117
GZ_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING
119
private
:
std::unique_ptr<ManagerPrivate>
dataPtr;
120
GZ_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING
121
};
122
}
123
}
124
}
125
126
#endif