Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
55ae8c09
Commit
55ae8c09
authored
Jun 17, 2010
by
pixhawk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
waypoints working
parent
d09ed967
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
255 additions
and
115 deletions
+255
-115
UAS.cc
src/uas/UAS.cc
+13
-3
UASWaypointManager.cc
src/uas/UASWaypointManager.cc
+75
-11
UASWaypointManager.h
src/uas/UASWaypointManager.h
+38
-4
WaypointList.cc
src/ui/WaypointList.cc
+23
-62
WaypointList.h
src/ui/WaypointList.h
+7
-11
WaypointView.cc
src/ui/WaypointView.cc
+33
-12
WaypointView.h
src/ui/WaypointView.h
+7
-7
WaypointView.ui
src/ui/WaypointView.ui
+59
-5
No files found.
src/uas/UAS.cc
View file @
55ae8c09
...
@@ -449,11 +449,20 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message)
...
@@ -449,11 +449,20 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message)
case
MAVLINK_MSG_ID_WAYPOINT_REACHED
:
case
MAVLINK_MSG_ID_WAYPOINT_REACHED
:
{
{
// mavlink_waypoint_reached_t wp
;
mavlink_waypoint_reached_t
wpr
;
// mavlink_msg_waypoint_reached_decode(&message, &wp
);
mavlink_msg_waypoint_reached_decode
(
&
message
,
&
wpr
);
// emit waypointReached(this, wp.id
);
waypointManager
.
handleWaypointReached
(
message
.
sysid
,
message
.
compid
,
&
wpr
);
}
}
break
;
break
;
case
MAVLINK_MSG_ID_WAYPOINT_SET_CURRENT
:
{
mavlink_waypoint_set_current_t
wpsc
;
mavlink_msg_waypoint_set_current_decode
(
&
message
,
&
wpsc
);
waypointManager
.
handleWaypointSetCurrent
(
message
.
sysid
,
message
.
compid
,
&
wpsc
);
}
break
;
case
MAVLINK_MSG_ID_LOCAL_POSITION_SETPOINT
:
case
MAVLINK_MSG_ID_LOCAL_POSITION_SETPOINT
:
{
{
mavlink_local_position_setpoint_t
p
;
mavlink_local_position_setpoint_t
p
;
...
@@ -461,6 +470,7 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message)
...
@@ -461,6 +470,7 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message)
emit
positionSetPointsChanged
(
uasId
,
p
.
x
,
p
.
y
,
p
.
z
,
p
.
yaw
,
QGC
::
groundTimeUsecs
());
emit
positionSetPointsChanged
(
uasId
,
p
.
x
,
p
.
y
,
p
.
z
,
p
.
yaw
,
QGC
::
groundTimeUsecs
());
}
}
break
;
break
;
case
MAVLINK_MSG_ID_STATUSTEXT
:
case
MAVLINK_MSG_ID_STATUSTEXT
:
{
{
QByteArray
b
;
QByteArray
b
;
...
...
src/uas/UASWaypointManager.cc
View file @
55ae8c09
/*=====================================================================
PIXHAWK Micro Air Vehicle Flying Robotics Toolkit
(c) 2009, 2010 PIXHAWK PROJECT <http://pixhawk.ethz.ch>
This file is part of the PIXHAWK project
PIXHAWK is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
PIXHAWK is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with PIXHAWK. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/**
* @file
* @brief Implementation of the waypoint protocol handler
*
* @author Petri Tanskanen <mavteam@student.ethz.ch>
*
*/
#include "UASWaypointManager.h"
#include "UASWaypointManager.h"
#include "UAS.h"
#include "UAS.h"
#define PROTOCOL_TIMEOUT_MS 2000
UASWaypointManager
::
UASWaypointManager
(
UAS
&
_uas
)
UASWaypointManager
::
UASWaypointManager
(
UAS
&
_uas
)
:
uas
(
_uas
),
:
uas
(
_uas
),
current_wp_id
(
0
),
current_wp_id
(
0
),
current_count
(
0
),
current_count
(
0
),
current_state
(
WP_IDLE
),
current_state
(
WP_IDLE
),
current_partner_systemid
(
0
),
current_partner_systemid
(
0
),
current_partner_compid
(
0
)
current_partner_compid
(
0
),
protocol_timer
(
this
)
{
connect
(
&
protocol_timer
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
timeout
()));
}
void
UASWaypointManager
::
timeout
()
{
{
protocol_timer
.
stop
();
qDebug
()
<<
"Waypoint transaction (state="
<<
current_state
<<
") timed out going to state WP_IDLE"
;
emit
updateStatusString
(
"Operation timed out."
);
current_state
=
WP_IDLE
;
current_count
=
0
;
current_wp_id
=
0
;
current_partner_systemid
=
0
;
current_partner_compid
=
0
;
}
}
void
UASWaypointManager
::
handleWaypointCount
(
quint8
systemId
,
quint8
compId
,
quint16
count
)
void
UASWaypointManager
::
handleWaypointCount
(
quint8
systemId
,
quint8
compId
,
quint16
count
)
{
{
protocol_timer
.
start
(
PROTOCOL_TIMEOUT_MS
);
if
(
current_state
==
WP_GETLIST
&&
systemId
==
current_partner_systemid
&&
compId
==
current_partner_compid
)
if
(
current_state
==
WP_GETLIST
&&
systemId
==
current_partner_systemid
&&
compId
==
current_partner_compid
)
{
{
qDebug
()
<<
"got waypoint count ("
<<
count
<<
") from ID "
<<
systemId
;
qDebug
()
<<
"got waypoint count ("
<<
count
<<
") from ID "
<<
systemId
;
...
@@ -35,6 +87,8 @@ void UASWaypointManager::handleWaypointCount(quint8 systemId, quint8 compId, qui
...
@@ -35,6 +87,8 @@ void UASWaypointManager::handleWaypointCount(quint8 systemId, quint8 compId, qui
void
UASWaypointManager
::
handleWaypoint
(
quint8
systemId
,
quint8
compId
,
mavlink_waypoint_t
*
wp
)
void
UASWaypointManager
::
handleWaypoint
(
quint8
systemId
,
quint8
compId
,
mavlink_waypoint_t
*
wp
)
{
{
protocol_timer
.
start
(
PROTOCOL_TIMEOUT_MS
);
if
(
systemId
==
current_partner_systemid
&&
compId
==
current_partner_compid
&&
current_state
==
WP_GETLIST_GETWPS
&&
wp
->
seq
==
current_wp_id
)
if
(
systemId
==
current_partner_systemid
&&
compId
==
current_partner_compid
&&
current_state
==
WP_GETLIST_GETWPS
&&
wp
->
seq
==
current_wp_id
)
{
{
if
(
wp
->
seq
==
current_wp_id
)
if
(
wp
->
seq
==
current_wp_id
)
...
@@ -58,6 +112,7 @@ void UASWaypointManager::handleWaypoint(quint8 systemId, quint8 compId, mavlink_
...
@@ -58,6 +112,7 @@ void UASWaypointManager::handleWaypoint(quint8 systemId, quint8 compId, mavlink_
current_partner_systemid
=
0
;
current_partner_systemid
=
0
;
current_partner_compid
=
0
;
current_partner_compid
=
0
;
protocol_timer
.
stop
();
emit
updateStatusString
(
"done."
);
emit
updateStatusString
(
"done."
);
qDebug
()
<<
"got all waypoints from ID "
<<
systemId
;
qDebug
()
<<
"got all waypoints from ID "
<<
systemId
;
...
@@ -72,6 +127,8 @@ void UASWaypointManager::handleWaypoint(quint8 systemId, quint8 compId, mavlink_
...
@@ -72,6 +127,8 @@ void UASWaypointManager::handleWaypoint(quint8 systemId, quint8 compId, mavlink_
void
UASWaypointManager
::
handleWaypointRequest
(
quint8
systemId
,
quint8
compId
,
mavlink_waypoint_request_t
*
wpr
)
void
UASWaypointManager
::
handleWaypointRequest
(
quint8
systemId
,
quint8
compId
,
mavlink_waypoint_request_t
*
wpr
)
{
{
protocol_timer
.
start
(
PROTOCOL_TIMEOUT_MS
);
if
(
systemId
==
current_partner_systemid
&&
compId
==
current_partner_compid
&&
((
current_state
==
WP_SENDLIST
&&
wpr
->
seq
==
0
)
||
(
current_state
==
WP_SENDLIST_SENDWPS
&&
(
wpr
->
seq
==
current_wp_id
||
wpr
->
seq
==
current_wp_id
+
1
))
||
(
current_state
==
WP_IDLE
&&
wpr
->
seq
==
current_count
-
1
)))
if
(
systemId
==
current_partner_systemid
&&
compId
==
current_partner_compid
&&
((
current_state
==
WP_SENDLIST
&&
wpr
->
seq
==
0
)
||
(
current_state
==
WP_SENDLIST_SENDWPS
&&
(
wpr
->
seq
==
current_wp_id
||
wpr
->
seq
==
current_wp_id
+
1
))
||
(
current_state
==
WP_IDLE
&&
wpr
->
seq
==
current_count
-
1
)))
{
{
qDebug
()
<<
"handleWaypointRequest"
;
qDebug
()
<<
"handleWaypointRequest"
;
...
@@ -87,6 +144,7 @@ void UASWaypointManager::handleWaypointRequest(quint8 systemId, quint8 compId, m
...
@@ -87,6 +144,7 @@ void UASWaypointManager::handleWaypointRequest(quint8 systemId, quint8 compId, m
//all waypoints sent, but we still have to wait for a possible rerequest of the last waypoint
//all waypoints sent, but we still have to wait for a possible rerequest of the last waypoint
current_state
=
WP_IDLE
;
current_state
=
WP_IDLE
;
protocol_timer
.
stop
();
emit
updateStatusString
(
"done."
);
emit
updateStatusString
(
"done."
);
qDebug
()
<<
"send all waypoints to ID "
<<
systemId
;
qDebug
()
<<
"send all waypoints to ID "
<<
systemId
;
...
@@ -99,17 +157,24 @@ void UASWaypointManager::handleWaypointRequest(quint8 systemId, quint8 compId, m
...
@@ -99,17 +157,24 @@ void UASWaypointManager::handleWaypointRequest(quint8 systemId, quint8 compId, m
}
}
}
}
void
UASWaypointManager
::
clearWaypointList
(
)
void
UASWaypointManager
::
handleWaypointReached
(
quint8
systemId
,
quint8
compId
,
mavlink_waypoint_reached_t
*
wpr
)
{
{
if
(
systemId
==
uas
.
getUASID
()
&&
compId
==
MAV_COMP_ID_WAYPOINTPLANNER
)
{
emit
updateStatusString
(
QString
(
"Reached waypoint %1"
).
arg
(
wpr
->
seq
));
}
}
}
void
UASWaypointManager
::
currentWaypointChanged
(
quint16
)
void
UASWaypointManager
::
handleWaypointSetCurrent
(
quint8
systemId
,
quint8
compId
,
mavlink_waypoint_set_current_t
*
wpr
)
{
{
if
(
systemId
==
uas
.
getUASID
()
&&
compId
==
MAV_COMP_ID_WAYPOINTPLANNER
)
{
qDebug
()
<<
"new current waypoint"
<<
wpr
->
seq
;
emit
currentWaypointChanged
(
wpr
->
seq
);
}
}
}
void
UASWaypointManager
::
removeWaypointId
(
quint16
)
void
UASWaypointManager
::
clearWaypointList
(
)
{
{
}
}
...
@@ -118,6 +183,8 @@ void UASWaypointManager::requestWaypoints()
...
@@ -118,6 +183,8 @@ void UASWaypointManager::requestWaypoints()
{
{
if
(
current_state
==
WP_IDLE
)
if
(
current_state
==
WP_IDLE
)
{
{
protocol_timer
.
start
(
PROTOCOL_TIMEOUT_MS
);
mavlink_message_t
message
;
mavlink_message_t
message
;
mavlink_waypoint_request_list_t
wprl
;
mavlink_waypoint_request_list_t
wprl
;
...
@@ -145,6 +212,8 @@ void UASWaypointManager::sendWaypoints(const QVector<Waypoint*> &list)
...
@@ -145,6 +212,8 @@ void UASWaypointManager::sendWaypoints(const QVector<Waypoint*> &list)
{
{
if
(
list
.
count
()
>
0
)
if
(
list
.
count
()
>
0
)
{
{
protocol_timer
.
start
(
PROTOCOL_TIMEOUT_MS
);
current_count
=
list
.
count
();
current_count
=
list
.
count
();
current_state
=
WP_SENDLIST
;
current_state
=
WP_SENDLIST
;
current_wp_id
=
0
;
current_wp_id
=
0
;
...
@@ -240,8 +309,3 @@ void UASWaypointManager::sendWaypoint(quint16 seq)
...
@@ -240,8 +309,3 @@ void UASWaypointManager::sendWaypoint(quint16 seq)
qDebug
()
<<
"sent waypoint ("
<<
wp
->
seq
<<
") to ID "
<<
wp
->
target_system
;
qDebug
()
<<
"sent waypoint ("
<<
wp
->
seq
<<
") to ID "
<<
wp
->
target_system
;
}
}
}
}
void
UASWaypointManager
::
waypointChanged
(
Waypoint
*
)
{
}
src/uas/UASWaypointManager.h
View file @
55ae8c09
/*=====================================================================
PIXHAWK Micro Air Vehicle Flying Robotics Toolkit
(c) 2009, 2010 PIXHAWK PROJECT <http://pixhawk.ethz.ch>
This file is part of the PIXHAWK project
PIXHAWK is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
PIXHAWK is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with PIXHAWK. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/**
* @file
* @brief Definition of the waypoint protocol handler
*
* @author Petri Tanskanen <mavteam@student.ethz.ch>
*
*/
#ifndef UASWAYPOINTMANAGER_H
#ifndef UASWAYPOINTMANAGER_H
#define UASWAYPOINTMANAGER_H
#define UASWAYPOINTMANAGER_H
#include <QObject>
#include <QObject>
#include <QVector>
#include <QVector>
#include <QTimer>
#include "Waypoint.h"
#include "Waypoint.h"
#include <mavlink.h>
#include <mavlink.h>
class
UAS
;
class
UAS
;
...
@@ -25,22 +57,23 @@ public:
...
@@ -25,22 +57,23 @@ public:
void
handleWaypointCount
(
quint8
systemId
,
quint8
compId
,
quint16
count
);
void
handleWaypointCount
(
quint8
systemId
,
quint8
compId
,
quint16
count
);
void
handleWaypoint
(
quint8
systemId
,
quint8
compId
,
mavlink_waypoint_t
*
wp
);
void
handleWaypoint
(
quint8
systemId
,
quint8
compId
,
mavlink_waypoint_t
*
wp
);
void
handleWaypointRequest
(
quint8
systemId
,
quint8
compId
,
mavlink_waypoint_request_t
*
wpr
);
void
handleWaypointRequest
(
quint8
systemId
,
quint8
compId
,
mavlink_waypoint_request_t
*
wpr
);
void
handleWaypointReached
(
quint8
systemId
,
quint8
compId
,
mavlink_waypoint_reached_t
*
wpr
);
void
handleWaypointSetCurrent
(
quint8
systemId
,
quint8
compId
,
mavlink_waypoint_set_current_t
*
wpr
);
private:
private:
void
sendWaypointRequest
(
quint16
seq
);
void
sendWaypointRequest
(
quint16
seq
);
void
sendWaypoint
(
quint16
seq
);
void
sendWaypoint
(
quint16
seq
);
public
slots
:
public
slots
:
void
timeout
();
void
clearWaypointList
();
void
clearWaypointList
();
void
currentWaypointChanged
(
quint16
);
void
removeWaypointId
(
quint16
);
void
requestWaypoints
();
void
requestWaypoints
();
void
sendWaypoints
(
const
QVector
<
Waypoint
*>
&
list
);
void
sendWaypoints
(
const
QVector
<
Waypoint
*>
&
list
);
void
waypointChanged
(
Waypoint
*
);
signals:
signals:
void
waypointUpdated
(
int
,
quint16
,
double
,
double
,
double
,
double
,
bool
,
bool
);
///< Adds a waypoint to the waypoint list widget
void
waypointUpdated
(
int
,
quint16
,
double
,
double
,
double
,
double
,
bool
,
bool
);
///< Adds a waypoint to the waypoint list widget
void
updateStatusString
(
const
QString
&
);
///< updates the current status string
void
currentWaypointChanged
(
quint16
);
///< emits the new current waypoint sequence number
void
updateStatusString
(
const
QString
&
);
///< emits the current status string
private:
private:
UAS
&
uas
;
///< Reference to the corresponding UAS
UAS
&
uas
;
///< Reference to the corresponding UAS
...
@@ -51,6 +84,7 @@ private:
...
@@ -51,6 +84,7 @@ private:
quint8
current_partner_compid
;
///< The current protocol communication target component
quint8
current_partner_compid
;
///< The current protocol communication target component
QVector
<
mavlink_waypoint_t
*>
waypoint_buffer
;
///< communication buffer for waypoints
QVector
<
mavlink_waypoint_t
*>
waypoint_buffer
;
///< communication buffer for waypoints
QTimer
protocol_timer
;
///< Timer to catch timeouts
};
};
#endif // UASWAYPOINTMANAGER_H
#endif // UASWAYPOINTMANAGER_H
src/ui/WaypointList.cc
View file @
55ae8c09
...
@@ -45,8 +45,6 @@ WaypointList::WaypointList(QWidget *parent, UASInterface* uas) :
...
@@ -45,8 +45,6 @@ WaypointList::WaypointList(QWidget *parent, UASInterface* uas) :
{
{
m_ui
->
setupUi
(
this
);
m_ui
->
setupUi
(
this
);
transmitDelay
=
new
QTimer
(
this
);
listLayout
=
new
QVBoxLayout
(
m_ui
->
listWidget
);
listLayout
=
new
QVBoxLayout
(
m_ui
->
listWidget
);
listLayout
->
setSpacing
(
6
);
listLayout
->
setSpacing
(
6
);
listLayout
->
setMargin
(
0
);
listLayout
->
setMargin
(
0
);
...
@@ -73,7 +71,6 @@ WaypointList::WaypointList(QWidget *parent, UASInterface* uas) :
...
@@ -73,7 +71,6 @@ WaypointList::WaypointList(QWidget *parent, UASInterface* uas) :
connect
(
m_ui
->
loadButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
loadWaypoints
()));
connect
(
m_ui
->
loadButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
loadWaypoints
()));
connect
(
UASManager
::
instance
(),
SIGNAL
(
activeUASSet
(
UASInterface
*
)),
this
,
SLOT
(
setUAS
(
UASInterface
*
)));
connect
(
UASManager
::
instance
(),
SIGNAL
(
activeUASSet
(
UASInterface
*
)),
this
,
SLOT
(
setUAS
(
UASInterface
*
)));
connect
(
transmitDelay
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
reenableTransmit
()));
// STATUS LABEL
// STATUS LABEL
updateStatusLabel
(
""
);
updateStatusLabel
(
""
);
...
@@ -97,14 +94,14 @@ void WaypointList::setUAS(UASInterface* uas)
...
@@ -97,14 +94,14 @@ void WaypointList::setUAS(UASInterface* uas)
if
(
this
->
uas
==
NULL
&&
uas
!=
NULL
)
if
(
this
->
uas
==
NULL
&&
uas
!=
NULL
)
{
{
this
->
uas
=
uas
;
this
->
uas
=
uas
;
connect
(
&
uas
->
getWaypointManager
(),
SIGNAL
(
updateStatusString
(
const
QString
&
)),
this
,
SLOT
(
updateStatusLabel
(
const
QString
&
)));
connect
(
&
uas
->
getWaypointManager
(),
SIGNAL
(
waypointUpdated
(
int
,
quint16
,
double
,
double
,
double
,
double
,
bool
,
bool
)),
this
,
SLOT
(
setWaypoint
(
int
,
quint16
,
double
,
double
,
double
,
double
,
bool
,
bool
)));
connect
(
&
uas
->
getWaypointManager
(),
SIGNAL
(
waypointUpdated
(
int
,
quint16
,
double
,
double
,
double
,
double
,
bool
,
bool
)),
this
,
SLOT
(
setWaypoint
(
int
,
quint16
,
double
,
double
,
double
,
double
,
bool
,
bool
)));
//connect(this, SIGNAL(waypointChanged(Waypoint*)), &uas->getWaypointManager(), SLOT(setWaypoint(Waypoint*
)));
connect
(
&
uas
->
getWaypointManager
(),
SIGNAL
(
currentWaypointChanged
(
quint16
)),
this
,
SLOT
(
currentWaypointChanged
(
quint16
)));
//connect(this, SIGNAL(currentWaypointChanged(int)), &uas->getWaypointManager(), SLOT(setWaypointActive(quint16)));
connect
(
this
,
SIGNAL
(
sendWaypoints
(
const
QVector
<
Waypoint
*>
&
)),
&
uas
->
getWaypointManager
(),
SLOT
(
sendWaypoints
(
const
QVector
<
Waypoint
*>
&
)));
connect
(
this
,
SIGNAL
(
sendWaypoints
(
const
QVector
<
Waypoint
*>
&
)),
&
uas
->
getWaypointManager
(),
SLOT
(
sendWaypoints
(
const
QVector
<
Waypoint
*>
&
)));
connect
(
this
,
SIGNAL
(
requestWaypoints
()),
&
uas
->
getWaypointManager
(),
SLOT
(
requestWaypoints
()));
connect
(
this
,
SIGNAL
(
requestWaypoints
()),
&
uas
->
getWaypointManager
(),
SLOT
(
requestWaypoints
()));
connect
(
this
,
SIGNAL
(
clearWaypointList
()),
&
uas
->
getWaypointManager
(),
SLOT
(
clearWaypointList
()));
connect
(
this
,
SIGNAL
(
clearWaypointList
()),
&
uas
->
getWaypointManager
(),
SLOT
(
clearWaypointList
()));
connect
(
&
uas
->
getWaypointManager
(),
SIGNAL
(
updateStatusString
(
const
QString
&
)),
this
,
SLOT
(
updateStatusLabel
(
const
QString
&
)));
}
}
}
}
...
@@ -112,7 +109,6 @@ void WaypointList::setWaypoint(int uasId, quint16 id, double x, double y, double
...
@@ -112,7 +109,6 @@ void WaypointList::setWaypoint(int uasId, quint16 id, double x, double y, double
{
{
if
(
uasId
==
this
->
uas
->
getUASID
())
if
(
uasId
==
this
->
uas
->
getUASID
())
{
{
transmitDelay
->
start
(
1000
);
Waypoint
*
wp
=
new
Waypoint
(
id
,
x
,
y
,
z
,
yaw
,
autocontinue
,
current
);
Waypoint
*
wp
=
new
Waypoint
(
id
,
x
,
y
,
z
,
yaw
,
autocontinue
,
current
);
addWaypoint
(
wp
);
addWaypoint
(
wp
);
}
}
...
@@ -123,34 +119,30 @@ void WaypointList::waypointReached(UASInterface* uas, quint16 waypointId)
...
@@ -123,34 +119,30 @@ void WaypointList::waypointReached(UASInterface* uas, quint16 waypointId)
Q_UNUSED
(
uas
);
Q_UNUSED
(
uas
);
qDebug
()
<<
"Waypoint reached: "
<<
waypointId
;
qDebug
()
<<
"Waypoint reached: "
<<
waypointId
;
/*if (waypoints.size() > waypointId)
updateStatusLabel
(
QString
(
"Waypoint %1 reached."
).
arg
(
waypointId
));
}
void
WaypointList
::
currentWaypointChanged
(
quint16
seq
)
{
if
(
seq
<
waypoints
.
size
())
{
{
if (waypoints[waypointId]->autocontinue == true
)
for
(
int
i
=
0
;
i
<
waypoints
.
size
();
i
++
)
{
{
WaypointView
*
widget
=
wpViews
.
find
(
waypoints
[
i
]).
value
();
for(int i = 0; i < waypoints.size(); i++
)
if
(
waypoints
[
i
]
->
getId
()
==
seq
)
{
{
if (i == waypointId+1)
waypoints
[
i
]
->
setCurrent
(
true
);
{
widget
->
setCurrent
(
true
);
waypoints[i]->current = true;
}
WaypointView* widget = wpViews.find(waypoints[i]).value();
else
widget->setCurrent();
{
}
waypoints
[
i
]
->
setCurrent
(
false
);
else
widget
->
setCurrent
(
false
);
{
if (waypoints[i]->current)
{
waypoints[i]->current = false;
WaypointView* widget = wpViews.find(waypoints[i]).value();
widget->removeCurrentCheck();
}
}
}
}
redrawList();
qDebug() << "NEW WAYPOINT SET";
}
}
}*/
redrawList
();
}
}
}
void
WaypointList
::
read
()
void
WaypointList
::
read
()
...
@@ -165,9 +157,6 @@ void WaypointList::read()
...
@@ -165,9 +157,6 @@ void WaypointList::read()
void
WaypointList
::
transmit
()
void
WaypointList
::
transmit
()
{
{
transmitDelay
->
start
(
1000
);
m_ui
->
transmitButton
->
setEnabled
(
false
);
emit
sendWaypoints
(
waypoints
);
emit
sendWaypoints
(
waypoints
);
//emit requestWaypoints(); FIXME
//emit requestWaypoints(); FIXME
}
}
...
@@ -199,8 +188,7 @@ void WaypointList::addWaypoint(Waypoint* wp)
...
@@ -199,8 +188,7 @@ void WaypointList::addWaypoint(Waypoint* wp)
connect
(
wpview
,
SIGNAL
(
moveDownWaypoint
(
Waypoint
*
)),
this
,
SLOT
(
moveDown
(
Waypoint
*
)));
connect
(
wpview
,
SIGNAL
(
moveDownWaypoint
(
Waypoint
*
)),
this
,
SLOT
(
moveDown
(
Waypoint
*
)));
connect
(
wpview
,
SIGNAL
(
moveUpWaypoint
(
Waypoint
*
)),
this
,
SLOT
(
moveUp
(
Waypoint
*
)));
connect
(
wpview
,
SIGNAL
(
moveUpWaypoint
(
Waypoint
*
)),
this
,
SLOT
(
moveUp
(
Waypoint
*
)));
connect
(
wpview
,
SIGNAL
(
removeWaypoint
(
Waypoint
*
)),
this
,
SLOT
(
removeWaypoint
(
Waypoint
*
)));
connect
(
wpview
,
SIGNAL
(
removeWaypoint
(
Waypoint
*
)),
this
,
SLOT
(
removeWaypoint
(
Waypoint
*
)));
connect
(
wpview
,
SIGNAL
(
setCurrentWaypoint
(
Waypoint
*
)),
this
,
SLOT
(
setCurrentWaypoint
(
Waypoint
*
)));
connect
(
wpview
,
SIGNAL
(
currentWaypointChanged
(
quint16
)),
this
,
SLOT
(
currentWaypointChanged
(
quint16
)));
//connect(wpview, SIGNAL(waypointUpdated(Waypoint*)), this, SIGNAL(waypointChanged(Waypoint*)));
}
}
}
}
...
@@ -292,28 +280,6 @@ void WaypointList::removeWaypoint(Waypoint* wp)
...
@@ -292,28 +280,6 @@ void WaypointList::removeWaypoint(Waypoint* wp)
}
}
}
}
void
WaypointList
::
setCurrentWaypoint
(
Waypoint
*
wp
)
{
for
(
int
i
=
0
;
i
<
waypoints
.
size
();
i
++
)
{
if
(
waypoints
[
i
]
==
wp
)
{
waypoints
[
i
]
->
setCurrent
(
true
);
// Retransmit waypoint
//uas->getWaypointManager().setWaypointActive(i);
}
else
{
if
(
waypoints
[
i
]
->
getCurrent
())
{
waypoints
[
i
]
->
setCurrent
(
false
);
WaypointView
*
widget
=
wpViews
.
find
(
waypoints
[
i
]).
value
();
widget
->
removeCurrentCheck
();
}
}
}
}
void
WaypointList
::
changeEvent
(
QEvent
*
e
)
void
WaypointList
::
changeEvent
(
QEvent
*
e
)
{
{
switch
(
e
->
type
())
{
switch
(
e
->
type
())
{
...
@@ -325,11 +291,6 @@ void WaypointList::changeEvent(QEvent *e)
...
@@ -325,11 +291,6 @@ void WaypointList::changeEvent(QEvent *e)
}
}
}
}
void
WaypointList
::
reenableTransmit
()
{
m_ui
->
transmitButton
->
setEnabled
(
true
);
}
void
WaypointList
::
saveWaypoints
()
void
WaypointList
::
saveWaypoints
()
{
{
QString
fileName
=
QFileDialog
::
getSaveFileName
(
this
,
tr
(
"Save File"
),
"./waypoints.txt"
,
tr
(
"Waypoint File (*.txt)"
));
QString
fileName
=
QFileDialog
::
getSaveFileName
(
this
,
tr
(
"Save File"
),
"./waypoints.txt"
,
tr
(
"Waypoint File (*.txt)"
));
...
...
src/ui/WaypointList.h
View file @
55ae8c09
...
@@ -56,7 +56,6 @@ class WaypointList : public QWidget {
...
@@ -56,7 +56,6 @@ class WaypointList : public QWidget {
public
slots
:
public
slots
:
void
setUAS
(
UASInterface
*
uas
);
void
setUAS
(
UASInterface
*
uas
);
void
redrawList
();
void
redrawList
();
void
reenableTransmit
();
//UI Buttons
//UI Buttons
void
saveWaypoints
();
void
saveWaypoints
();
...
@@ -66,36 +65,33 @@ public slots:
...
@@ -66,36 +65,33 @@ public slots:
void
add
();
void
add
();
void
moveUp
(
Waypoint
*
wp
);
void
moveUp
(
Waypoint
*
wp
);
void
moveDown
(
Waypoint
*
wp
);
void
moveDown
(
Waypoint
*
wp
);
void
setCurrentWaypoint
(
Waypoint
*
wp
);
/** @brief sets statusLabel string */
/** @brief sets statusLabel string */
void
updateStatusLabel
(
const
QString
&
string
);
void
updateStatusLabel
(
const
QString
&
string
);
void
currentWaypointChanged
(
quint16
seq
);
//To be moved to UASWaypointManager (?)
//To be moved to UASWaypointManager (?)
void
setWaypoint
(
int
uasId
,
quint16
id
,
double
x
,
double
y
,
double
z
,
double
yaw
,
bool
autocontinue
,
bool
current
);
void
setWaypoint
(
int
uasId
,
quint16
id
,
double
x
,
double
y
,
double
z
,
double
yaw
,
bool
autocontinue
,
bool
current
);
void
addWaypoint
(
Waypoint
*
wp
);
void
addWaypoint
(
Waypoint
*
wp
);
void
removeWaypoint
(
Waypoint
*
wp
);
void
removeWaypoint
(
Waypoint
*
wp
);
void
waypointReached
(
UASInterface
*
uas
,
quint16
waypointId
);
void
waypointReached
(
UASInterface
*
uas
,
quint16
waypointId
);
signals:
void
sendWaypoints
(
const
QVector
<
Waypoint
*>
&
);
void
requestWaypoints
();
void
clearWaypointList
();
protected:
protected:
virtual
void
changeEvent
(
QEvent
*
e
);
virtual
void
changeEvent
(
QEvent
*
e
);
QVector
<
Waypoint
*>
waypoints
;
QVector
<
Waypoint
*>
waypoints
;
QMap
<
Waypoint
*
,
WaypointView
*>
wpViews
;
QMap
<
Waypoint
*
,
WaypointView
*>
wpViews
;
QVBoxLayout
*
listLayout
;
QVBoxLayout
*
listLayout
;
QTimer
*
transmitDelay
;
UASInterface
*
uas
;
UASInterface
*
uas
;
private:
private:
Ui
::
WaypointList
*
m_ui
;
Ui
::
WaypointList
*
m_ui
;
signals:
//void waypointChanged(Waypoint*);
//void currentWaypointChanged(int);
//void removeWaypointId(int);
void
sendWaypoints
(
const
QVector
<
Waypoint
*>
&
);
void
requestWaypoints
();
void
clearWaypointList
();
};
};
#endif // WAYPOINTLIST_H
#endif // WAYPOINTLIST_H
src/ui/WaypointView.cc
View file @
55ae8c09
...
@@ -34,6 +34,8 @@ This file is part of the PIXHAWK project
...
@@ -34,6 +34,8 @@ This file is part of the PIXHAWK project
#include <QDoubleSpinBox>
#include <QDoubleSpinBox>
#include <QDebug>
#include <QDebug>
#include <cmath> //M_PI
#include "WaypointView.h"
#include "WaypointView.h"
#include "ui_WaypointView.h"
#include "ui_WaypointView.h"
...
@@ -49,7 +51,7 @@ WaypointView::WaypointView(Waypoint* wp, QWidget* parent) :
...
@@ -49,7 +51,7 @@ WaypointView::WaypointView(Waypoint* wp, QWidget* parent) :
m_ui
->
xSpinBox
->
setValue
(
wp
->
getX
());
m_ui
->
xSpinBox
->
setValue
(
wp
->
getX
());
m_ui
->
ySpinBox
->
setValue
(
wp
->
getY
());
m_ui
->
ySpinBox
->
setValue
(
wp
->
getY
());
m_ui
->
zSpinBox
->
setValue
(
wp
->
getZ
());
m_ui
->
zSpinBox
->
setValue
(
wp
->
getZ
());
m_ui
->
yawSpinBox
->
setValue
(
wp
->
getYaw
());
m_ui
->
yawSpinBox
->
setValue
(
wp
->
getYaw
()
/
M_PI
*
180.
);
m_ui
->
selectedBox
->
setChecked
(
wp
->
getCurrent
());
m_ui
->
selectedBox
->
setChecked
(
wp
->
getCurrent
());
m_ui
->
autoContinue
->
setChecked
(
wp
->
getAutoContinue
());
m_ui
->
autoContinue
->
setChecked
(
wp
->
getAutoContinue
());
m_ui
->
idLabel
->
setText
(
QString
(
"%1"
).
arg
(
wp
->
getId
()));
m_ui
->
idLabel
->
setText
(
QString
(
"%1"
).
arg
(
wp
->
getId
()));
...
@@ -57,14 +59,22 @@ WaypointView::WaypointView(Waypoint* wp, QWidget* parent) :
...
@@ -57,14 +59,22 @@ WaypointView::WaypointView(Waypoint* wp, QWidget* parent) :
connect
(
m_ui
->
xSpinBox
,
SIGNAL
(
valueChanged
(
double
)),
wp
,
SLOT
(
setX
(
double
)));
connect
(
m_ui
->
xSpinBox
,
SIGNAL
(
valueChanged
(
double
)),
wp
,
SLOT
(
setX
(
double
)));
connect
(
m_ui
->
ySpinBox
,
SIGNAL
(
valueChanged
(
double
)),
wp
,
SLOT
(
setY
(
double
)));
connect
(
m_ui
->
ySpinBox
,
SIGNAL
(
valueChanged
(
double
)),
wp
,
SLOT
(
setY
(
double
)));
connect
(
m_ui
->
zSpinBox
,
SIGNAL
(
valueChanged
(
double
)),
wp
,
SLOT
(
setZ
(
double
)));
connect
(
m_ui
->
zSpinBox
,
SIGNAL
(
valueChanged
(
double
)),
wp
,
SLOT
(
setZ
(
double
)));
connect
(
m_ui
->
yawSpinBox
,
SIGNAL
(
valueChanged
(
double
)),
wp
,
SLOT
(
setYaw
(
double
)));
//hidden degree to radian conversion of the yaw angle
connect
(
m_ui
->
yawSpinBox
,
SIGNAL
(
valueChanged
(
int
)),
this
,
SLOT
(
setYaw
(
int
)));
connect
(
this
,
SIGNAL
(
setYaw
(
double
)),
wp
,
SLOT
(
setYaw
(
double
)));
connect
(
m_ui
->
upButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
moveUp
()));
connect
(
m_ui
->
upButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
moveUp
()));
connect
(
m_ui
->
downButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
moveDown
()));
connect
(
m_ui
->
downButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
moveDown
()));
connect
(
m_ui
->
removeButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
remove
()));
connect
(
m_ui
->
removeButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
remove
()));
connect
(
m_ui
->
autoContinue
,
SIGNAL
(
stateChanged
(
int
)),
this
,
SLOT
(
setAutoContinue
(
int
)));
connect
(
m_ui
->
autoContinue
,
SIGNAL
(
stateChanged
(
int
)),
this
,
SLOT
(
changedAutoContinue
(
int
)));
connect
(
m_ui
->
selectedBox
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
setCurrent
()));
connect
(
m_ui
->
selectedBox
,
SIGNAL
(
stateChanged
(
int
)),
this
,
SLOT
(
changedCurrent
(
int
)));
}
void
WaypointView
::
setYaw
(
int
yawDegree
)
{
emit
setYaw
((
double
)
yawDegree
*
M_PI
/
180.
);
}
}
void
WaypointView
::
moveUp
()
void
WaypointView
::
moveUp
()
...
@@ -83,26 +93,37 @@ void WaypointView::remove()
...
@@ -83,26 +93,37 @@ void WaypointView::remove()
delete
this
;
delete
this
;
}
}
void
WaypointView
::
set
AutoContinue
(
int
state
)
void
WaypointView
::
changed
AutoContinue
(
int
state
)
{
{
if
(
state
==
0
)
if
(
state
==
0
)
wp
->
setAutocontinue
(
false
);
wp
->
setAutocontinue
(
false
);
else
else
wp
->
setAutocontinue
(
true
);
wp
->
setAutocontinue
(
true
);
emit
waypointUpdated
(
wp
);
}
}
void
WaypointView
::
removeCurrentCheck
(
)
void
WaypointView
::
changedCurrent
(
int
state
)
{
{
m_ui
->
selectedBox
->
setCheckState
(
Qt
::
Unchecked
);
if
(
state
==
0
)
{
wp
->
setCurrent
(
false
);
}
else
{
wp
->
setCurrent
(
true
);
emit
currentWaypointChanged
(
wp
->
getId
());
//the slot currentWayppointChanged() in WaypointList sets all other current flags to false
}
}
}
void
WaypointView
::
setCurrent
()
void
WaypointView
::
setCurrent
(
bool
state
)
{
{
if
(
m_ui
->
selectedBox
->
isChecked
())
if
(
state
)
emit
setCurrentWaypoint
(
wp
);
{
else
m_ui
->
selectedBox
->
setCheckState
(
Qt
::
Checked
);
m_ui
->
selectedBox
->
setCheckState
(
Qt
::
Checked
);
}
else
{
m_ui
->
selectedBox
->
setCheckState
(
Qt
::
Unchecked
);
}
}
}
WaypointView
::~
WaypointView
()
WaypointView
::~
WaypointView
()
...
...
src/ui/WaypointView.h
View file @
55ae8c09
...
@@ -49,15 +49,16 @@ class WaypointView : public QWidget {
...
@@ -49,15 +49,16 @@ class WaypointView : public QWidget {
virtual
~
WaypointView
();
virtual
~
WaypointView
();
public:
public:
void
removeCurrentCheck
(
);
void
setCurrent
(
bool
state
);
public
slots
:
public
slots
:
void
moveUp
();
void
moveUp
();
void
moveDown
();
void
moveDown
();
void
remove
();
void
remove
();
void
setAutoContinue
(
int
);
void
changedAutoContinue
(
int
);
void
setCurrent
();
void
changedCurrent
(
int
);
//void setText();
void
setYaw
(
int
);
//hidden degree to radian conversion
protected:
protected:
virtual
void
changeEvent
(
QEvent
*
e
);
virtual
void
changeEvent
(
QEvent
*
e
);
...
@@ -70,9 +71,8 @@ signals:
...
@@ -70,9 +71,8 @@ signals:
void
moveUpWaypoint
(
Waypoint
*
);
void
moveUpWaypoint
(
Waypoint
*
);
void
moveDownWaypoint
(
Waypoint
*
);
void
moveDownWaypoint
(
Waypoint
*
);
void
removeWaypoint
(
Waypoint
*
);
void
removeWaypoint
(
Waypoint
*
);
void
setCurrentWaypoint
(
Waypoint
*
);
void
currentWaypointChanged
(
quint16
);
void
setWaypointText
(
Waypoint
*
,
QString
);
void
setYaw
(
double
);
void
waypointUpdated
(
Waypoint
*
);
};
};
#endif // WAYPOINTVIEW_H
#endif // WAYPOINTVIEW_H
src/ui/WaypointView.ui
View file @
55ae8c09
...
@@ -180,9 +180,21 @@ QProgressBar::chunk#thrustBar {
...
@@ -180,9 +180,21 @@ QProgressBar::chunk#thrustBar {
</item>
</item>
<item>
<item>
<widget
class=
"QLabel"
name=
"idLabel"
>
<widget
class=
"QLabel"
name=
"idLabel"
>
<property
name=
"minimumSize"
>
<size>
<width>
15
</width>
<height>
0
</height>
</size>
</property>
<property
name=
"toolTip"
>
<string>
Waypoint Sequence Number
</string>
</property>
<property
name=
"text"
>
<property
name=
"text"
>
<string>
TextLabel
</string>
<string>
TextLabel
</string>
</property>
</property>
<property
name=
"alignment"
>
<set>
Qt::AlignCenter
</set>
</property>
</widget>
</widget>
</item>
</item>
<item>
<item>
...
@@ -200,22 +212,40 @@ QProgressBar::chunk#thrustBar {
...
@@ -200,22 +212,40 @@ QProgressBar::chunk#thrustBar {
</item>
</item>
<item>
<item>
<widget
class=
"QDoubleSpinBox"
name=
"xSpinBox"
>
<widget
class=
"QDoubleSpinBox"
name=
"xSpinBox"
>
<property
name=
"toolTip"
>
<string>
Position X coordinate
</string>
</property>
<property
name=
"suffix"
>
<string>
m
</string>
</property>
<property
name=
"minimum"
>
<property
name=
"minimum"
>
<double>
-100000.000000000000000
</double>
<double>
-100000.000000000000000
</double>
</property>
</property>
<property
name=
"maximum"
>
<property
name=
"maximum"
>
<double>
100000.000000000000000
</double>
<double>
100000.000000000000000
</double>
</property>
</property>
<property
name=
"singleStep"
>
<double>
0.050000000000000
</double>
</property>
</widget>
</widget>
</item>
</item>
<item>
<item>
<widget
class=
"QDoubleSpinBox"
name=
"ySpinBox"
>
<widget
class=
"QDoubleSpinBox"
name=
"ySpinBox"
>
<property
name=
"toolTip"
>
<string>
Position Y coordinate
</string>
</property>
<property
name=
"suffix"
>
<string>
m
</string>
</property>
<property
name=
"minimum"
>
<property
name=
"minimum"
>
<double>
-100000.000000000000000
</double>
<double>
-100000.000000000000000
</double>
</property>
</property>
<property
name=
"maximum"
>
<property
name=
"maximum"
>
<double>
100000.000000000000000
</double>
<double>
100000.000000000000000
</double>
</property>
</property>
<property
name=
"singleStep"
>
<double>
0.050000000000000
</double>
</property>
<property
name=
"value"
>
<property
name=
"value"
>
<double>
0.000000000000000
</double>
<double>
0.000000000000000
</double>
</property>
</property>
...
@@ -223,21 +253,36 @@ QProgressBar::chunk#thrustBar {
...
@@ -223,21 +253,36 @@ QProgressBar::chunk#thrustBar {
</item>
</item>
<item>
<item>
<widget
class=
"QDoubleSpinBox"
name=
"zSpinBox"
>
<widget
class=
"QDoubleSpinBox"
name=
"zSpinBox"
>
<property
name=
"toolTip"
>
<string>
Position Z coordinate
</string>
</property>
<property
name=
"suffix"
>
<string>
m
</string>
</property>
<property
name=
"minimum"
>
<property
name=
"minimum"
>
<double>
-100000.000000000000000
</double>
<double>
-100000.000000000000000
</double>
</property>
</property>
<property
name=
"maximum"
>
<property
name=
"maximum"
>
<double>
100000.000000000000000
</double>
<double>
0.000000000000000
</double>
</property>
<property
name=
"singleStep"
>
<double>
0.050000000000000
</double>
</property>
</property>
</widget>
</widget>
</item>
</item>
<item>
<item>
<widget
class=
"QDoubleSpinBox"
name=
"yawSpinBox"
>
<widget
class=
"QSpinBox"
name=
"yawSpinBox"
>
<property
name=
"minimum"
>
<property
name=
"toolTip"
>
<double>
0.000000000000000
</double>
<string>
Yaw angle
</string>
</property>
<property
name=
"wrapping"
>
<bool>
true
</bool>
</property>
<property
name=
"suffix"
>
<string>
°
</string>
</property>
</property>
<property
name=
"maximum"
>
<property
name=
"maximum"
>
<
double>
360.000000000000000
</double
>
<
number>
359
</number
>
</property>
</property>
</widget>
</widget>
</item>
</item>
...
@@ -259,6 +304,9 @@ QProgressBar::chunk#thrustBar {
...
@@ -259,6 +304,9 @@ QProgressBar::chunk#thrustBar {
<height>
22
</height>
<height>
22
</height>
</size>
</size>
</property>
</property>
<property
name=
"toolTip"
>
<string>
Move Up
</string>
</property>
<property
name=
"text"
>
<property
name=
"text"
>
<string/>
<string/>
</property>
</property>
...
@@ -276,6 +324,9 @@ QProgressBar::chunk#thrustBar {
...
@@ -276,6 +324,9 @@ QProgressBar::chunk#thrustBar {
<height>
22
</height>
<height>
22
</height>
</size>
</size>
</property>
</property>
<property
name=
"toolTip"
>
<string>
Move Down
</string>
</property>
<property
name=
"text"
>
<property
name=
"text"
>
<string/>
<string/>
</property>
</property>
...
@@ -293,6 +344,9 @@ QProgressBar::chunk#thrustBar {
...
@@ -293,6 +344,9 @@ QProgressBar::chunk#thrustBar {
<height>
22
</height>
<height>
22
</height>
</size>
</size>
</property>
</property>
<property
name=
"toolTip"
>
<string>
Delete
</string>
</property>
<property
name=
"text"
>
<property
name=
"text"
>
<string/>
<string/>
</property>
</property>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment