Gazebo Sim

API Reference

7.9.0
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 
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 
54 {
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(
76  const UpdateInfo &_info);
77 
79  public: void FileReloaded();
80 
88  public: void Step(
89  const UpdateInfo &_info,
90  const EntityComponentManager &_ecm,
92  unsigned int _xSamples, unsigned int _ySamples, unsigned int _zSamples);
93 
99  private: void Visualize(
101  unsigned int _xSamples, unsigned int _ySamples, unsigned int _zSamples);
102 
104  private: void Publish();
105 
113  private: void ResizeCloud(
115  const EntityComponentManager &_ecm,
116  unsigned int _xSamples, unsigned int _ySamples, unsigned int _zSamples);
117 
119  private: transport::Node::Publisher pcPub;
120 
123 
126 
128  private: transport::Node node;
129 
131  private: gz::msgs::PointCloudPacked pcMsg;
132 
136 
139 };
140 }
141 }
142 }
143 #endif