31#define EMERGENCY_STOP_PROXY "EmergencyStopMaster"
32#define EMERGENCY_STOP_TOPIC_NAME "EmergencyStop"
37 static const std::string ss2_active_tooltip =
38 "Release SS2 emergency stop (only possible after a short cooldown period. Shortcut: "
39 "Shift+Pause or Shift+End.";
40 static const std::string ss2_inactive_tooltip =
41 "Enable SS2 emergency stop. Shortcut: Pause or End.";
44 mainWindow(mainWindow),
45 iconNormal(QPixmap::fromImage(QImage(QString::fromUtf8(
":/icons/emergency-stop.png")))),
46 iconDark(QPixmap::fromImage(QImage(QString::fromUtf8(
":/icons/emergency-stop-dark.png")))),
47 lastKnownEmergencyStopState(EmergencyStopState::eEmergencyStopInactive),
48 timer(new QTimer(this))
50 qRegisterMetaType<EmergencyStopState>(
"EmergencyStopState");
54 timer->setInterval(std::chrono::milliseconds(1'000));
55 connect(timer, &QTimer::timeout,
this, &EmergencyStopWidget::updateEmergencyStopState);
59 qOverload<>(&QTimer::start));
62 icon.addPixmap(iconNormal, QIcon::Normal, QIcon::Off);
63 icon.addPixmap(iconDark, QIcon::Normal, QIcon::On);
65 button =
new QToolButton();
66 button->setCheckable(
true);
67 button->setIcon(icon);
68 button->setIconSize(QSize(68, 28));
69 button->setToolTip(QString::fromStdString(ss2_active_tooltip));
70 button->setVisible(
false);
71 QGridLayout* l =
new QGridLayout(this->
getWidget());
73 l->setContentsMargins(0, 0, 0, 0);
75 this->
getWidget()->layout()->addWidget(button);
77 QShortcut* enableSS2Shortcut1 =
new QShortcut(this->
getWidget());
78 enableSS2Shortcut1->setContext(Qt::ApplicationShortcut);
79 enableSS2Shortcut1->setKey(Qt::Key_Pause);
80 QShortcut* enableSS2Shortcut2 =
new QShortcut(this->
getWidget());
81 enableSS2Shortcut2->setContext(Qt::ApplicationShortcut);
82 enableSS2Shortcut2->setKey(Qt::Key_End);
86 QShortcut* releaseSS2Shortcut1 =
new QShortcut(this->
getWidget());
87 releaseSS2Shortcut1->setContext(Qt::ApplicationShortcut);
88 releaseSS2Shortcut1->setKey(Qt::SHIFT | Qt::Key_Pause);
89 QShortcut* releaseSS2Shortcut2 =
new QShortcut(this->
getWidget());
90 releaseSS2Shortcut2->setContext(Qt::ApplicationShortcut);
91 releaseSS2Shortcut2->setKey(Qt::SHIFT | Qt::Key_End);
116 QMetaObject::invokeMethod(button,
"setVisible", Qt::QueuedConnection, Q_ARG(
bool,
true));
117 EmergencyStopState state = EmergencyStopState::eEmergencyStopActive;
121 state = emergencyStopMasterPrx->getEmergencyStopState();
123 catch (Ice::Exception
const& e)
128 QMetaObject::invokeMethod(
129 this,
"setChecked", Qt::QueuedConnection, Q_ARG(EmergencyStopState, state));
137 ARMARX_IMPORTANT <<
"SS2 widget disconnected. This is expected if the earlier connected "
138 "robot unit shut down.";
139 QMetaObject::invokeMethod(button,
"setVisible", Qt::QueuedConnection, Q_ARG(
bool,
false));
159 QMetaObject::invokeMethod(
160 this,
"setChecked", Qt::QueuedConnection, Q_ARG(EmergencyStopState, state));
166 if (emergencyStopMasterPrx)
168 emergencyStopMasterPrx->setEmergencyStopState(EmergencyStopState::eEmergencyStopActive);
170 if (lastKnownEmergencyStopState == EmergencyStopState::eEmergencyStopActive)
172 std::string
const message =
173 "SS2 already active. Press Shift+Pause or Shift+End to release SS2.";
176 button->mapToGlobal(QPoint(button->width() / 2, button->height() / 2));
177 QToolTip::showText(globalPos, QString::fromStdString(message), button);
186 if (emergencyStopMasterPrx)
190 if (lastKnownEmergencyStopState == EmergencyStopState::eEmergencyStopActive)
192 std::string
const message =
"SS2 cannot be released since it was just activated.";
195 button->mapToGlobal(QPoint(button->width() / 2, button->height() / 2));
196 QToolTip::showText(globalPos, QString::fromStdString(message), button);
205 if (not emergencyStopMasterPrx)
210 switch (lastKnownEmergencyStopState)
212 case EmergencyStopState::eEmergencyStopActive:
216 if (lastKnownEmergencyStopState == EmergencyStopState::eEmergencyStopActive)
218 ARMARX_INFO <<
"SS2 cannot be released since it was just activated.";
219 button->setChecked(
true);
223 case EmergencyStopState::eEmergencyStopInactive:
241 if (not emergencyStopMasterPrx)
243 return EmergencyStopState::eEmergencyStopActive;
248 return emergencyStopMasterPrx->trySetEmergencyStopState(
249 EmergencyStopState::eEmergencyStopInactive);
254 catch (Ice::OperationNotExistException
const&)
256 ARMARX_WARNING <<
"Cannot safely release SS2. This only happens if your ArmarX GUI "
257 "is using a newer version of the emergency stop interface than the "
258 "emergency stop master or the robot unit provides. Will use a less "
259 "safe fallback interface method now.";
260 emergencyStopMasterPrx->setEmergencyStopState(
261 EmergencyStopState::eEmergencyStopInactive);
262 return emergencyStopMasterPrx->getEmergencyStopState();
267 EmergencyStopWidget::setChecked(
const EmergencyStopState state)
271 case EmergencyStopState::eEmergencyStopActive:
272 button->setChecked(
true);
273 button->setToolTip(QString::fromStdString(ss2_active_tooltip));
275 case EmergencyStopState::eEmergencyStopInactive:
277 button->setChecked(
false);
278 button->setToolTip(QString::fromStdString(ss2_inactive_tooltip));
282 lastKnownEmergencyStopState = state;
286 EmergencyStopWidget::updateEmergencyStopState()
290 if (emergencyStopMasterPrx)
292 setChecked(emergencyStopMasterPrx->getEmergencyStopState());
295 catch (Ice::Exception
const& e)
298 setChecked(EmergencyStopState::eEmergencyStopActive);
SpamFilterDataPtr deactivateSpam(SpamFilterDataPtr const &spamFilter, float deactivationDurationSec, const std::string &identifier, bool deactivate)
The ArmarXMainWindow class.
bool usingProxy(const std::string &name, const std::string &endpoints="")
Registers a proxy for retrieval after initialization and adds it to the dependency list.
void usingTopic(const std::string &name, bool orderedPublishing=false)
Registers a proxy for subscription after initialization.
Ice::ObjectPrx getProxy(long timeoutMs=0, bool waitForScheduler=true) const
Returns the proxy of this object (optionally it waits for the proxy)
#define ARMARX_INFO
The normal logging level.
#define ARMARX_IMPORTANT
The logging level for always important information, but expected behaviour (in contrast to ARMARX_WAR...
#define ARMARX_ERROR
The logging level for unexpected behaviour, that must be fixed.
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
This file offers overloads of toIce() and fromIce() functions for STL container types.