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
1fe54579
Commit
1fe54579
authored
Mar 09, 2011
by
Mariano Lizarraga
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'experimental' of
git://github.com/amolinap/qgroundcontrol
into experimental
parents
5379a798
b5af9b84
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
158 additions
and
125 deletions
+158
-125
MapWidget.cc
src/ui/MapWidget.cc
+134
-99
MapWidget.h
src/ui/MapWidget.h
+9
-21
SlugsPadCameraControl.ui
src/ui/SlugsPadCameraControl.ui
+4
-1
UASControlParameters.cpp
src/ui/uas/UASControlParameters.cpp
+11
-4
No files found.
src/ui/MapWidget.cc
View file @
1fe54579
...
...
@@ -115,6 +115,11 @@ void MapWidget::init()
lastZoom
=
settings
.
value
(
"LAST_ZOOM"
,
lastZoom
).
toInt
();
settings
.
endGroup
();
settings
.
beginGroup
(
"QGC_HOMEPOSITION"
);
homeCoordinate
.
setY
(
settings
.
value
(
"HOME_LATITUDE"
,
homeCoordinate
.
y
()).
toDouble
());
homeCoordinate
.
setX
(
settings
.
value
(
"HOME_LONGITUDE"
,
homeCoordinate
.
x
()).
toDouble
());
settings
.
endGroup
();
// SET INITIAL POSITION AND ZOOM
// Set default zoom level
mc
->
setZoom
(
lastZoom
);
...
...
@@ -140,6 +145,14 @@ void MapWidget::init()
connect
(
mapproviderGroup
,
SIGNAL
(
triggered
(
QAction
*
)),
this
,
SLOT
(
mapproviderSelected
(
QAction
*
)));
//mapSettings.beginGroup("Map_Widget");
//QAction *act = new QAction(mapSettings.value("QAction").toString(), this);
//mapproviderSelected(act);
//mapSettings.endGroup();
// Overlay seems currently broken
// yahooActionOverlay = new QAction(tr("Yahoo: street overlay"), this);
// yahooActionOverlay->setCheckable(true);
...
...
@@ -230,17 +243,6 @@ void MapWidget::init()
waypointPath
=
new
qmapcontrol
::
LineString
(
wps
,
"Waypoint path"
,
pointPen
);
mc
->
layer
(
"Waypoints"
)
->
addGeometry
(
waypointPath
);
//Camera Control
// CAMERA INDICATOR LAYER
// create a layer with the mapadapter and type GeometryLayer (for camera indicator)
//camLayer = new qmapcontrol::GeometryLayer("Camera", mapadapter);
//mc->addLayer(camLayer);
//camLine = new qmapcontrol::LineString(camPoints,"Camera Eje", camBorderPen);
drawCamBorder
=
false
;
radioCamera
=
10
;
// Done set state
initialized
=
true
;
...
...
@@ -288,10 +290,49 @@ void MapWidget::init()
connect
(
geomLayer
,
SIGNAL
(
geometryEndDrag
(
Geometry
*
,
QPointF
)),
this
,
SLOT
(
captureGeometryEndDrag
(
Geometry
*
,
QPointF
)));
connect
(
homePosition
,
SIGNAL
(
geometryClicked
(
Geometry
*
,
QPoint
)),
this
,
SLOT
(
captureGeometryClick
(
Geometry
*
,
QPoint
)));
connect
(
homePosition
,
SIGNAL
(
geometryDragged
(
Geometry
*
,
QPointF
)),
this
,
SLOT
(
captureGeometryDragHome
(
Geometry
*
,
QPointF
)));
connect
(
homePosition
,
SIGNAL
(
geometryEndDrag
(
Geometry
*
,
QPointF
)),
this
,
SLOT
(
captureGeometryEndDrag
(
Geometry
*
,
QPointF
)));
this
->
loadSettingsMap
(
settings
);
this
->
createHomePosition
(
homeCoordinate
);
qDebug
()
<<
"CHECK END"
;
}
}
void
MapWidget
::
loadSettingsMap
(
QSettings
&
settings
)
{
index
=
0
;
settings
.
beginGroup
(
"QGC_MAPINDEX"
);
index
=
settings
.
value
(
"MAP_INDEX"
,
index
).
toInt
();
settings
.
endGroup
();
switch
(
index
)
{
case
0
:
mapproviderSelected
(
osmAction
);
break
;
case
1
:
mapproviderSelected
(
yahooActionMap
);
break
;
case
2
:
mapproviderSelected
(
yahooActionSatellite
);
break
;
case
3
:
mapproviderSelected
(
googleActionMap
);
break
;
case
4
:
mapproviderSelected
(
googleSatAction
);
break
;
}
}
void
MapWidget
::
goTo
()
{
bool
ok
;
...
...
@@ -332,6 +373,8 @@ void MapWidget::mapproviderSelected(QAction* action)
mapadapter
=
new
qmapcontrol
::
OSMMapAdapter
();
l
->
setMapAdapter
(
mapadapter
);
geomLayer
->
setMapAdapter
(
mapadapter
);
homePosition
->
setMapAdapter
(
mapadapter
);
index
=
0
;
if
(
isVisible
())
mc
->
updateRequestNew
();
mc
->
setZoom
(
zoom
);
...
...
@@ -348,6 +391,8 @@ void MapWidget::mapproviderSelected(QAction* action)
mapadapter
=
new
qmapcontrol
::
YahooMapAdapter
();
l
->
setMapAdapter
(
mapadapter
);
geomLayer
->
setMapAdapter
(
mapadapter
);
homePosition
->
setMapAdapter
(
mapadapter
);
index
=
1
;
if
(
isVisible
())
mc
->
updateRequestNew
();
mc
->
setZoom
(
zoom
);
...
...
@@ -364,6 +409,8 @@ void MapWidget::mapproviderSelected(QAction* action)
mapadapter
=
new
qmapcontrol
::
YahooMapAdapter
(
"us.maps3.yimg.com"
,
"/aerial.maps.yimg.com/png?v=1.7&t=a&s=256&x=%2&y=%3&z=%1"
);
l
->
setMapAdapter
(
mapadapter
);
geomLayer
->
setMapAdapter
(
mapadapter
);
homePosition
->
setMapAdapter
(
mapadapter
);
index
=
2
;
if
(
isVisible
())
mc
->
updateRequestNew
();
mc
->
setZoom
(
zoom
);
...
...
@@ -377,6 +424,8 @@ void MapWidget::mapproviderSelected(QAction* action)
mapadapter
=
new
qmapcontrol
::
GoogleMapAdapter
();
l
->
setMapAdapter
(
mapadapter
);
geomLayer
->
setMapAdapter
(
mapadapter
);
homePosition
->
setMapAdapter
(
mapadapter
);
index
=
3
;
if
(
isVisible
())
mc
->
updateRequestNew
();
mc
->
setZoom
(
zoom
);
...
...
@@ -391,6 +440,8 @@ void MapWidget::mapproviderSelected(QAction* action)
mapadapter
=
new
qmapcontrol
::
GoogleSatMapAdapter
();
l
->
setMapAdapter
(
mapadapter
);
geomLayer
->
setMapAdapter
(
mapadapter
);
homePosition
->
setMapAdapter
(
mapadapter
);
index
=
4
;
if
(
isVisible
())
mc
->
updateRequestNew
();
mc
->
setZoom
(
zoom
);
...
...
@@ -706,6 +757,38 @@ void MapWidget::captureGeometryEndDrag(Geometry* geom, QPointF coordinate)
mc
->
setMouseMode
(
qmapcontrol
::
MapControl
::
Panning
);
}
if
(
!
setHome
->
isChecked
())
{
mc
->
setMouseMode
(
qmapcontrol
::
MapControl
::
Panning
);
if
(
mav
)
{
// Update homePosition
UASManager
::
instance
()
->
setHomePosition
(
static_cast
<
double
>
(
homeCoordinate
.
x
()),
static_cast
<
double
>
(
homeCoordinate
.
y
()),
0
);
}
}
}
void
MapWidget
::
captureGeometryDragHome
(
Geometry
*
geom
,
QPointF
coordinate
)
{
if
(
isVisible
())
mc
->
updateRequest
(
geom
->
boundingBox
().
toRect
());
Waypoint2DIcon
*
point2Find
=
dynamic_cast
<
Waypoint2DIcon
*>
(
geom
);
if
(
point2Find
)
// && wps.count() > index)
{
// Update visual
point2Find
->
setCoordinate
(
coordinate
);
homeCoordinate
.
setX
(
coordinate
.
x
());
homeCoordinate
.
setY
(
coordinate
.
y
());
qmapcontrol
::
Point
*
tempPoint
=
new
qmapcontrol
::
Point
(
homeCoordinate
.
x
(),
homeCoordinate
.
y
(),
"g"
);
if
(
isVisible
())
mc
->
updateRequest
(
tempPoint
->
boundingBox
().
toRect
());
}
}
MapWidget
::~
MapWidget
()
...
...
@@ -1010,7 +1093,7 @@ void MapWidget::wheelEvent(QWheelEvent *event)
detailZoom
=
qAbs
(
qMin
(
0
,
mc
->
currentZoom
()
-
newZoom
));
// visual field of camera
updateCameraPosition
(
20
*
newZoom
,
0
,
"no"
);
//
updateCameraPosition(20*newZoom,0,"no");
}
}
...
...
@@ -1077,7 +1160,19 @@ void MapWidget::hideEvent(QHideEvent* event)
settings
.
setValue
(
"LAST_LONGITUDE"
,
currentPos
.
x
());
settings
.
setValue
(
"LAST_ZOOM"
,
mc
->
currentZoom
());
settings
.
endGroup
();
settings
.
beginGroup
(
"QGC_MAPINDEX"
);
settings
.
setValue
(
"MAP_INDEX"
,
index
);
settings
.
endGroup
();
settings
.
beginGroup
(
"QGC_HOMEPOSITION"
);
settings
.
setValue
(
"HOME_LATITUDE"
,
homeCoordinate
.
y
());
settings
.
setValue
(
"HOME_LONGITUDE"
,
homeCoordinate
.
x
());
settings
.
endGroup
();
settings
.
sync
();
}
}
...
...
@@ -1146,88 +1241,25 @@ void MapWidget::clearPath(int uas)
}
}
void
MapWidget
::
updateCameraPosition
(
double
radio
,
double
bearing
,
QString
dir
)
void
MapWidget
::
createHomePosition
(
const
QMouseEvent
*
event
,
const
QPointF
coordinate
)
{
Q_UNUSED
(
dir
);
Q_UNUSED
(
bearing
);
if
(
mc
)
{
// FIXME Mariano
//camPoints.clear();
QPointF
currentPos
=
mc
->
currentCoordinate
();
// QPointF actualPos = getPointxBearing_Range(currentPos.y(),currentPos.x(),bearing,distance);
// qmapcontrol::Point* tempPoint1 = new qmapcontrol::Point(currentPos.x(), currentPos.y(),"inicial",qmapcontrol::Point::Middle);
// qmapcontrol::Point* tempPoint2 = new qmapcontrol::Point(actualPos.x(), actualPos.y(),"final",qmapcontrol::Point::Middle);
// camPoints.append(tempPoint1);
// camPoints.append(tempPoint2);
// camLine->setPoints(camPoints);
QPen
*
camBorderPen
=
new
QPen
(
QColor
(
255
,
0
,
0
));
camBorderPen
->
setWidth
(
2
);
//radio = mc->currentZoom()
if
(
drawCamBorder
)
{
//clear camera borders
mc
->
layer
(
"Camera"
)
->
clearGeometries
();
//create a camera borders
qmapcontrol
::
CirclePoint
*
camBorder
=
new
qmapcontrol
::
CirclePoint
(
currentPos
.
x
(),
currentPos
.
y
(),
radio
,
"camBorder"
,
qmapcontrol
::
Point
::
Middle
,
camBorderPen
);
//camBorder->setCoordinate(currentPos);
mc
->
layer
(
"Camera"
)
->
addGeometry
(
camBorder
);
// mc->layer("Camera")->addGeometry(camLine);
if
(
isVisible
())
mc
->
updateRequestNew
();
}
else
if
(
QEvent
::
MouseButtonRelease
==
event
->
type
()
&&
setHome
->
isChecked
())
{
//clear camera borders
mc
->
layer
(
"Camera"
)
->
clearGeometries
();
if
(
isVisible
())
mc
->
updateRequestNew
();
}
this
->
createHomePosition
(
coordinate
);
}
}
void
MapWidget
::
drawBorderCamAtMap
(
bool
status
)
void
MapWidget
::
createHomePosition
(
const
QPointF
coordinate
)
{
drawCamBorder
=
status
;
updateCameraPosition
(
20
,
0
,
"no"
);
}
QPointF
MapWidget
::
getPointxBearing_Range
(
double
lat1
,
double
lon1
,
double
bearing
,
double
distance
)
{
QPointF
temp
;
double
rad
=
M_PI
/
180
;
bearing
=
bearing
*
rad
;
temp
.
setX
((
lon1
+
((
distance
/
60
)
*
(
sin
(
bearing
)))));
temp
.
setY
((
lat1
+
((
distance
/
60
)
*
(
cos
(
bearing
)))));
return
temp
;
}
void
MapWidget
::
createHomePosition
(
const
QMouseEvent
*
event
,
const
QPointF
coordinate
)
{
if
(
QEvent
::
MouseButtonRelease
==
event
->
type
()
&&
setHome
->
isChecked
())
{
homeCoordinate
=
coordinate
;
Waypoint2DIcon
*
tempCirclePoint
;
double
latitud
=
homeCoordinate
.
x
();
double
longitud
=
homeCoordinate
.
y
();
double
latitude
=
homeCoordinate
.
y
();
double
longitude
=
homeCoordinate
.
x
();
tempCirclePoint
=
new
Waypoint2DIcon
(
latitud
,
longitud
,
longitude
,
latitude
,
20
,
"g"
,
qmapcontrol
::
Point
::
Middle
);
QPen
*
pencil
=
new
QPen
(
Qt
::
blue
);
...
...
@@ -1236,13 +1268,12 @@ void MapWidget::createHomePosition(const QMouseEvent *event, const QPointF coord
mc
->
layer
(
"Station"
)
->
clearGeometries
();
mc
->
layer
(
"Station"
)
->
addGeometry
(
tempCirclePoint
);
qmapcontrol
::
Point
*
tempPoint
=
new
qmapcontrol
::
Point
(
latitud
,
longitud
,
"g"
);
qmapcontrol
::
Point
*
tempPoint
=
new
qmapcontrol
::
Point
(
latitude
,
longitude
,
"g"
);
if
(
isVisible
())
{
mc
->
updateRequest
(
tempPoint
->
boundingBox
().
toRect
());
}
}
}
void
MapWidget
::
createHomePositionClick
(
bool
click
)
...
...
@@ -1250,11 +1281,15 @@ void MapWidget::createHomePositionClick(bool click)
Q_UNUSED
(
click
);
if
(
!
setHome
->
isChecked
())
{
if
(
mav
)
{
UASManager
::
instance
()
->
setHomePosition
(
static_cast
<
double
>
(
homeCoordinate
.
x
()),
static_cast
<
double
>
(
homeCoordinate
.
y
()),
0
);
static_cast
<
double
>
(
homeCoordinate
.
y
()),
static_cast
<
double
>
(
homeCoordinate
.
x
()),
0
);
qDebug
()
<<
"Set home position "
<<
homeCoordinate
.
x
()
<<
" "
<<
homeCoordinate
.
y
();
qDebug
()
<<
"Set home position "
<<
homeCoordinate
.
y
()
<<
" "
<<
homeCoordinate
.
x
();
}
}
}
src/ui/MapWidget.h
View file @
1fe54579
...
...
@@ -40,8 +40,7 @@ This file is part of the QGROUNDCONTROL project
#include "QPointF"
#include <qmath.h>
#include <QSettings>
class
QMenu
;
class
Waypoint
;
...
...
@@ -76,8 +75,8 @@ public slots:
void
updateAttitude
(
UASInterface
*
uas
,
double
roll
,
double
pitch
,
double
yaw
,
quint64
usec
);
void
updateGlobalPosition
(
UASInterface
*
uas
,
double
lat
,
double
lon
,
double
alt
,
quint64
usec
);
void
updatePosition
(
float
time
,
double
lat
,
double
lon
);
void
updateCameraPosition
(
double
distance
,
double
bearing
,
QString
dir
);
QPointF
getPointxBearing_Range
(
double
lat1
,
double
lon1
,
double
bearing
,
double
distance
);
//
void updateCameraPosition(double distance, double bearing, QString dir);
//
QPointF getPointxBearing_Range(double lat1, double lon1, double bearing, double distance);
/** @brief Clear the waypoints overlay layer */
void
clearWaypoints
(
int
uas
=
0
);
...
...
@@ -93,7 +92,7 @@ public slots:
void
updateWaypoint
(
int
uas
,
Waypoint
*
wp
);
void
updateWaypoint
(
int
uas
,
Waypoint
*
wp
,
bool
updateView
);
void
drawBorderCamAtMap
(
bool
status
);
//
void drawBorderCamAtMap(bool status);
/** @brief Bring up dialog to go to a specific location */
void
goTo
();
...
...
@@ -130,8 +129,6 @@ protected:
qmapcontrol
::
Layer
*
tracks
;
///< Layer for UAV tracks
qmapcontrol
::
GeometryLayer
*
geomLayer
;
///< Layer for waypoints
qmapcontrol
::
GeometryLayer
*
homePosition
;
///< Layer for station control
//only for experiment
//qmapcontrol::GeometryLayer* camLayer; ///< Layer for camera indicator
int
zoomLevel
;
int
detailZoom
;
///< Steps zoomed in further than qMapControl allows
...
...
@@ -143,8 +140,6 @@ protected:
QMap
<
int
,
qmapcontrol
::
Point
*>
uasIcons
;
QMap
<
int
,
qmapcontrol
::
LineString
*>
uasTrails
;
QMap
<
int
,
QPen
*>
mavPens
;
//QMap<int, QList<qmapcontrol::Point*> > mavWps;
//QMap<int, qmapcontrol::LineString*> waypointPaths;
UASInterface
*
mav
;
quint64
lastUpdate
;
bool
initialized
;
...
...
@@ -158,6 +153,8 @@ protected:
void
captureGeometryDrag
(
Geometry
*
geom
,
QPointF
coordinate
);
void
captureGeometryEndDrag
(
Geometry
*
geom
,
QPointF
coordinate
);
void
captureGeometryDragHome
(
Geometry
*
geom
,
QPointF
coordinate
);
void
createPathButtonClicked
(
bool
checked
);
/** @brief Create the graphic representation of the waypoint */
...
...
@@ -165,16 +162,14 @@ protected:
void
mapproviderSelected
(
QAction
*
action
);
void
createHomePosition
(
const
QMouseEvent
*
event
,
const
QPointF
coordinate
);
void
createHomePosition
(
const
QPointF
coordinate
);
void
createHomePositionClick
(
bool
click
);
void
loadSettingsMap
(
QSettings
&
);
signals:
//void movePoint(QPointF newCoord);
//void captureMapCoordinateClick(const QPointF coordinate); //ROCA
//void createGlobalWP(bool value, QPointF centerCoordinate);
void
waypointCreated
(
Waypoint
*
wp
);
void
sendGeometryEndDrag
(
const
QPointF
coordinate
,
const
int
index
);
private:
Ui
::
MapWidget
*
m_ui
;
QList
<
qmapcontrol
::
Point
*>
wps
;
...
...
@@ -184,15 +179,8 @@ private:
QPen
*
pointPen
;
int
wpExists
(
const
QPointF
coordinate
);
bool
waypointIsDrag
;
qmapcontrol
::
LineString
*
camLine
;
QList
<
qmapcontrol
::
Point
*>
camPoints
;
QPointF
lastCamBorderPos
;
bool
drawCamBorder
;
int
radioCamera
;
QPointF
homeCoordinate
;
int8_t
index
;
};
#endif // MAPWIDGET_H
src/ui/SlugsPadCameraControl.ui
View file @
1fe54579
...
...
@@ -41,7 +41,7 @@
<bool>
true
</bool>
</property>
<property
name=
"styleSheet"
>
<string
notr=
"true"
>
background-color: rgb
a(255, 0, 0,50%
);
</string>
<string
notr=
"true"
>
background-color: rgb
(135, 206, 235
);
</string>
</property>
<property
name=
"frameShape"
>
<enum>
QFrame::StyledPanel
</enum>
...
...
@@ -67,6 +67,9 @@
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout"
>
<item>
<widget
class=
"QLabel"
name=
"lbPixel"
>
<property
name=
"styleSheet"
>
<string
notr=
"true"
>
font-color:rgb(0, 0, 0);
</string>
</property>
<property
name=
"text"
>
<string>
----
</string>
</property>
...
...
src/ui/uas/UASControlParameters.cpp
View file @
1fe54579
...
...
@@ -80,11 +80,11 @@ void UASControlParameters::changedMode(int mode)
if
(
modeTemp
!=
this
->
mode
)
{
ui
->
lbMode
->
setStyleSheet
(
"background-color: rgb(
255, 0, 0
)"
);
ui
->
lbMode
->
setStyleSheet
(
"background-color: rgb(
165, 42, 42
)"
);
}
else
{
ui
->
lbMode
->
setStyleSheet
(
"background-color: rgb(
0, 255, 0
)"
);
ui
->
lbMode
->
setStyleSheet
(
"background-color: rgb(
85, 107, 47
)"
);
}
}
...
...
@@ -104,12 +104,17 @@ void UASControlParameters::activeUasSet(UASInterface *uas)
void
UASControlParameters
::
updateGlobalPosition
(
UASInterface
*
a
,
double
b
,
double
c
,
double
aa
,
quint64
ab
)
{
//ui->sbHeight->setValue(aa);
Q_UNUSED
(
a
);
Q_UNUSED
(
b
);
Q_UNUSED
(
c
);
Q_UNUSED
(
ab
);
this
->
altitude
=
aa
;
}
void
UASControlParameters
::
speedChanged
(
UASInterface
*
uas
,
double
vx
,
double
vy
,
double
vz
,
quint64
time
)
{
Q_UNUSED
(
time
);
Q_UNUSED
(
uas
);
this
->
speed
=
sqrt
(
pow
(
vx
,
2.0
)
+
pow
(
vy
,
2.0
)
+
pow
(
vz
,
2.0
));
//ui->sbAirSpeed->setValue(speed);
}
...
...
@@ -117,6 +122,8 @@ void UASControlParameters::speedChanged(UASInterface* uas, double vx, double vy,
void
UASControlParameters
::
updateAttitude
(
UASInterface
*
uas
,
double
roll
,
double
pitch
,
double
yaw
,
quint64
time
)
{
Q_UNUSED
(
uas
);
Q_UNUSED
(
pitch
);
Q_UNUSED
(
yaw
);
Q_UNUSED
(
time
);
//ui->sbTurnRate->setValue(roll);
this
->
roll
=
roll
;
...
...
@@ -194,7 +201,7 @@ void UASControlParameters::updateMode(int uas,QString mode,QString description)
this
->
mode
=
mode
;
ui
->
lbMode
->
setText
(
this
->
mode
);
ui
->
lbMode
->
setStyleSheet
(
"background-color: rgb(
0, 255, 0
)"
);
ui
->
lbMode
->
setStyleSheet
(
"background-color: rgb(
85, 107, 47
)"
);
}
void
UASControlParameters
::
thrustChanged
(
UASInterface
*
uas
,
double
throttle
)
...
...
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