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
17bd4fa3
Commit
17bd4fa3
authored
Aug 16, 2010
by
pixhawk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleaned up the code
parent
d94341d9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
95 additions
and
95 deletions
+95
-95
WaypointList.cc
src/ui/WaypointList.cc
+76
-84
WaypointList.h
src/ui/WaypointList.h
+19
-11
No files found.
src/ui/WaypointList.cc
View file @
17bd4fa3
...
...
@@ -91,11 +91,6 @@ WaypointList::~WaypointList()
delete
m_ui
;
}
void
WaypointList
::
updateStatusLabel
(
const
QString
&
string
)
{
m_ui
->
statusLabel
->
setText
(
string
);
}
void
WaypointList
::
updateLocalPosition
(
UASInterface
*
uas
,
double
x
,
double
y
,
double
z
,
quint64
usec
)
{
Q_UNUSED
(
uas
);
...
...
@@ -129,17 +124,86 @@ void WaypointList::setUAS(UASInterface* uas)
}
}
void
WaypointList
::
waypointReached
(
quint16
waypointId
)
void
WaypointList
::
saveWaypoints
()
{
if
(
uas
)
{
QString
fileName
=
QFileDialog
::
getSaveFileName
(
this
,
tr
(
"Save File"
),
"./waypoints.txt"
,
tr
(
"Waypoint File (*.txt)"
));
uas
->
getWaypointManager
().
localSaveWaypoints
(
fileName
);
}
}
void
WaypointList
::
loadWaypoints
()
{
if
(
uas
)
{
QString
fileName
=
QFileDialog
::
getOpenFileName
(
this
,
tr
(
"Load File"
),
"."
,
tr
(
"Waypoint File (*.txt)"
));
uas
->
getWaypointManager
().
localLoadWaypoints
(
fileName
);
}
}
void
WaypointList
::
transmit
()
{
if
(
uas
)
{
uas
->
getWaypointManager
().
writeWaypoints
();
}
}
void
WaypointList
::
read
()
{
if
(
uas
)
{
uas
->
getWaypointManager
().
readWaypoints
();
}
}
void
WaypointList
::
add
()
{
if
(
uas
)
{
const
QVector
<
Waypoint
*>
&
waypoints
=
uas
->
getWaypointManager
().
getWaypointList
();
if
(
waypoints
.
size
()
>
0
)
{
Waypoint
*
last
=
waypoints
.
at
(
waypoints
.
size
()
-
1
);
Waypoint
*
wp
=
new
Waypoint
(
0
,
last
->
getX
(),
last
->
getY
(),
last
->
getZ
(),
last
->
getYaw
(),
last
->
getAutoContinue
(),
false
,
last
->
getOrbit
(),
last
->
getHoldTime
());
uas
->
getWaypointManager
().
localAddWaypoint
(
wp
);
}
else
{
Waypoint
*
wp
=
new
Waypoint
(
0
,
1.1
,
1.1
,
-
0.8
,
0.0
,
true
,
true
,
0.15
,
2000
);
uas
->
getWaypointManager
().
localAddWaypoint
(
wp
);
}
}
}
void
WaypointList
::
addCurrentPositonWaypoint
()
{
if
(
this
->
uas
)
if
(
uas
)
{
updateStatusLabel
(
QString
(
"Waypoint %1 reached."
).
arg
(
waypointId
));
const
QVector
<
Waypoint
*>
&
waypoints
=
uas
->
getWaypointManager
().
getWaypointList
();
if
(
waypoints
.
size
()
>
0
)
{
Waypoint
*
last
=
waypoints
.
at
(
waypoints
.
size
()
-
1
);
Waypoint
*
wp
=
new
Waypoint
(
0
,
(
qRound
(
mavX
*
100
))
/
100.
,
(
qRound
(
mavY
*
100
))
/
100.
,
(
qRound
(
mavZ
*
100
))
/
100.
,
(
qRound
(
mavYaw
*
100
))
/
100.
,
last
->
getAutoContinue
(),
false
,
last
->
getOrbit
(),
last
->
getHoldTime
());
uas
->
getWaypointManager
().
localAddWaypoint
(
wp
);
}
else
{
Waypoint
*
wp
=
new
Waypoint
(
0
,
(
qRound
(
mavX
*
100
))
/
100.
,
(
qRound
(
mavY
*
100
))
/
100.
,
(
qRound
(
mavZ
*
100
))
/
100.
,
(
qRound
(
mavYaw
*
100
))
/
100.
,
true
,
true
,
0.15
,
2000
);
uas
->
getWaypointManager
().
localAddWaypoint
(
wp
);
}
}
}
void
WaypointList
::
updateStatusLabel
(
const
QString
&
string
)
{
m_ui
->
statusLabel
->
setText
(
string
);
}
void
WaypointList
::
changeCurrentWaypoint
(
quint16
seq
)
{
if
(
this
->
uas
)
if
(
uas
)
{
uas
->
getWaypointManager
().
setCurrentWaypoint
(
seq
);
}
...
...
@@ -147,7 +211,7 @@ void WaypointList::changeCurrentWaypoint(quint16 seq)
void
WaypointList
::
currentWaypointChanged
(
quint16
seq
)
{
if
(
this
->
uas
)
if
(
uas
)
{
const
QVector
<
Waypoint
*>
&
waypoints
=
uas
->
getWaypointManager
().
getWaypointList
();
...
...
@@ -172,7 +236,7 @@ void WaypointList::currentWaypointChanged(quint16 seq)
void
WaypointList
::
waypointListChanged
()
{
if
(
this
->
uas
)
if
(
uas
)
{
const
QVector
<
Waypoint
*>
&
waypoints
=
uas
->
getWaypointManager
().
getWaypointList
();
...
...
@@ -203,6 +267,7 @@ void WaypointList::waypointListChanged()
}
}
// then add/update the views for each waypoint in the list
for
(
int
i
=
0
;
i
<
waypoints
.
size
();
i
++
)
{
Waypoint
*
wp
=
waypoints
[
i
];
...
...
@@ -224,61 +289,6 @@ void WaypointList::waypointListChanged()
}
}
void
WaypointList
::
read
()
{
if
(
uas
)
{
uas
->
getWaypointManager
().
readWaypoints
();
}
}
void
WaypointList
::
transmit
()
{
if
(
uas
)
{
uas
->
getWaypointManager
().
writeWaypoints
();
}
}
void
WaypointList
::
add
()
{
// Only add waypoints if UAS is present
if
(
uas
)
{
const
QVector
<
Waypoint
*>
&
waypoints
=
uas
->
getWaypointManager
().
getWaypointList
();
if
(
waypoints
.
size
()
>
0
)
{
Waypoint
*
last
=
waypoints
.
at
(
waypoints
.
size
()
-
1
);
Waypoint
*
wp
=
new
Waypoint
(
0
,
last
->
getX
(),
last
->
getY
(),
last
->
getZ
(),
last
->
getYaw
(),
last
->
getAutoContinue
(),
false
,
last
->
getOrbit
(),
last
->
getHoldTime
());
uas
->
getWaypointManager
().
localAddWaypoint
(
wp
);
}
else
{
Waypoint
*
wp
=
new
Waypoint
(
0
,
1.1
,
1.1
,
-
0.8
,
0.0
,
true
,
true
,
0.15
,
2000
);
uas
->
getWaypointManager
().
localAddWaypoint
(
wp
);
}
}
}
void
WaypointList
::
addCurrentPositonWaypoint
()
{
if
(
uas
)
{
const
QVector
<
Waypoint
*>
&
waypoints
=
uas
->
getWaypointManager
().
getWaypointList
();
if
(
waypoints
.
size
()
>
0
)
{
Waypoint
*
last
=
waypoints
.
at
(
waypoints
.
size
()
-
1
);
Waypoint
*
wp
=
new
Waypoint
(
0
,
(
qRound
(
mavX
*
100
))
/
100.
,
(
qRound
(
mavY
*
100
))
/
100.
,
(
qRound
(
mavZ
*
100
))
/
100.
,
(
qRound
(
mavYaw
*
100
))
/
100.
,
last
->
getAutoContinue
(),
false
,
last
->
getOrbit
(),
last
->
getHoldTime
());
uas
->
getWaypointManager
().
localAddWaypoint
(
wp
);
}
else
{
Waypoint
*
wp
=
new
Waypoint
(
0
,
(
qRound
(
mavX
*
100
))
/
100.
,
(
qRound
(
mavY
*
100
))
/
100.
,
(
qRound
(
mavZ
*
100
))
/
100.
,
(
qRound
(
mavYaw
*
100
))
/
100.
,
true
,
true
,
0.15
,
2000
);
uas
->
getWaypointManager
().
localAddWaypoint
(
wp
);
}
}
}
void
WaypointList
::
moveUp
(
Waypoint
*
wp
)
{
if
(
uas
)
...
...
@@ -342,21 +352,3 @@ void WaypointList::changeEvent(QEvent *e)
}
}
void
WaypointList
::
saveWaypoints
()
{
if
(
uas
)
{
QString
fileName
=
QFileDialog
::
getSaveFileName
(
this
,
tr
(
"Save File"
),
"./waypoints.txt"
,
tr
(
"Waypoint File (*.txt)"
));
uas
->
getWaypointManager
().
localSaveWaypoints
(
fileName
);
}
}
void
WaypointList
::
loadWaypoints
()
{
if
(
uas
)
{
QString
fileName
=
QFileDialog
::
getOpenFileName
(
this
,
tr
(
"Load File"
),
"."
,
tr
(
"Waypoint File (*.txt)"
));
uas
->
getWaypointManager
().
localLoadWaypoints
(
fileName
);
}
}
src/ui/WaypointList.h
View file @
17bd4fa3
...
...
@@ -54,31 +54,39 @@ class WaypointList : public QWidget {
virtual
~
WaypointList
();
public
slots
:
void
updateLocalPosition
(
UASInterface
*
,
double
x
,
double
y
,
double
z
,
quint64
usec
);
void
updateAttitude
(
UASInterface
*
,
double
roll
,
double
pitch
,
double
yaw
,
quint64
usec
);
void
setUAS
(
UASInterface
*
uas
);
//UI Buttons
//Waypoint list operations
/** @brief Save the local waypoint list to a file */
void
saveWaypoints
();
/** @brief Load a waypoint list from a file */
void
loadWaypoints
();
/** @brief Transmit the local waypoint list to the UAS */
void
transmit
();
/** @brief Read the remote waypoint list */
void
read
();
/** @brief Add a waypoint */
void
add
();
/** @brief Add a waypoint at the current MAV position */
void
addCurrentPositonWaypoint
();
void
moveUp
(
Waypoint
*
wp
);
void
moveDown
(
Waypoint
*
wp
);
//Update events
/** @brief sets statusLabel string */
void
updateStatusLabel
(
const
QString
&
string
);
void
changeCurrentWaypoint
(
quint16
seq
);
///< The user wants to change the current waypoint
void
currentWaypointChanged
(
quint16
seq
);
///< The waypoint planner changed the current waypoint
void
waypointListChanged
(
void
);
///< The waypoint manager informs that the waypoint list was changed
/** @brief The user wants to change the current waypoint */
void
changeCurrentWaypoint
(
quint16
seq
);
/** @brief The waypoint planner changed the current waypoint */
void
currentWaypointChanged
(
quint16
seq
);
/** @brief The waypoint manager informs that the waypoint list was changed */
void
waypointListChanged
(
void
);
// Waypoint operations
void
moveUp
(
Waypoint
*
wp
);
void
moveDown
(
Waypoint
*
wp
);
void
removeWaypoint
(
Waypoint
*
wp
);
void
waypointReached
(
quint16
waypointId
);
void
updateLocalPosition
(
UASInterface
*
,
double
x
,
double
y
,
double
z
,
quint64
usec
);
void
updateAttitude
(
UASInterface
*
,
double
roll
,
double
pitch
,
double
yaw
,
quint64
usec
);
protected:
virtual
void
changeEvent
(
QEvent
*
e
);
...
...
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