Gazebo Gazebo

API Reference

6.16.0
Pose3d.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_GAZEBO_GUI_COMPONENTINSPECTOR_POSE3D_HH_
18 #define GZ_GAZEBO_GUI_COMPONENTINSPECTOR_POSE3D_HH_
19 
20 #include <gz/math/Pose3.hh>
21 
25 
26 #include "ComponentInspector.hh"
27 #include "Types.hh"
28 
29 #include <QObject>
30 #include <QStandardItem>
31 
32 namespace ignition
33 {
34 namespace gazebo
35 {
36 class ComponentInspector;
37 namespace inspector
38 {
43  class Pose3d : public QObject
44  {
45  Q_OBJECT
46 
49  public: explicit Pose3d(ComponentInspector *_inspector);
50 
55  public:
56  template<typename ComponentType>
58  QStandardItem *_item)
59  {
60  if (nullptr == _item)
61  return;
62 
63  auto comp = _ecm.Component<ComponentType>(this->inspector->GetEntity());
64  if (nullptr == comp)
65  return;
66 
67  auto pose = comp->Data();
68 
69  _item->setData(QString("Pose3d"),
70  ComponentsModel::RoleNames().key("dataType"));
71  _item->setData(QList({
72  QVariant(pose.Pos().X()),
73  QVariant(pose.Pos().Y()),
74  QVariant(pose.Pos().Z()),
75  QVariant(pose.Rot().Roll()),
76  QVariant(pose.Rot().Pitch()),
77  QVariant(pose.Rot().Yaw())
78  }), ComponentsModel::RoleNames().key("data"));
79  }
80 
88  public: Q_INVOKABLE void OnPose(double _x, double _y, double _z,
89  double _roll, double _pitch, double _yaw);
90 
93  private: ComponentInspector *inspector{nullptr};
94  };
95 }
96 }
97 }
98 #endif
Pose3d(ComponentInspector *_inspector)
Constructor.
This library is part of the Gazebo project.
The EntityComponentManager constructs, deletes, and returns components and entities....
Definition: gz/sim/EntityComponentManager.hh:66
void UpdateView(const EntityComponentManager &_ecm, QStandardItem *_item)
Callback when there are ECM updates.
Definition: Pose3d.hh:57
const ComponentTypeT * Component(const Entity _entity) const
Get a component assigned to an entity based on a component type.
Q_INVOKABLE void OnPose(double _x, double _y, double _z, double _roll, double _pitch, double _yaw)
Callback in Qt thread when pose changes.
Handles components that are displayed as a 3D pose:
Definition: Pose3d.hh:43