cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mtsPIDQtWidget.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
3 
4 /*
5  Author(s): Zihan Chen, Anton Deguet
6  Created on: 2013-02-20
7 
8  (C) Copyright 2013-2014 Johns Hopkins University (JHU), All Rights Reserved.
9 
10 --- begin cisst license - do not edit ---
11 
12 This software is provided "as is" under an open source license, with
13 no warranty. The complete license can be found in license.txt and
14 http://www.cisst.org/cisst/license.txt.
15 
16 --- end cisst license ---
17 */
18 
19 
20 #ifndef _mtsPIDQtWidget_h
21 #define _mtsPIDQtWidget_h
22 
23 #include <cisstCommon/cmnXMLPath.h>
24 #include <cisstCommon/cmnUnits.h>
30 
31 #include <QCheckBox>
32 #include <QSpinBox>
33 #include <QPushButton>
35 
36 class CISST_EXPORT mtsPIDQtWidget: public QWidget, public mtsComponent
37 {
38  Q_OBJECT;
40 
41 public:
42  mtsPIDQtWidget(const std::string & componentName, unsigned int numberOfAxis,
43  double periodInSeconds = 50.0 * cmn_ms);
46 
47  void Configure(const std::string & filename = "");
48  void Startup(void);
49  void Cleanup(void);
50 
51 protected:
52  void Init(void);
53  virtual void closeEvent(QCloseEvent * event);
54 
55 signals:
56  void SignalEnablePID(bool enable);
57 
58 private slots:
60  void SlotEnablePID(bool toggle);
61  void SlotEnableTorqueMode(bool toggle);
63  void SlotPositionChanged(void);
64  void SlotPGainChanged(void);
65  void SlotDGainChanged(void);
66  void SlotIGainChanged(void);
68  void SlotMaintainPosition(void);
70  void SlotZeroPosition(void);
72  void SlotResetPIDGain(void);
74  void SlotPlotIndex(int newAxis);
76  void SlotEnableEventHandler(bool enable);
77  void SlotEnableDirectControl(bool toggle);
78 
80  void timerEvent(QTimerEvent * event);
81 
82 private:
84  void setupUi(void);
85  int TimerPeriodInMilliseconds;
86 
87  void JointLimitEventHandler(const vctBoolVec & flags);
88  void ErrorEventHandler(const std::string & message);
89  void EnableEventHandler(const bool & enable);
90 
91 protected:
92 
100 
103 
108 
112  } PID;
113 
114 private:
115  bool DirectControl;
116 
118  vctDoubleVec DesiredPosition;
119  prmPositionJointSet DesiredPositionParam;
120  vctDoubleVec UnitFactor;
121 
122  size_t NumberOfAxis;
123 
124  // GUI: Commands
125  QCheckBox * QCBEnableDirectControl;
126  QCheckBox * QCBEnablePID;
127  QCheckBox * QCBEnableTorqueMode;
128  QPushButton * QPBMaintainPosition;
129  QPushButton * QPBZeroPosition;
130  QPushButton * QPBResetPIDGain;
131  vctQtWidgetDynamicVectorDoubleWrite * QVWDesiredPositionWidget;
132  vctQtWidgetDynamicVectorDoubleWrite * QVWPGainWidget;
133  vctQtWidgetDynamicVectorDoubleWrite * QVWDGainWidget;
134  vctQtWidgetDynamicVectorDoubleWrite * QVWIGainWidget;
135  vctQtWidgetDynamicVectorDoubleRead * QVRCurrentPositionWidget;
136  vctQtWidgetDynamicVectorDoubleRead * QVRCurrentEffortWidget;
137 
138  // GUI: plot
139  vctPlot2DOpenGLQtWidget * QVPlot;
140  vctPlot2DBase::Signal * CurrentPositionSignal;
141  vctPlot2DBase::Signal * DesiredPositionSignal;
142  vctPlot2DBase::Signal * CurrentVelocitySignal;
143  vctPlot2DBase::Signal * DesiredEffortSignal;
144  vctPlot2DBase::Signal * CurrentEffortSignal;
145  QSpinBox * QSBPlotIndex;
146  int PlotIndex;
147 };
148 
150 
151 #endif // _mtsPIDQtWidget_h
#define CISST_EXPORT
Definition: cmnExportMacros.h:50
Definition: mtsFunctionRead.h:37
Defines XMLPath.
mtsFunctionRead GetStateJointDesired
Definition: mtsPIDQtWidget.h:99
mtsFunctionVoid ResetController
Definition: mtsPIDQtWidget.h:94
mtsFunctionWrite SetPositionJoint
Definition: mtsPIDQtWidget.h:97
mtsFunctionRead GetDGain
Definition: mtsPIDQtWidget.h:106
mtsFunctionRead GetPGain
Definition: mtsPIDQtWidget.h:105
Definition: mtsFunctionVoid.h:36
Declaration of units and unit conversion methodsThis file include the definition and implementation o...
const int CMN_DYNAMIC_CREATION_ONEARG
Definition: cmnClassRegisterMacros.h:333
Definition: vctQtForwardDeclarations.h:25
mtsFunctionRead GetJointType
Definition: mtsPIDQtWidget.h:104
mtsFunctionWrite SetDGain
Definition: mtsPIDQtWidget.h:110
virtual void Startup(void)
Definition: mtsComponent.h:262
mtsFunctionWrite EnableTorqueMode
Definition: mtsPIDQtWidget.h:96
Definition: prmStateJoint.h:35
prmStateJoint StateJoint
Definition: mtsPIDQtWidget.h:101
Definition: mtsComponent.h:60
Declaration of mtsComponent.
Definition: mtsPIDQtWidget.h:36
~mtsPIDQtWidget()
Definition: mtsPIDQtWidget.h:45
Definition: mtsComponent.h:150
mtsFunctionWrite SetPGain
Definition: mtsPIDQtWidget.h:109
mtsFunctionRead GetStateJoint
Definition: mtsPIDQtWidget.h:98
#define CMN_DECLARE_SERVICES(hasDynamicCreation, lod)
Definition: cmnClassRegisterMacros.h:116
const double cmn_ms
Definition: cmnUnits.h:190
Definition: vctPlot2DOpenGLQtWidget.h:29
mtsFunctionWrite SetIGain
Definition: mtsPIDQtWidget.h:111
Joint position move parameters.
Definition: mtsFunctionWrite.h:37
virtual void Configure(const std::string &filename="")
Definition: vctQtForwardDeclarations.h:36
Definition: mtsPIDQtWidget.h:93
virtual void Cleanup(void)
Definition: mtsComponent.h:267
Definition: vctPlot2DBase.h:55
#define CMN_LOG_ALLOW_DEFAULT
Definition: cmnLogLoD.h:76
prmStateJoint StateJointDesired
Definition: mtsPIDQtWidget.h:102
mtsFunctionRead GetIGain
Definition: mtsPIDQtWidget.h:107
CMN_DECLARE_SERVICES_INSTANTIATION(mtsPIDQtWidget)
Definition: prmPositionJointSet.h:37
mtsFunctionWrite Enable
Definition: mtsPIDQtWidget.h:95