JointControlWidget.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 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 GAZEBO_GUI_JOINTCONTROLWIDGET_HH_
18 #define GAZEBO_GUI_JOINTCONTROLWIDGET_HH_
19 
20 #include <functional>
21 #include <memory>
22 #include <string>
23 #include <ignition/msgs.hh>
24 #include <ignition/transport.hh>
25 #include "gazebo/gui/qt.h"
26 #include "gazebo/util/system.hh"
27 
28 namespace gazebo
29 {
30  namespace msgs
31  {
32  class Model;
33  }
34 
35  namespace gui
36  {
37  class JointControlWidgetPrivate;
38  class JointForceControl;
39  class JointForceControlPrivate;
40  class JointPIDPosControl;
41  class JointPIDPosControlPrivate;
42  class JointPIDVelControl;
43  class JointPIDVelControlPrivate;
44 
49  class GZ_GUI_VISIBLE JointControlWidget : public QWidget
50  {
51  Q_OBJECT
52 
55  public: explicit JointControlWidget(QWidget *_parent = 0);
56 
58  public: virtual ~JointControlWidget();
59 
62  public: void SetModelName(const std::string &_modelName);
63 
68  private: void ResponseCallback(const std::string &_modelName,
69  const ignition::msgs::JointCmd &_rep, const bool _result);
70 
74  private slots: void OnResponse(const std::string &_modelName,
75  const ignition::msgs::JointCmd &_rep);
76 
80  Q_SIGNALS: void repReceived(const std::string &_modelName,
81  const ignition::msgs::JointCmd &_rep);
82 
84  private slots: void OnReset();
85 
89  private slots: void OnForceChanged(double _value,
90  const std::string &_name);
91 
95  private slots: void OnPIDPosChanged(double _value,
96  const std::string &_name);
97 
101  private slots: void OnPPosGainChanged(double _value,
102  const std::string &_name);
103 
107  private slots: void OnDPosGainChanged(double _value,
108  const std::string &_name);
109 
113  private slots: void OnIPosGainChanged(double _value,
114  const std::string &_name);
115 
119  private slots: void OnPIDVelChanged(double _value,
120  const std::string &_name);
121 
125  private slots: void OnPVelGainChanged(double _value,
126  const std::string &_name);
127 
131  private slots: void OnDVelGainChanged(double _value,
132  const std::string &_name);
133 
137  private slots: void OnIVelGainChanged(double _value,
138  const std::string &_name);
139 
142  private slots: void OnPIDPosUnitsChanged(int _index);
143 
148  private: void AddScrollTab(QTabWidget *_tabPane,
149  QGridLayout *_tabLayout,
150  const QString &_name);
151 
154  private: void LayoutForceTab(msgs::Model &_modelMsg);
155 
158  private: void LayoutPositionTab(msgs::Model &_modelMsg);
159 
162  private: void LayoutVelocityTab(msgs::Model &_modelMsg);
163 
166  private: std::unique_ptr<JointControlWidgetPrivate> dataPtr;
167  };
168 
171  class GZ_GUI_VISIBLE JointForceControl : public QWidget
172  {
173  Q_OBJECT
174 
180  public: JointForceControl(const std::string &_name,
181  QGridLayout *_layout, QWidget *_parent, int _index);
182 
184  public: virtual ~JointForceControl();
185 
187  public: void Reset();
188 
191  public: void SetForce(const double _force);
192 
195  public: void SetShowActive(const bool _active);
196 
199  public slots: void OnChanged(double _value);
200 
205  Q_SIGNALS: void changed(double _value, const std::string &_name);
206 
209  private: std::unique_ptr<JointForceControlPrivate> dataPtr;
210  };
211 
215  class GZ_GUI_VISIBLE JointPIDPosControl : public QWidget
216  {
217  Q_OBJECT
218 
224  public: JointPIDPosControl(const std::string &_name,
225  QGridLayout *_layout, QWidget *_parent, int _index);
226 
228  public: virtual ~JointPIDPosControl();
229 
231  public: void Reset();
232 
235  public: void SetPositionTarget(const double _target);
236 
239  public: void SetPGain(const double _pGain);
240 
243  public: void SetIGain(const double _iGain);
244 
247  public: void SetDGain(const double _dGain);
248 
251  public: void SetShowActive(const bool _active);
252 
254  public: void SetToRadians();
255 
257  public: void SetToDegrees();
258 
261  public slots: void OnChanged(double _value);
262 
265  public slots: void OnPChanged(double _value);
266 
269  public slots: void OnIChanged(double _value);
270 
273  public slots: void OnDChanged(double _value);
274 
279  Q_SIGNALS: void changed(double _value, const std::string &_name);
280 
285  Q_SIGNALS: void pChanged(double _value, const std::string &_name);
286 
291  Q_SIGNALS: void dChanged(double _value, const std::string &_name);
292 
297  Q_SIGNALS: void iChanged(double _value, const std::string &_name);
298 
301  private: std::unique_ptr<JointPIDPosControlPrivate> dataPtr;
302  };
303 
307  class GZ_GUI_VISIBLE JointPIDVelControl : public QWidget
308  {
309  Q_OBJECT
310 
316  public: JointPIDVelControl(const std::string &_name,
317  QGridLayout *_layout, QWidget *_parent, int _index);
318 
320  public: virtual ~JointPIDVelControl();
321 
323  public: void Reset();
324 
327  public: void SetVelocityTarget(const double _target);
328 
331  public: void SetPGain(const double _pGain);
332 
335  public: void SetIGain(const double _iGain);
336 
339  public: void SetDGain(const double _dGain);
340 
343  public: void SetShowActive(const bool _active);
344 
347  public slots: void OnChanged(double _value);
348 
351  public slots: void OnPChanged(double _value);
352 
355  public slots: void OnIChanged(double _value);
356 
359  public slots: void OnDChanged(double _value);
360 
365  Q_SIGNALS: void changed(double _value, const std::string &_name);
366 
371  Q_SIGNALS: void pChanged(double _value, const std::string &_name);
372 
377  Q_SIGNALS: void dChanged(double _value, const std::string &_name);
378 
383  Q_SIGNALS: void iChanged(double _value, const std::string &_name);
384 
387  private: std::unique_ptr<JointPIDVelControlPrivate> dataPtr;
388  };
389  }
390 }
391 #endif
Widget to control joints via application of position PID controller.
Definition: JointControlWidget.hh:215
Widget to control joints via application of a velocity PID controller.
Definition: JointControlWidget.hh:307
Widget to control joints via application of force.
Definition: JointControlWidget.hh:171
gui/JointControlWidget.hh
Definition: JointControlWidget.hh:49