Skip to content
Snippets Groups Projects
Commit 381df033 authored by Rainer Kartmann's avatar Rainer Kartmann
Browse files

Make logging nicer

parent aa89a38f
No related branches found
No related tags found
No related merge requests found
...@@ -47,6 +47,7 @@ PlatformUnitGuiPlugin::PlatformUnitGuiPlugin() ...@@ -47,6 +47,7 @@ PlatformUnitGuiPlugin::PlatformUnitGuiPlugin()
addWidget<PlatformUnitWidget>(); addWidget<PlatformUnitWidget>();
} }
PlatformUnitWidget::PlatformUnitWidget() : PlatformUnitWidget::PlatformUnitWidget() :
platformUnitProxyName("PlatformUnit"), // overwritten in loadSettings() anyway? platformUnitProxyName("PlatformUnit"), // overwritten in loadSettings() anyway?
platformName("Platform"), platformName("Platform"),
...@@ -79,7 +80,6 @@ PlatformUnitWidget::PlatformUnitWidget() : ...@@ -79,7 +80,6 @@ PlatformUnitWidget::PlatformUnitWidget() :
connect(getWidget().data(), SIGNAL(commandKeyPressed(int)), this, SLOT(controlPlatformWithKeyboard(int))); connect(getWidget().data(), SIGNAL(commandKeyPressed(int)), this, SLOT(controlPlatformWithKeyboard(int)));
connect(getWidget().data(), SIGNAL(commandKeyReleased(int)), this, SLOT(stopPlatformWithKeyboard(int))); connect(getWidget().data(), SIGNAL(commandKeyReleased(int)), this, SLOT(stopPlatformWithKeyboard(int)));
} }
...@@ -91,23 +91,25 @@ void PlatformUnitWidget::onInitComponent() ...@@ -91,23 +91,25 @@ void PlatformUnitWidget::onInitComponent()
} }
void PlatformUnitWidget::onConnectComponent() void PlatformUnitWidget::onConnectComponent()
{ {
platformUnitProxy = getProxy<PlatformUnitInterfacePrx>(platformUnitProxyName); platformUnitProxy = getProxy<PlatformUnitInterfacePrx>(platformUnitProxyName);
connectSlots(); connectSlots();
} }
void PlatformUnitWidget::onDisconnectComponent() void PlatformUnitWidget::onDisconnectComponent()
{ {
stopControlTimer(); stopControlTimer();
} }
void PlatformUnitWidget::onExitComponent() void PlatformUnitWidget::onExitComponent()
{ {
} }
QPointer<QDialog> PlatformUnitWidget::getConfigDialog(QWidget* parent) QPointer<QDialog> PlatformUnitWidget::getConfigDialog(QWidget* parent)
{ {
if (!dialog) if (!dialog)
...@@ -119,6 +121,7 @@ QPointer<QDialog> PlatformUnitWidget::getConfigDialog(QWidget* parent) ...@@ -119,6 +121,7 @@ QPointer<QDialog> PlatformUnitWidget::getConfigDialog(QWidget* parent)
return qobject_cast<PlatformUnitConfigDialog*>(dialog); return qobject_cast<PlatformUnitConfigDialog*>(dialog);
} }
void PlatformUnitWidget::configured() void PlatformUnitWidget::configured()
{ {
platformUnitProxyName = dialog->finder->getSelectedProxyName().toStdString(); platformUnitProxyName = dialog->finder->getSelectedProxyName().toStdString();
...@@ -132,6 +135,7 @@ void PlatformUnitWidget::loadSettings(QSettings* settings) ...@@ -132,6 +135,7 @@ void PlatformUnitWidget::loadSettings(QSettings* settings)
platformName = settings->value("platformName", QString::fromStdString(platformName)).toString().toStdString(); platformName = settings->value("platformName", QString::fromStdString(platformName)).toString().toStdString();
} }
void PlatformUnitWidget::saveSettings(QSettings* settings) void PlatformUnitWidget::saveSettings(QSettings* settings)
{ {
settings->setValue("platformUnitProxyName", QString::fromStdString(platformUnitProxyName)); settings->setValue("platformUnitProxyName", QString::fromStdString(platformUnitProxyName));
...@@ -153,11 +157,9 @@ void PlatformUnitWidget::connectSlots() ...@@ -153,11 +157,9 @@ void PlatformUnitWidget::connectSlots()
connect(rotaCtrl, SIGNAL(released()), this, SLOT(stopPlatform()), Qt::UniqueConnection); connect(rotaCtrl, SIGNAL(released()), this, SLOT(stopPlatform()), Qt::UniqueConnection);
connect(rotaCtrl, SIGNAL(released()), this, SLOT(stopControlTimer()), Qt::UniqueConnection); connect(rotaCtrl, SIGNAL(released()), this, SLOT(stopControlTimer()), Qt::UniqueConnection);
connect(ui.buttonStopPlatform, SIGNAL(pressed()), this, SLOT(stopPlatform()), Qt::UniqueConnection); connect(ui.buttonStopPlatform, SIGNAL(pressed()), this, SLOT(stopPlatform()), Qt::UniqueConnection);
} }
void PlatformUnitWidget::moveTo() void PlatformUnitWidget::moveTo()
{ {
ARMARX_LOG << "Moving Platform"; ARMARX_LOG << "Moving Platform";
...@@ -169,6 +171,7 @@ void PlatformUnitWidget::moveTo() ...@@ -169,6 +171,7 @@ void PlatformUnitWidget::moveTo()
platformUnitProxy->moveTo(positionX, positionY, rotation, posAcc, rotAcc); platformUnitProxy->moveTo(positionX, positionY, rotation, posAcc, rotAcc);
} }
void PlatformUnitWidget::setNewPlatformPoseLabels(float x, float y, float alpha) void PlatformUnitWidget::setNewPlatformPoseLabels(float x, float y, float alpha)
{ {
ui.labelCurrentPositionX->setText(QString::number(x)); ui.labelCurrentPositionX->setText(QString::number(x));
...@@ -177,6 +180,7 @@ void PlatformUnitWidget::setNewPlatformPoseLabels(float x, float y, float alpha) ...@@ -177,6 +180,7 @@ void PlatformUnitWidget::setNewPlatformPoseLabels(float x, float y, float alpha)
} }
void PlatformUnitWidget::setNewTargetPoseLabels(float x, float y, float alpha) void PlatformUnitWidget::setNewTargetPoseLabels(float x, float y, float alpha)
{ {
ui.editTargetPositionX->setText(QString::number(x)); ui.editTargetPositionX->setText(QString::number(x));
...@@ -184,13 +188,13 @@ void PlatformUnitWidget::setNewTargetPoseLabels(float x, float y, float alpha) ...@@ -184,13 +188,13 @@ void PlatformUnitWidget::setNewTargetPoseLabels(float x, float y, float alpha)
ui.editTargetRotation->setText(QString::number(alpha)); ui.editTargetRotation->setText(QString::number(alpha));
} }
void PlatformUnitWidget::startControlTimer() void PlatformUnitWidget::startControlTimer()
{ {
ctrlEvaluationTimer.start(CONTROL_TICK_RATE); //tickrate in ms
ctrlEvaluationTimer.start(CONTROL_TICK_RATE);//tickrate in ms
} }
void PlatformUnitWidget::stopControlTimer() void PlatformUnitWidget::stopControlTimer()
{ {
ctrlEvaluationTimer.stop(); ctrlEvaluationTimer.stop();
...@@ -198,6 +202,7 @@ void PlatformUnitWidget::stopControlTimer() ...@@ -198,6 +202,7 @@ void PlatformUnitWidget::stopControlTimer()
rotaCtrl->setNibble({0, 0}); rotaCtrl->setNibble({0, 0});
} }
void PlatformUnitWidget::reportPlatformPose(PlatformPose const& currentPose, const Ice::Current& c) void PlatformUnitWidget::reportPlatformPose(PlatformPose const& currentPose, const Ice::Current& c)
{ {
// moved to qt thread for thread safety // moved to qt thread for thread safety
...@@ -205,6 +210,7 @@ void PlatformUnitWidget::reportPlatformPose(PlatformPose const& currentPose, con ...@@ -205,6 +210,7 @@ void PlatformUnitWidget::reportPlatformPose(PlatformPose const& currentPose, con
platformRotation = currentPose.rotationAroundZ; platformRotation = currentPose.rotationAroundZ;
} }
void PlatformUnitWidget::reportNewTargetPose(::Ice::Float newPlatformPositionX, ::Ice::Float newPlatformPositionY, ::Ice::Float newPlatformRotation, const Ice::Current& c) void PlatformUnitWidget::reportNewTargetPose(::Ice::Float newPlatformPositionX, ::Ice::Float newPlatformPositionY, ::Ice::Float newPlatformRotation, const Ice::Current& c)
{ {
// moved to qt thread for thread safety // moved to qt thread for thread safety
...@@ -219,14 +225,15 @@ void PlatformUnitWidget::reportPlatformVelocity(::Ice::Float currentPlatformVelo ...@@ -219,14 +225,15 @@ void PlatformUnitWidget::reportPlatformVelocity(::Ice::Float currentPlatformVelo
} }
void PlatformUnitWidget::stopPlatform() void PlatformUnitWidget::stopPlatform()
{ {
platformUnitProxy->stopPlatform(); platformUnitProxy->stopPlatform();
} }
void PlatformUnitWidget::controlPlatformWithKeyboard(int key) void PlatformUnitWidget::controlPlatformWithKeyboard(int key)
{ {
pressedKeys.insert(key); pressedKeys.insert(key);
if (!ctrlEvaluationTimer.isActive()) if (!ctrlEvaluationTimer.isActive())
{ {
...@@ -237,13 +244,11 @@ void PlatformUnitWidget::controlPlatformWithKeyboard(int key) ...@@ -237,13 +244,11 @@ void PlatformUnitWidget::controlPlatformWithKeyboard(int key)
keyboardVelocityControl(); keyboardVelocityControl();
keyboardVelocityTimer.start(); keyboardVelocityTimer.start();
} }
} }
void PlatformUnitWidget::stopPlatformWithKeyboard(int key) void PlatformUnitWidget::stopPlatformWithKeyboard(int key)
{ {
pressedKeys.remove(key); pressedKeys.remove(key);
if (!keyboardVelocityTimer.isActive()) if (!keyboardVelocityTimer.isActive())
...@@ -251,9 +256,9 @@ void PlatformUnitWidget::stopPlatformWithKeyboard(int key) ...@@ -251,9 +256,9 @@ void PlatformUnitWidget::stopPlatformWithKeyboard(int key)
keyboardVelocityControl(); keyboardVelocityControl();
keyboardVelocityTimer.start(); keyboardVelocityTimer.start();
} }
} }
void PlatformUnitWidget::keyboardVelocityControl() void PlatformUnitWidget::keyboardVelocityControl()
{ {
if (!pressedKeys.contains(Qt::Key_A) && !pressedKeys.contains(Qt::Key_D)) if (!pressedKeys.contains(Qt::Key_A) && !pressedKeys.contains(Qt::Key_D))
...@@ -307,6 +312,7 @@ void PlatformUnitWidget::keyboardVelocityControl() ...@@ -307,6 +312,7 @@ void PlatformUnitWidget::keyboardVelocityControl()
break; break;
} }
} }
currentKeyboardVelocityAlpha = std::max(-1.f, currentKeyboardVelocityAlpha); currentKeyboardVelocityAlpha = std::max(-1.f, currentKeyboardVelocityAlpha);
currentKeyboardVelocityAlpha = std::min(1.f, currentKeyboardVelocityAlpha); currentKeyboardVelocityAlpha = std::min(1.f, currentKeyboardVelocityAlpha);
currentKeyboardVelocityX = std::max(-1.f, currentKeyboardVelocityX); currentKeyboardVelocityX = std::max(-1.f, currentKeyboardVelocityX);
...@@ -317,13 +323,9 @@ void PlatformUnitWidget::keyboardVelocityControl() ...@@ -317,13 +323,9 @@ void PlatformUnitWidget::keyboardVelocityControl()
float y = sin(acos(currentKeyboardVelocityAlpha)); float y = sin(acos(currentKeyboardVelocityAlpha));
speedCtrl->setNibble(QPointF(currentKeyboardVelocityX, currentKeyboardVelocityY)); speedCtrl->setNibble(QPointF(currentKeyboardVelocityX, currentKeyboardVelocityY));
rotaCtrl->setNibble(QPointF(currentKeyboardVelocityAlpha, -y)); rotaCtrl->setNibble(QPointF(currentKeyboardVelocityAlpha, -y));
} }
QPointer<QWidget> PlatformUnitWidget::getWidget() QPointer<QWidget> PlatformUnitWidget::getWidget()
{ {
if (!__widget) if (!__widget)
...@@ -335,27 +337,29 @@ QPointer<QWidget> PlatformUnitWidget::getWidget() ...@@ -335,27 +337,29 @@ QPointer<QWidget> PlatformUnitWidget::getWidget()
} }
void PlatformUnitWidget::controlTimerTick() void PlatformUnitWidget::controlTimerTick()
{ {
float translationFactor = ui.maxTranslationSpeed->value(); float translationFactor = ui.maxTranslationSpeed->value();
float rotationFactor = ui.maxRotationSpeed->value() * -1; float rotationFactor = ui.maxRotationSpeed->value() * -1;
float rotationVel = rotaCtrl->getRotation() / M_PI_2 * rotationFactor; float rotationVel = rotaCtrl->getRotation() / M_PI_2 * rotationFactor;
ARMARX_INFO << deactivateSpam(0.5) << speedCtrl->getPosition().x()*translationFactor << ", " << speedCtrl->getPosition().y()*translationFactor; ARMARX_INFO << deactivateSpam(0.5)
ARMARX_INFO << deactivateSpam(0.5) << "Rotation Speed: " << (rotationVel); << "Translation speed: (" << speedCtrl->getPosition().x() * translationFactor
platformUnitProxy->move(speedCtrl->getPosition().x()*translationFactor, -1 * speedCtrl->getPosition().y()*translationFactor, rotationVel); << ", " << speedCtrl->getPosition().y() * translationFactor << ")"
<< ", \t rotation speed: " << (rotationVel);
platformUnitProxy->move(speedCtrl->getPosition().x() * translationFactor,
-1 * speedCtrl->getPosition().y() * translationFactor,
rotationVel);
if (speedCtrl->getPosition().x() == 0 if (speedCtrl->getPosition().x() == 0
&& speedCtrl->getPosition().y() == 0 && speedCtrl->getPosition().y() == 0
&& rotaCtrl->getRotation() == 0) && rotaCtrl->getRotation() == 0)
{ {
stopControlTimer(); stopControlTimer();
} }
} }
void KeyboardPlatformHookWidget::keyPressEvent(QKeyEvent* event) void KeyboardPlatformHookWidget::keyPressEvent(QKeyEvent* event)
{ {
switch (event->key()) switch (event->key())
...@@ -374,6 +378,7 @@ void KeyboardPlatformHookWidget::keyPressEvent(QKeyEvent* event) ...@@ -374,6 +378,7 @@ void KeyboardPlatformHookWidget::keyPressEvent(QKeyEvent* event)
QWidget::keyPressEvent(event); QWidget::keyPressEvent(event);
} }
void KeyboardPlatformHookWidget::keyReleaseEvent(QKeyEvent* event) void KeyboardPlatformHookWidget::keyReleaseEvent(QKeyEvent* event)
{ {
switch (event->key()) switch (event->key())
...@@ -392,6 +397,7 @@ void KeyboardPlatformHookWidget::keyReleaseEvent(QKeyEvent* event) ...@@ -392,6 +397,7 @@ void KeyboardPlatformHookWidget::keyReleaseEvent(QKeyEvent* event)
QWidget::keyReleaseEvent(event); QWidget::keyReleaseEvent(event);
} }
void armarx::PlatformUnitWidget::reportPlatformOdometryPose(Ice::Float, Ice::Float, Ice::Float, const Ice::Current&) void armarx::PlatformUnitWidget::reportPlatformOdometryPose(Ice::Float, Ice::Float, Ice::Float, const Ice::Current&)
{ {
// ignore for now // ignore for now
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment