39 #include <visp3/ustk_gui/usRobotManualControlWidget.h>
41 #ifdef USTK_HAVE_VTK_QT
45 this->setStyleSheet(
"QGroupBox { border: 2px solid Lightgray;}");
47 this->setMinimumWidth(160);
48 this->setMinimumHeight(200);
50 txLabel =
new QLabel(
"vx: ",
this);
51 tyLabel =
new QLabel(
"vy: ",
this);
52 tzLabel =
new QLabel(
"vz: ",
this);
53 wxLabel =
new QLabel(
"wx: ",
this);
54 wyLabel =
new QLabel(
"wy: ",
this);
55 wzLabel =
new QLabel(
"wz: ",
this);
57 txSlider =
new QSlider(Qt::Horizontal,
this);
58 txSlider->setValue(0);
59 txSlider->setRange(-100, 100);
60 tySlider =
new QSlider(Qt::Horizontal,
this);
61 tySlider->setValue(0);
62 tySlider->setRange(-100, 100);
63 tzSlider =
new QSlider(Qt::Horizontal,
this);
64 tzSlider->setValue(0);
65 tzSlider->setRange(-100, 100);
67 wxSlider =
new QSlider(Qt::Horizontal,
this);
68 wxSlider->setValue(0);
69 wxSlider->setRange(-80, 80);
70 wySlider =
new QSlider(Qt::Horizontal,
this);
71 wySlider->setValue(0);
72 wySlider->setRange(-80, 80);
73 wzSlider =
new QSlider(Qt::Horizontal,
this);
74 wzSlider->setValue(0);
75 wzSlider->setRange(-80, 80);
77 initPushButton =
new QPushButton(
this);
78 initPushButton->setText(QString(
"Init robot"));
79 initPushButton->setEnabled(
true);
80 startStopPushButton =
new QPushButton(
this);
81 startStopPushButton->setText(QString(
"Start robot"));
82 startStopPushButton->setEnabled(
false);
84 labelRobotState =
new QLabel(
this);
85 labelRobotState->setText(
"Press security handle, then click Init robot");
87 txSlider->setMinimumWidth(150);
88 tySlider->setMinimumWidth(150);
89 tzSlider->setMinimumWidth(150);
90 wxSlider->setMinimumWidth(150);
91 wySlider->setMinimumWidth(150);
92 wzSlider->setMinimumWidth(150);
94 automaticForceButton =
new QPushButton(
this);
95 automaticForceButton->setText(QString(
"Enable automatic force control"));
96 automaticForceButton->setEnabled(
true);
99 L->addWidget(txLabel, 0, 0, Qt::AlignRight);
100 L->addWidget(tyLabel, 1, 0, Qt::AlignRight);
101 L->addWidget(tzLabel, 2, 0, Qt::AlignRight);
102 L->addWidget(wxLabel, 3, 0, Qt::AlignRight);
103 L->addWidget(wyLabel, 4, 0, Qt::AlignRight);
104 L->addWidget(wzLabel, 5, 0, Qt::AlignRight);
105 L->addWidget(initPushButton, 6, 0, 1, 2, Qt::AlignCenter);
106 L->addWidget(startStopPushButton, 7, 0, 1, 2, Qt::AlignCenter);
107 L->addWidget(labelRobotState, 8, 0, 1, 2, Qt::AlignCenter);
108 L->addWidget(automaticForceButton, 9, 0, 1, 2, Qt::AlignCenter);
110 L->addWidget(txSlider, 0, 1, Qt::AlignLeft);
111 L->addWidget(tySlider, 1, 1, Qt::AlignLeft);
112 L->addWidget(tzSlider, 2, 1, Qt::AlignLeft);
113 L->addWidget(wxSlider, 3, 1, Qt::AlignLeft);
114 L->addWidget(wySlider, 4, 1, Qt::AlignLeft);
115 L->addWidget(wzSlider, 5, 1, Qt::AlignLeft);
138 delete startStopPushButton;
139 delete labelRobotState;
141 delete automaticForceButton;
147 void usRobotManualControlWidget::setUpConnections()
150 connect(txSlider, SIGNAL(sliderReleased()), SLOT(
releaseSlider()));
151 connect(tySlider, SIGNAL(sliderReleased()), SLOT(
releaseSlider()));
152 connect(tzSlider, SIGNAL(sliderReleased()), SLOT(
releaseSlider()));
153 connect(wxSlider, SIGNAL(sliderReleased()), SLOT(
releaseSlider()));
154 connect(wySlider, SIGNAL(sliderReleased()), SLOT(
releaseSlider()));
155 connect(wzSlider, SIGNAL(sliderReleased()), SLOT(
releaseSlider()));
157 connect(txSlider, SIGNAL(valueChanged(
int)), SIGNAL(
changeVX(
int)));
158 connect(tySlider, SIGNAL(valueChanged(
int)), SIGNAL(
changeVY(
int)));
159 connect(tzSlider, SIGNAL(valueChanged(
int)), SIGNAL(
changeVZ(
int)));
160 connect(wxSlider, SIGNAL(valueChanged(
int)), SIGNAL(
changeWX(
int)));
161 connect(wySlider, SIGNAL(valueChanged(
int)), SIGNAL(
changeWY(
int)));
162 connect(wzSlider, SIGNAL(valueChanged(
int)), SIGNAL(
changeWZ(
int)));
164 connect(initPushButton, SIGNAL(clicked()), SIGNAL(
initRobot()));
165 automaticForceButton->setText(QString(
"Enable automatic force control"));
166 automaticForceButton->setEnabled(
false);
172 connect(automaticForceButton, SIGNAL(clicked()),
this, SLOT(activateAutomaticForceControlSlot()));
177 QSlider *slider =
dynamic_cast<QSlider *
>(sender());
183 startStopPushButton->setEnabled(
true);
184 startStopPushButton->setText(QString(
"Start robot"));
185 labelRobotState->setText(QString(
"Now press the viper start button (flashing)"));
191 if (startStopPushButton->text() == QString(
"Start robot")) {
193 startStopPushButton->setText(QString(
"Stop robot"));
194 labelRobotState->setText(QString(
"Robot OK, you can move it or stop it"));
195 automaticForceButton->setEnabled(
true);
198 else if (startStopPushButton->text() == QString(
"Stop robot")) {
200 startStopPushButton->setText(QString(
"Start robot"));
201 labelRobotState->setText(QString(
"Robot stopped"));
202 automaticForceButton->setEnabled(
false);
209 labelRobotState->setText(text);
215 startStopPushButton->setEnabled(
false);
216 labelRobotState->setText(
"Robot Error ! To restart, press security handle, then click Init robot");
217 automaticForceButton->setText(QString(
"Enable automatic force control"));
218 automaticForceButton->setEnabled(
false);
222 void usRobotManualControlWidget::activateAutomaticForceControlSlot()
225 bool activate = automaticForceButton->text() == QString(
"Enable automatic force control");
227 txSlider->setEnabled(!activate);
228 tySlider->setEnabled(!activate);
229 automaticForceButton->setText(QString(
"Enable automatic force control"));
230 tzSlider->setEnabled(!activate);
231 wxSlider->setEnabled(!activate);
232 wySlider->setEnabled(!activate);
233 wzSlider->setEnabled(!activate);
235 automaticForceButton->setText(QString(
"Disable automatic force control"));
236 labelRobotState->setText(
"Automatic force control enabled");
240 automaticForceButton->setText(QString(
"Enable automatic force control"));
241 labelRobotState->setText(
"Manual robot control");