cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mtsRobotIO1394QtWidget.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
6  Created on: 2012-07-20
7 
8  (C) Copyright 2012-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 #ifndef _mtsRobotIO1394QtWidget_h
20 #define _mtsRobotIO1394QtWidget_h
21 
27 
28 #include <QWidget>
29 #include <QCheckBox>
30 #include <QPushButton>
31 #include <QDoubleSpinBox>
32 
37 class mtsRobotIO1394QtWidget: public QWidget, public mtsComponent
38 {
39  Q_OBJECT;
41 
42 public:
43  mtsRobotIO1394QtWidget(const std::string & componentName,
44  unsigned int numberOfActuators,
45  unsigned int numberOfBrakes,
46  double periodInSeconds = 50.0 * cmn_ms);
48  inline ~mtsRobotIO1394QtWidget(void) {}
49 
50  void Configure(const std::string & filename = "");
51  void Startup(void);
52  void Cleanup(void);
53 
54 protected:
55  void Init(void);
56  virtual void closeEvent(QCloseEvent *event);
57 
58 private slots:
59  void SlotEnableAmps(bool toggle);
60  void SlotEnableAll(bool toggle);
61  void SlotEnableDirectControl(bool toggle);
62  void SlotActuatorAmpEnable(void);
63  void SlotResetCurrentAll(void);
64  void SlotActuatorCurrentValueChanged();
65  void SlotSliderActuatorCurrentValueChanged(void);
66  void SlotBrakeAmpEnable(void);
67  void SlotResetEncodersAll(void);
68  void SlotBiasEncodersAll(void);
69  void SlotWatchdogPeriod(double period_ms);
70  void SlotBrakeEngage(void);
71  void SlotBrakeRelease(void);
72 
73  void timerEvent(QTimerEvent * event);
74 
75 private:
76  void SetupCisstInterface(void);
77  void setupUi(void);
78 
79  // gui update
80  void UpdateCurrentDisplay(void);
81  void UpdateRobotInfo(void);
82 
83 protected:
87 
88  struct RobotStruct {
93 
105 
117 
119  } Robot;
120 
121  struct ActuatorStruct {
124 
126 
130  } Actuators;
131 
132 
133 private:
134  mtsIntervalStatistics IntervalStatistics;
135 
136  size_t NumberOfActuators;
137  size_t NumberOfBrakes;
138 
139  vctDoubleVec UnitFactor;
140  vctDoubleVec JointPosition;
141  prmPositionJointGet ActuatorPositionGet;
142  vctDoubleVec ActuatorPosition;
143  vctDoubleVec ActuatorVelocity;
144  vctDoubleVec PotentiometersVolts;
145  vctDoubleVec PotentiometersPosition;
146  vctDoubleVec ActuatorFeedbackCurrent;
147  vctDoubleVec ActuatorRequestedCurrent;
148  vctDoubleVec ActuatorAmpTemperature;
149  vctBoolVec ActuatorAmpEnable;
150  vctBoolVec ActuatorAmpStatus;
151  vctDoubleVec BrakeFeedbackCurrent;
152  vctDoubleVec BrakeRequestedCurrent;
153  vctDoubleVec BrakeAmpTemperature;
154  vctBoolVec BrakeAmpEnable;
155  vctBoolVec BrakeAmpStatus;
156 
157  bool PowerStatus;
158  unsigned short SafetyRelay;
159 
160  // Interface
161  double DummyValueWhenNotConnected;
162  vctDynamicVector<bool> LastEnableState;
163  double StartTime;
164 
165  // GUI: Commands
166  QCheckBox * QCBEnableAmps;
167  QCheckBox * QCBEnableAll;
168  QPushButton * QPBResetCurrentAll;
169 
170  // GUI: Feedbacks
171  QPushButton * QPBResetEncAll;
172  QPushButton * QPBBiasEncAll;
173  QDoubleSpinBox * QSBWatchdogPeriod;
174  QCheckBox * QCBEnableDirectControl;
175 
176  // GUI: timing
177  mtsQtWidgetIntervalStatistics * QMIntervalStatistics;
178 
179  vctQtWidgetDynamicVectorBoolWrite * QVWActuatorCurrentEnableEachWidget;
180  vctQtWidgetDynamicVectorDoubleWrite * QVWActuatorCurrentSpinBoxWidget;
181  vctQtWidgetDynamicVectorDoubleWrite * QVWActuatorCurrentSliderWidget;
182  vctQtWidgetDynamicVectorDoubleRead * QVRActuatorCurrentFeedbackWidget;
183  vctQtWidgetDynamicVectorDoubleRead * QVRJointPositionWidget;
184  vctQtWidgetDynamicVectorDoubleRead * QVRActuatorPositionWidget;
185  vctQtWidgetDynamicVectorDoubleRead * QVRActuatorVelocityWidget;
186  vctQtWidgetDynamicVectorDoubleRead * QVRPotVoltsWidget;
187  vctQtWidgetDynamicVectorDoubleRead * QVRPotPositionWidget;
188  vctQtWidgetDynamicVectorDoubleRead * QVRActuatorAmpTemperature;
189 
190  // Brakes
191  QPushButton * QPBBrakeRelease;
192  QPushButton * QPBBrakeEngage;
193  vctQtWidgetDynamicVectorBoolWrite * QVWBrakeCurrentEnableEachWidget;
194  vctQtWidgetDynamicVectorDoubleRead * QVRBrakeCurrentCommandWidget;
195  vctQtWidgetDynamicVectorDoubleRead * QVRBrakeCurrentFeedbackWidget;
196  vctQtWidgetDynamicVectorDoubleRead * QVRBrakeAmpTemperature;
197 
198  QLabel * QLAmpStatus;
199  QLabel * QLPowerStatus;
200  QLabel * QLSafetyRelay;
201  QLabel * QLWatchdog;
202  QLabel * QLWatchdogLastTimeout;
203 
204  void PowerStatusEventHandler(const bool & status);
205  void WatchdogStatusEventHandler(const bool & status);
206 
207  // signal and slot used by mts event handlers, this this component
208  // doesn't have a thread (i.e. mtsTask), events are handled in the
209  // thread that sends the event. We then use Qt emit/slot to maintain
210  // thread safety
211 signals:
212  void SignalPowerStatus(bool status);
213  void SignalWatchdogStatus(bool status);
214 protected slots:
215  void SlotPowerStatus(bool status);
216  void SlotWatchdogStatus(bool status);
217 };
218 
220 
221 #endif // _mtsRobotIO1394QtWidget_h
Definition: prmPositionJointGet.h:35
mtsFunctionRead GetAnalogInputPosSI
Definition: mtsRobotIO1394QtWidget.h:97
mtsFunctionVoid BrakeRelease
Definition: mtsRobotIO1394QtWidget.h:113
mtsFunctionVoid DisableBoardsPower
Definition: mtsRobotIO1394QtWidget.h:123
mtsFunctionRead GetPeriodStatistics
Definition: mtsRobotIO1394QtWidget.h:89
void SignalWatchdogStatus(bool status)
mtsFunctionRead GetVelocity
Definition: mtsRobotIO1394QtWidget.h:95
Definition: mtsFunctionRead.h:37
mtsFunctionRead GetAmpEnable
Definition: mtsRobotIO1394QtWidget.h:127
Declaration of osaTimeServer class.
CMN_DECLARE_SERVICES_INSTANTIATION(mtsRobotIO1394QtWidget)
mtsFunctionRead GetBrakeAmpTemperature
Definition: mtsRobotIO1394QtWidget.h:111
Definition: vctQtWidgetDynamicVector.h:142
void SlotPowerStatus(bool status)
Definition: mtsFunctionVoid.h:36
mtsFunctionWrite SetBrakeAmpEnable
Definition: mtsRobotIO1394QtWidget.h:106
mtsFunctionVoid EnableBoardsPower
Definition: mtsRobotIO1394QtWidget.h:122
virtual void closeEvent(QCloseEvent *event)
int TimerPeriodInMilliseconds
Definition: mtsRobotIO1394QtWidget.h:85
mtsFunctionRead GetPositionActuator
Definition: mtsRobotIO1394QtWidget.h:129
const int CMN_DYNAMIC_CREATION_ONEARG
Definition: cmnClassRegisterMacros.h:333
Definition: vctQtForwardDeclarations.h:25
mtsFunctionRead GetSafetyRelay
Definition: mtsRobotIO1394QtWidget.h:103
struct mtsRobotIO1394QtWidget::ActuatorStruct Actuators
mtsFunctionWrite SetAmpEnable
Definition: mtsRobotIO1394QtWidget.h:125
Definition: mtsRobotIO1394QtWidget.h:37
bool DirectControl
Definition: mtsRobotIO1394QtWidget.h:84
double WatchdogPeriodInSeconds
Definition: mtsRobotIO1394QtWidget.h:86
Definition: mtsComponent.h:60
void SlotWatchdogStatus(bool status)
Declaration of mtsComponent.
Definition: mtsIntervalStatistics.h:45
Definition: mtsQtWidgetIntervalStatistics.h:32
mtsFunctionRead GetActuatorAmpTemperature
Definition: mtsRobotIO1394QtWidget.h:104
Definition: mtsComponent.h:150
mtsFunctionVoid DisablePower
Definition: mtsRobotIO1394QtWidget.h:92
Definition: mtsRobotIO1394QtWidget.h:121
mtsFunctionWrite SetEncoderPosition
Definition: mtsRobotIO1394QtWidget.h:115
mtsRobotIO1394QtWidget(const std::string &componentName, unsigned int numberOfActuators, unsigned int numberOfBrakes, double periodInSeconds=50.0 *cmn_ms)
mtsFunctionRead GetBrakeAmpStatus
Definition: mtsRobotIO1394QtWidget.h:108
mtsFunctionRead GetAmpStatus
Definition: mtsRobotIO1394QtWidget.h:128
const double cmn_ms
Definition: cmnUnits.h:190
mtsFunctionRead GetBrakeAmpEnable
Definition: mtsRobotIO1394QtWidget.h:107
struct mtsRobotIO1394QtWidget::RobotStruct Robot
mtsFunctionRead GetPosition
Definition: mtsRobotIO1394QtWidget.h:94
mtsFunctionRead GetActuatorFeedbackCurrent
Definition: mtsRobotIO1394QtWidget.h:99
mtsFunctionRead GetJointType
Definition: mtsRobotIO1394QtWidget.h:101
mtsFunctionVoid EnablePower
Definition: mtsRobotIO1394QtWidget.h:91
void Configure(const std::string &filename="")
mtsFunctionRead GetBrakeFeedbackCurrent
Definition: mtsRobotIO1394QtWidget.h:110
mtsFunctionVoid BiasEncoder
Definition: mtsRobotIO1394QtWidget.h:118
mtsFunctionWrite SetWatchdogPeriod
Definition: mtsRobotIO1394QtWidget.h:116
mtsFunctionRead GetPowerStatus
Definition: mtsRobotIO1394QtWidget.h:102
mtsFunctionRead GetAnalogInputVolts
Definition: mtsRobotIO1394QtWidget.h:96
~mtsRobotIO1394QtWidget(void)
Definition: mtsRobotIO1394QtWidget.h:48
mtsFunctionRead GetActuatorCurrentMax
Definition: mtsRobotIO1394QtWidget.h:100
Definition: mtsFunctionWrite.h:37
mtsFunctionVoid BrakeEngage
Definition: mtsRobotIO1394QtWidget.h:112
mtsFunctionRead GetBrakeRequestedCurrent
Definition: mtsRobotIO1394QtWidget.h:109
mtsFunctionWrite SetActuatorCurrent
Definition: mtsRobotIO1394QtWidget.h:114
Definition: vctQtForwardDeclarations.h:36
mtsFunctionRead GetActuatorRequestedCurrent
Definition: mtsRobotIO1394QtWidget.h:98
void SignalPowerStatus(bool status)
Definition: mtsRobotIO1394QtWidget.h:88
#define CMN_LOG_ALLOW_DEFAULT
Definition: cmnLogLoD.h:76
mtsFunctionRead IsValid
Definition: mtsRobotIO1394QtWidget.h:90