Gazebo Sim

API Reference

8.7.0
gui/plugins/joint_position_controller/JointPositionController.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 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_JOINTPOSITIONCONTROLLER_HH_
19 #define GZ_SIM_GUI_JOINTPOSITIONCONTROLLER_HH_
20 
21 #include <map>
22 #include <memory>
23 #include <string>
24 
25 #include <gz/sim/gui/GuiSystem.hh>
26 #include <gz/sim/Types.hh>
27 
29 
30 namespace gz
31 {
32 namespace sim
33 {
34 namespace gui
35 {
36  class JointPositionControllerPrivate;
37 
39  class JointsModel : public QStandardItemModel
40  {
41  Q_OBJECT
42 
44  public: explicit JointsModel();
45 
47  public: ~JointsModel() override = default;
48 
49  // Documentation inherited
50  public: QHash<int, QByteArray> roleNames() const override;
51 
54  public: static QHash<int, QByteArray> RoleNames();
55 
59  public slots: QStandardItem *AddJoint(Entity _entity);
60 
63  public slots: void RemoveJoint(Entity _entity);
64 
66  public slots: void Clear();
67 
70  };
71 
91  class JointPositionController : public sim::GuiSystem
92  {
93  Q_OBJECT
94 
96  Q_PROPERTY(
97  Entity modelEntity
98  READ ModelEntity
99  WRITE SetModelEntity
100  NOTIFY ModelEntityChanged
101  )
102 
103 
104  Q_PROPERTY(
105  QString modelName
106  READ ModelName
107  WRITE SetModelName
108  NOTIFY ModelNameChanged
109  )
110 
111 
112  Q_PROPERTY(
113  bool locked
114  READ Locked
115  WRITE SetLocked
116  NOTIFY LockedChanged
117  )
118 
119 
120  public: JointPositionController();
121 
123  public: ~JointPositionController() override;
124 
125  // Documentation inherited
126  public: void LoadConfig(const tinyxml2::XMLElement *_pluginElem) override;
127 
128  // Documentation inherited
129  public: void Update(const UpdateInfo &, EntityComponentManager &) override;
130 
134  public: Q_INVOKABLE void OnCommand(const QString &_jointName, double _pos);
135 
137  public: Q_INVOKABLE void OnReset();
138 
141  public: Q_INVOKABLE Entity ModelEntity() const;
142 
145  public: Q_INVOKABLE void SetModelEntity(Entity _entity);
146 
148  signals: void ModelEntityChanged();
149 
152  public: Q_INVOKABLE QString ModelName() const;
153 
156  public: Q_INVOKABLE void SetModelName(const QString &_name);
157 
159  signals: void ModelNameChanged();
160 
163  public: Q_INVOKABLE bool Locked() const;
164 
167  public: Q_INVOKABLE void SetLocked(bool _locked);
168 
170  signals: void LockedChanged();
171 
172  // Documentation inherited
173  protected: bool eventFilter(QObject *_obj, QEvent *_event) override;
174 
178  };
179 }
180 }
181 }
182 
183 #endif