NimbRo ROS Soccer Package
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
pidview.h
1 #ifndef PIDVIEW_H
2 #define PIDVIEW_H
3 
4 // Widget to edit PID of certain joint
5 // Author: Dmytro Pavlichenko <dm.mark999@gmail.com>
6 
7 #include <QSpinBox>
8 #include <QRadioButton>
9 
10 #include <trajectory_editor/historykeeper.h>
11 #include <trajectory_editor/spaces/basicsmallview.h>
12 
13 #include <motion_file/motionfile.h>
14 
15 class PIDView : public BasicSmallView
16 {
17  Q_OBJECT
18 public:
19 
20  enum Field
21  {
22  P_VALUE,
23  I_VALUE,
24  D_VALUE,
25 
26  LIMIT,
27  PID_FLAG
28  };
29 
30  PIDView(BasicSmallView::Alignment alignment, BasicSmallView::Type type, std::string jointName, bool shiftMirrored, QWidget *parent = 0);
31  ~PIDView();
32 
33  void setField(PIDView::Field field, double value);
34  double getPGain();
35  double getIGain();
36  double getDGain();
37  double getLimit();
38  kf_player::gainSelectEnum getFlag();
39 
40  void clearHistoryOfChanges();
41 
42 Q_SIGNALS:
43  void fieldChanged(PIDView::Field);
44 
45 private Q_SLOTS:
46  void p_SpinChanged();
47  void i_SpinChanged();
48  void d_SpinChanged();
49 
50  void limitSpinChanged();
51 
52  void p_RadioChanged();
53  void i_RadioChanged();
54  void d_RadioChanged();
55 
56 private:
57  void blockRadioButtons(bool block);
58  void updateBackgroundColor(QDoubleSpinBox *spin, float boundary);
59 
60 private:
61  QDoubleSpinBox *p_Spin;
62  QDoubleSpinBox *i_Spin;
63  QDoubleSpinBox *d_Spin;
64 
65  QDoubleSpinBox *limit_Spin;
66 
67  QRadioButton *p_Radio;
68  QRadioButton *i_Radio;
69  QRadioButton *d_Radio;
70 
71  HistoryKeeper *p_History;
72  HistoryKeeper *i_History;
73  HistoryKeeper *d_History;
74 
75  // Boundary for PID gains after what the value is considered as "large" and is colored accordingly
76  static const float p_ColorBoundary = 0.4;
77  static const float i_ColorBoundary = 0.15;
78  static const float d_ColorBoundary = 0.15;
79 
80  // StyleSheets which corespond to: zero value, value < boundaty, value >= boundary
81  QString zero_sheet;
82  QString medium_sheet;
83  QString large_sheet;
84 };
85 
86 #endif // PIDVIEW_H