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