Gazebo Sim

API Reference

8.11.0
VisualizeFrustum.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2025 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 
18 #ifndef GZ_SIM_GUI_VISUALIZEFRUSTUM_HH_
19 #define GZ_SIM_GUI_VISUALIZEFRUSTUM_HH_
20 
21 #include <memory>
22 #include <string>
23 
24 #include "gz/msgs/camera_info.pb.h"
25 #include "gz/msgs/header.pb.h"
26 #include "gz/msgs/logical_camera_sensor.pb.h"
27 #include "gz/sim/gui/GuiSystem.hh"
28 #include "gz/gui/qt.h"
29 
30 namespace gz
31 {
32 namespace sim
33 {
34 // Inline bracket to help doxygen filtering.
35 inline namespace GZ_SIM_VERSION_NAMESPACE
36 {
37  class VisualizeFrustumPrivate;
38 
41  {
42  Q_OBJECT
43 
45  Q_PROPERTY(
46  QStringList topicList
47  READ TopicList
48  WRITE SetTopicList
49  NOTIFY TopicListChanged
50  )
51 
52 
53  public: struct FrustumData
54  {
56  double nearClip{0.1};
57 
59  double farClip{10.0};
60 
62  double horizontalFov{1.0471975512};
63 
65  double aspectRatio{1.3333333333};
66 
69 
71  bool valid{false};
72  };
73 
75  public: VisualizeFrustum();
76 
78  public: ~VisualizeFrustum() override;
79 
80  // Documentation inherited
81  public: void LoadConfig(const tinyxml2::XMLElement *_pluginElem) override;
82 
83  // Documentation inherited
84  public: bool eventFilter(QObject *_obj, QEvent *_event) override;
85 
86  // Documentation inherited
87  public: void Update(const UpdateInfo &,
88  EntityComponentManager &_ecm) override;
89 
92  public: void OnScan(const msgs::LogicalCameraSensor &_msg);
93 
96  public: void OnCameraInfo(const msgs::CameraInfo &_msg);
97 
99  public: void LoadFrustum();
100 
103  public: Q_INVOKABLE QStringList TopicList() const;
104 
107  public: Q_INVOKABLE void SetTopicList(const QStringList &_topicList);
108 
110  signals: void TopicListChanged();
111 
114  public: Q_INVOKABLE void OnTopic(const QString &_topicName);
115 
118  public: Q_INVOKABLE void DisplayVisual(bool _value);
119 
121  public: Q_INVOKABLE void OnRefresh();
122 
126  private: std::string FrameIdFromHeader(const msgs::Header &_header) const;
127 
132  private: bool FrustumDataFromLogicalCamera(
133  const msgs::LogicalCameraSensor &_msg,
134  FrustumData &_data) const;
135 
140  private: bool FrustumDataFromCameraInfo(
141  const msgs::CameraInfo &_msg,
142  FrustumData &_data) const;
143 
146  private: void ApplyFrustumData(const FrustumData &_data);
147 
151  };
152 }
153 }
154 }
155 #endif