Gazebo Sim
API Reference
8.7.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-sim
src
systems
environment_preload
VisualizationTool.hh
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2022 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_SIM_SYSTEMS_ENVIRONMENTPRELOAD_VIZTOOL_HH_
18
#define GZ_SIM_SYSTEMS_ENVIRONMENTPRELOAD_VIZTOOL_HH_
19
20
#include <atomic>
21
#include <memory>
22
#include <mutex>
23
#include <string>
24
#include <unordered_map>
25
#include <utility>
26
#include <vector>
27
28
#include <
gz/common/CSVStreams.hh
>
29
#include <
gz/common/DataFrame.hh
>
30
31
#include <
gz/transport/Node.hh
>
32
33
#include <gz/msgs/float_v.pb.h>
34
#include <gz/msgs/pointcloud_packed.pb.h>
35
#include <
gz/msgs/PointCloudPackedUtils.hh
>
36
#include <
gz/msgs/Utility.hh
>
37
38
#include "
gz/sim/components/Environment.hh
"
39
#include "
gz/sim/Util.hh
"
40
41
using namespace
gz
;
42
using namespace
sim;
43
44
namespace
gz
45
{
46
namespace
sim
47
{
48
inline
namespace
GZ_SIM_VERSION_NAMESPACE
49
{
50
53
class
EnvironmentVisualizationTool
54
{
56
public
:
EnvironmentVisualizationTool
();
57
59
private
:
std::mutex
mutex;
60
62
private
:
bool
first{
true
};
63
65
public
:
std::atomic<bool>
resample{
true
};
66
68
private
:
bool
finishedTime{
false
};
69
74
private
:
void
CreatePointCloudTopics(
75
const
std::shared_ptr<components::EnvironmentalData>
&_data,
76
const
UpdateInfo
&_info);
77
79
public
:
void
FileReloaded
();
80
88
public
:
void
Step
(
89
const
UpdateInfo
&_info,
90
const
EntityComponentManager
&_ecm,
91
const
std::shared_ptr<components::EnvironmentalData>
&_data,
92
unsigned
int
_xSamples,
unsigned
int
_ySamples,
unsigned
int
_zSamples);
93
99
private
:
void
Visualize(
100
const
std::shared_ptr<components::EnvironmentalData>
&_data,
101
unsigned
int
_xSamples,
unsigned
int
_ySamples,
unsigned
int
_zSamples);
102
104
private
:
void
Publish();
105
113
private
:
void
ResizeCloud(
114
const
std::shared_ptr<components::EnvironmentalData>
&_data,
115
const
EntityComponentManager
&_ecm,
116
unsigned
int
_xSamples,
unsigned
int
_ySamples,
unsigned
int
_zSamples);
117
119
private
:
transport::Node::Publisher
pcPub;
120
122
private
:
std::unordered_map<std::string, transport::Node::Publisher>
pubs;
123
125
private
:
std::unordered_map<std::string, gz::msgs::Float_V>
floatFields;
126
128
private
:
transport::Node
node;
129
131
private
: gz::msgs::PointCloudPacked pcMsg;
132
134
private
:
std::unordered_map
<
std::string
,
135
gz::math::InMemorySession<double, double>
> sessions;
136
138
private
:
std::chrono::time_point<std::chrono::steady_clock>
lastTick;
139
};
140
}
141
}
142
}
143
#endif