};///< The possible states for the waypoint protocol
public:
UASWaypointManager(UAS&);///< Standard constructor.
UASWaypointManager(UAS*uas=NULL);///< Standard constructor
/** @name Received message handlers */
/*@{*/
...
...
@@ -79,15 +79,20 @@ public:
/** @name Remote operations */
/*@{*/
voidclearWaypointList();///< Sends the waypoint clear all message to the MAV
voidreadWaypoints();///< Requests the MAV's current waypoint list
voidreadWaypoints(boolread_to_edit=false);///< Requests the MAV's current waypoint list.
voidwriteWaypoints();///< Sends the waypoint list to the MAV
intsetCurrentWaypoint(quint16seq);///< Changes the current waypoint and sends the sequence number of the waypoint that should get the new target waypoint to the UAS
intsetCurrentWaypoint(quint16seq);///< Sends the sequence number of the waypoint that should get the new target waypoint to the UAS
intsetCurrentEditable(quint16seq);///< Changes the current waypoint in edit tab
/*@}*/
/** @name Waypoint list operations */
/*@{*/
constQVector<Waypoint*>&getWaypointList(void){
returnwaypoints;///< Returns a const reference to the waypoint list.
returnwaypointsViewOnly;///< Returns a const reference to the waypoint list.
}
constQVector<Waypoint*>getGlobalFrameWaypointList();///< Returns a global waypoint list
constQVector<Waypoint*>getGlobalFrameAndNavTypeWaypointList();///< Returns a global waypoint list containing only waypoints suitable for navigation. Actions and other mission items are filtered out.
...
...
@@ -104,7 +109,7 @@ public:
intgetLocalFrameCount();///< Get the count of local waypoints in the list
/*@}*/
UAS&getUAS(){
UAS*getUAS(){
returnthis->uas;///< Returns the owning UAS
}
...
...
@@ -124,21 +129,26 @@ public slots:
voidtimeout();///< Called by the timer if a response times out. Handles send retries.
/** @name Waypoint list operations */
/*@{*/
voidaddWaypoint(Waypoint*wp,boolenforceFirstActive=true);///< adds a new waypoint to the end of the list and changes its sequence number accordingly
voidaddWaypointEditable(Waypoint*wp,boolenforceFirstActive=true);///< adds a new waypoint to the end of the editable list and changes its sequence number accordingly
voidaddWaypointViewOnly(Waypoint*wp);///< adds a new waypoint to the end of the view-only list and changes its sequence number accordingly
Waypoint*createWaypoint(boolenforceFirstActive=true);///< Creates a waypoint
intremoveWaypoint(quint16seq);///< locally remove the specified waypoint from the storage
voidmoveWaypoint(quint16cur_seq,quint16new_seq);///< locally move a waypoint from its current position cur_seq to a new position new_seq
voidsaveWaypoints(constQString&saveFile);///< saves the local waypoint list to saveFile
voidloadWaypoints(constQString&loadFile);///< loads a waypoint list from loadFile
voidnotifyOfChange(Waypoint*wp);///< Notifies manager to changes to a waypoint
voidnotifyOfChangeEditable(Waypoint*wp);///< Notifies manager to changes to an editable waypoint
voidnotifyOfChangeViewOnly(Waypoint*wp);///< Notifies manager to changes to a viewonly waypoint, e.g. some widget wants to change "current"
voidwaypointListChanged(void);///< emits signal that the waypoint list has been changed
voidwaypointListChanged(intuasid);///< Emits signal that list has been changed
voidwaypointChanged(intuasid,Waypoint*wp);///< emits signal that waypoint has been changed
voidwaypointEditableListChanged(void);///< emits signal that the list of editable waypoints has been changed
voidwaypointEditableListChanged(intuasid);///< emits signal that the list of editable waypoints has been changed
voidwaypointEditableChanged(intuasid,Waypoint*wp);///< emits signal that a single editable waypoint has been changed
voidwaypointViewOnlyListChanged(void);///< emits signal that the list of editable waypoints has been changed
voidwaypointViewOnlyListChanged(intuasid);///< emits signal that the list of editable waypoints has been changed
voidwaypointViewOnlyChanged(intuasid,Waypoint*wp);///< emits signal that a single editable waypoint has been changed
voidcurrentWaypointChanged(quint16);///< emits the new current waypoint sequence number
voidupdateStatusString(constQString&);///< emits the current status string
voidwaypointDistanceChanged(doubledistance);///< Distance to next waypoint changed (in meters)
...
...
@@ -147,18 +157,22 @@ signals:
voidreadGlobalWPFromUAS(boolvalue);///< emits signal when finish to read Global WP from UAS
private:
UAS&uas;///< Reference to the corresponding UAS
UAS*uas;///< Reference to the corresponding UAS
quint32current_retries;///< The current number of retries left
quint16current_wp_id;///< The last used waypoint ID in the current protocol transaction
quint16current_count;///< The number of waypoints in the current protocol transaction
WaypointStatecurrent_state;///< The current protocol state
quint8current_partner_systemid;///< The current protocol communication target system
quint8current_partner_compid;///< The current protocol communication target component
boolread_to_edit;///< If true, after readWaypoints() incoming waypoints will be copied both to "edit"-tab and "view"-tab. Otherwise, only to "view"-tab.
QVector<Waypoint*>waypoints;///< local waypoint list (main storage)
Waypoint*currentWaypoint;///< The currently used waypoint
QVector<Waypoint*>waypointsViewOnly;///< local copy of current waypoint list on MAV
QVector<Waypoint*>waypointsEditable;///< local editable waypoint list
Waypoint*currentWaypointEditable;///< The currently used waypoint
QVector<mavlink_mission_item_t*>waypoint_buffer;///< buffer for waypoints during communication
QTimerprotocol_timer;///< Timer to catch timeouts
boolstandalone;///< If standalone is set, do not write to UAS
if(wp->getCurrent()==true)//User clicked on the waypoint, that is already current
{
m_ui->current->setChecked(true);
m_ui->current->setCheckState(Qt::Checked);
}
else
{
m_ui->current->setChecked(false);
m_ui->current->setCheckState(Qt::Unchecked);
wp->setCurrent(false);
}
}
else
{
/*
FIXME: The checkbox should turn gray to indicate, that set_current request has been sent to UAV. It should become blue (checked) after receiving set_current_ack from waypointplanner.
m_ui->current->setStyleSheet("*::indicator { \
border: 1px solid #777777; \
border-radius: 2px; \
color: #999999; \
width: 10px; \
height: 10px; \
}");
*/
wp->setCurrent(true);
emitchangeCurrentWaypoint(wp->getId());//the slot changeCurrentWaypoint() in WaypointList sets all other current flags to false
m_ui->displayBar->setText(QString("Go to <b>(%1, %2, %3)</b> and wait there for %4 sec; yaw: %5; rad: %6").arg(wp->getX()).arg(wp->getY()).arg(wp->getZ()).arg(wp->getParam1()).arg(wp->getParam4()).arg(wp->getParam2()));
}
else
{
m_ui->displayBar->setText(QString("Go to <b>(%1, %2, %3)</b>; yaw: %4; rad: %5").arg(wp->getX()).arg(wp->getY()).arg(wp->getZ()).arg(wp->getParam4()).arg(wp->getParam2()));
}
break;
}
caseMAV_CMD_NAV_LAND:
{
m_ui->displayBar->setText(QString("LAND. Go to (%1, %2, %3) and descent; yaw: %4").arg(wp->getX()).arg(wp->getY()).arg(wp->getZ()).arg(wp->getParam4()));
break;
}
caseMAV_CMD_NAV_TAKEOFF:
{
m_ui->displayBar->setText(QString("TAKEOFF. Go to (%1, %2, %3); yaw: %4").arg(wp->getX()).arg(wp->getY()).arg(wp->getZ()).arg(wp->getParam4()));
break;
}
caseMAV_CMD_DO_JUMP:
{
if(wp->getParam2()>0)
{
m_ui->displayBar->setText(QString("Jump to waypoint %1. Jumps left: %2").arg(wp->getParam1()).arg(wp->getParam2()));
}
else
{
m_ui->displayBar->setText(QString("No jumps left. Proceed to next waypoint."));
m_ui->displayBar->setText(QString("Start searching for pattern. Success when got more than %2 detections with confidence %1").arg(wp->getParam1()).arg(wp->getParam2()));
break;
}
case238://MAV_CMD_DO_FINISH_SEARCH
{
m_ui->displayBar->setText(QString("Check if search was successful. yes -> jump to %1, no -> jump to %2. Jumps left: %3").arg(wp->getParam1()).arg(wp->getParam2()).arg(wp->getParam3()));
break;
}
case240://MAV_CMD_DO_SWEEP
{
m_ui->displayBar->setText(QString("Sweep. Corners: (%1,%2) and (%3,%4); z: %5; scan radius: %6").arg(wp->getParam3()).arg(wp->getParam4()).arg(wp->getParam5()).arg(wp->getParam6()).arg(wp->getParam7()).arg(wp->getParam1()));