All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
JointControlWidget.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2014 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 _JOINT_CONTROL_WIDGET_HH_
18 #define _JOINT_CONTROL_WIDGET_HH_
19 
20 #include <string>
21 #include <map>
22 #include "gazebo/msgs/msgs.hh"
23 #include "gazebo/gui/qt.h"
25 #include "gazebo/util/system.hh"
26 
27 namespace gazebo
28 {
29  namespace gui
30  {
31  class JointForceControl;
32  class JointPIDPosControl;
33  class JointPIDVelControl;
34 
39  class GAZEBO_VISIBLE JointControlWidget : public QWidget
40  {
41  Q_OBJECT
42 
45  public: JointControlWidget(QWidget *_parent = 0);
46 
48  public: virtual ~JointControlWidget();
49 
52  public: void SetModelName(const std::string &_modelName);
53 
55  private slots: void OnReset();
56 
60  private slots: void OnForceChanged(double _value,
61  const std::string &_name);
62 
66  private slots: void OnPIDPosChanged(double _value,
67  const std::string &_name);
68 
72  private slots: void OnPPosGainChanged(double _value,
73  const std::string &_name);
74 
78  private slots: void OnDPosGainChanged(double _value,
79  const std::string &_name);
80 
84  private slots: void OnIPosGainChanged(double _value,
85  const std::string &_name);
86 
90  private slots: void OnPIDVelChanged(double _value,
91  const std::string &_name);
92 
96  private slots: void OnPVelGainChanged(double _value,
97  const std::string &_name);
98 
102  private slots: void OnDVelGainChanged(double _value,
103  const std::string &_name);
104 
108  private slots: void OnIVelGainChanged(double _value,
109  const std::string &_name);
110 
113  private slots: void OnPIDPosUnitsChanged(int _index);
114 
119  private: void AddScrollTab(QTabWidget *_tabPane,
120  QGridLayout *_tabLayout,
121  const QString &_name);
122 
125  private: void LayoutForceTab(msgs::Model &_modelMsg);
126 
129  private: void LayoutPositionTab(msgs::Model &_modelMsg);
130 
133  private: void LayoutVelocityTab(msgs::Model &_modelMsg);
134 
136  private: transport::NodePtr node;
137 
139  private: transport::PublisherPtr jointPub;
140 
142  private: std::map<std::string, JointForceControl*> sliders;
143 
145  private: std::map<std::string, JointPIDPosControl*> pidPosSliders;
146 
148  private: std::map<std::string, JointPIDVelControl*> pidVelSliders;
149 
151  private: QLabel *modelLabel;
152 
154  private: QTabWidget *tabWidget;
155 
157  private: QGridLayout *forceGridLayout;
158 
160  private: QGridLayout *positionGridLayout;
161 
163  private: QGridLayout *velocityGridLayout;
164  };
165 
168  class GAZEBO_VISIBLE JointForceControl : public QWidget
169  {
170  Q_OBJECT
171 
177  public: JointForceControl(const std::string &_name,
178  QGridLayout *_layout, QWidget *_parent, int _index);
179 
181  public: virtual ~JointForceControl();
182 
184  public: void Reset();
185 
188  public slots: void OnChanged(double _value);
189 
194  Q_SIGNALS: void changed(double _value, const std::string &_name);
195 
197  private: std::string name;
198 
200  private: QDoubleSpinBox *forceSpin;
201  };
202 
206  class GAZEBO_VISIBLE JointPIDPosControl : public QWidget
207  {
208  Q_OBJECT
209 
215  public: JointPIDPosControl(const std::string &_name,
216  QGridLayout *_layout, QWidget *_parent, int _index);
217 
219  public: void Reset();
220 
222  public: void SetToRadians();
223 
225  public: void SetToDegrees();
226 
229  public slots: void OnChanged(double _value);
230 
233  public slots: void OnPChanged(double _value);
234 
237  public slots: void OnIChanged(double _value);
238 
241  public slots: void OnDChanged(double _value);
242 
247  Q_SIGNALS: void changed(double _value, const std::string &_name);
248 
253  Q_SIGNALS: void pChanged(double _value, const std::string &_name);
254 
259  Q_SIGNALS: void dChanged(double _value, const std::string &_name);
260 
265  Q_SIGNALS: void iChanged(double _value, const std::string &_name);
266 
268  private: QDoubleSpinBox *posSpin, *pGainSpin, *iGainSpin, *dGainSpin;
269 
271  private: std::string name;
272 
274  private: bool radians;
275  };
276 
280  class GAZEBO_VISIBLE JointPIDVelControl : public QWidget
281  {
282  Q_OBJECT
283 
289  public: JointPIDVelControl(const std::string &_name,
290  QGridLayout *_layout, QWidget *_parent, int _index);
291 
293  public: void Reset();
294 
297  public slots: void OnChanged(double _value);
298 
301  public slots: void OnPChanged(double _value);
302 
305  public slots: void OnIChanged(double _value);
306 
309  public slots: void OnDChanged(double _value);
310 
315  Q_SIGNALS: void changed(double _value, const std::string &_name);
316 
321  Q_SIGNALS: void pChanged(double _value, const std::string &_name);
322 
327  Q_SIGNALS: void dChanged(double _value, const std::string &_name);
328 
333  Q_SIGNALS: void iChanged(double _value, const std::string &_name);
334 
336  private: QDoubleSpinBox *posSpin, *pGainSpin, *iGainSpin, *dGainSpin;
337 
339  private: std::string name;
340  };
341  }
342 }
343 #endif
Widget to control joints via application of position PID controller.
Definition: JointControlWidget.hh:206
Widget to control joints via application of a velocity PID controller.
Definition: JointControlWidget.hh:280
Forward declarations for transport.
boost::shared_ptr< Node > NodePtr
Definition: TransportTypes.hh:52
Widget to control joints via application of force.
Definition: JointControlWidget.hh:168
boost::shared_ptr< Publisher > PublisherPtr
Definition: TransportTypes.hh:44
gui/JointControlWidget.hh
Definition: JointControlWidget.hh:39
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:48