Commit 15954fd5 authored by pixhawk's avatar pixhawk

Last setpoint fixes

parent 7490ed51
......@@ -2095,7 +2095,7 @@ void UAS::halt()
{
mavlink_message_t msg;
// TODO Replace MG System ID with static function call and allow to change ID in GUI
mavlink_msg_action_pack(MG::SYSTEM::ID, MG::SYSTEM::COMPID, &msg, this->getUASID(), MAV_COMP_ID_IMU, (int)MAV_ACTION_HALT);
mavlink_msg_action_pack(MG::SYSTEM::ID, MG::SYSTEM::COMPID, &msg, this->getUASID(), MAV_COMP_ID_IMU, (int)MAV_ACTION_HOLD);
// Send message twice to increase chance of reception
sendMessage(msg);
sendMessage(msg);
......
......@@ -103,7 +103,8 @@ HSIDisplay::HSIDisplay(QWidget *parent) :
userSetPointSet(false),
dragStarted(false),
leftDragStarted(false),
mouseHasMoved(false)
mouseHasMoved(false),
actionPending(false)
{
refreshTimer->setInterval(updateInterval);
......@@ -568,10 +569,10 @@ void HSIDisplay::mouseReleaseEvent(QMouseEvent * event)
{
if (leftDragStarted)
{
qDebug() << "Z CHANGED" << uiZSetCoordinate;
setStatusMessage(QString("SENT NEW Z: %1").arg(uiZSetCoordinate));
setBodySetpointCoordinateZ(uiZSetCoordinate);
leftDragStarted = false;
// qDebug() << "Z CHANGED" << uiZSetCoordinate;
// setStatusMessage(QString("SENT NEW Z: %1").arg(uiZSetCoordinate));
// setBodySetpointCoordinateZ(uiZSetCoordinate);
// leftDragStarted = false;
}
}
}
......@@ -606,14 +607,29 @@ void HSIDisplay::mouseMoveEvent(QMouseEvent * event)
if (leftDragStarted)
{
uiZSetCoordinate -= 0.06f*(startY - event->y()) / this->frameSize().height();
setStatusMessage(QString("NEW Z: %1").arg(uiZSetCoordinate));
// uiZSetCoordinate -= 0.06f*(startY - event->y()) / this->frameSize().height();
// setStatusMessage(QString("NEW Z: %1").arg(uiZSetCoordinate));
}
if (leftDragStarted || dragStarted) mouseHasMoved = true;
}
}
void HSIDisplay::keyPressEvent(QKeyEvent* event)
{
if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_S)
{
actionPending = false;
statusMessage = "SETPOINT SENT";
statusClearTimer.start();
sendBodySetPointCoordinates();
}
else
{
HDDisplay::keyPressEvent(event);
}
}
void HSIDisplay::contextMenuEvent (QContextMenuEvent* event)
{
event->ignore();
......@@ -703,7 +719,10 @@ void HSIDisplay::setBodySetpointCoordinateXY(double x, double y)
if (uas && mavInitialized)
{
sendBodySetPointCoordinates();
//sendBodySetPointCoordinates();
statusMessage = "POSITION SET, PRESS <ENTER> TO SEND";
actionPending = true;
statusClearTimer.start();
qDebug() << "Setting new setpoint at x: " << x << "metric y:" << y;
}
}
......@@ -713,7 +732,10 @@ void HSIDisplay::setBodySetpointCoordinateZ(double z)
userSetPointSet = true;
// Set coordinates and send them out to MAV
uiZSetCoordinate = z;
sendBodySetPointCoordinates();
statusMessage = "Z SET, PRESS <ENTER> TO SEND";
actionPending = true;
statusClearTimer.start();
//sendBodySetPointCoordinates();
}
void HSIDisplay::setBodySetpointCoordinateYaw(double yaw)
......@@ -733,7 +755,10 @@ void HSIDisplay::setBodySetpointCoordinateYaw(double yaw)
// Set coordinates and send them out to MAV
uiYawSet = atan2(sin(yaw), cos(yaw));
qDebug() << "YAW IN" << yaw << "YAW OUT" << uiYawSet;
sendBodySetPointCoordinates();
statusMessage = "YAW SET, PRESS <ENTER> TO SEND";
statusClearTimer.start();
actionPending = true;
//sendBodySetPointCoordinates();
}
void HSIDisplay::sendBodySetPointCoordinates()
......@@ -791,7 +816,7 @@ void HSIDisplay::updatePositionSetpoints(int uasid, float xDesired, float yDesir
{
uiXSetCoordinate = bodyXSetCoordinate;
uiYSetCoordinate = bodyYSetCoordinate;
uiZSetCoordinate = bodyZSetCoordinate;
// uiZSetCoordinate = bodyZSetCoordinate;
uiYawSet= bodyYawSet;
}
}
......
......@@ -89,6 +89,7 @@ public slots:
void clearStatusMessage()
{
statusMessage = "";
actionPending = false;
}
signals:
......@@ -123,6 +124,8 @@ protected slots:
void mouseMoveEvent(QMouseEvent * event);
/** @brief Receive mouse wheel events */
void wheelEvent(QWheelEvent* event);
/** @brief Read out send keys */
void keyPressEvent(QKeyEvent* event);
/** @brief Ignore context menu event */
void contextMenuEvent (QContextMenuEvent* event);
/** @brief Set status message on screen */
......@@ -166,6 +169,7 @@ protected:
float startY;
QTimer statusClearTimer;
QString statusMessage;
bool actionPending;
/**
* @brief Private data container class to be used within the HSI widget
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment