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
6344a49d
Commit
6344a49d
authored
Nov 28, 2010
by
pixhawk
Browse files
Options
Browse Files
Download
Plain Diff
Added support for OSG on Mac platform
parents
a1dc95ac
fa827afc
Changes
32
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
32 changed files
with
23529 additions
and
299 deletions
+23529
-299
cessna.osg
models/cessna.osg
+20534
-0
qgroundcontrol.pri
qgroundcontrol.pri
+146
-43
qgroundcontrol.pro
qgroundcontrol.pro
+49
-12
Freenect.cc
src/input/Freenect.cc
+247
-0
Freenect.h
src/input/Freenect.h
+70
-0
MainWindow.cc
src/ui/MainWindow.cc
+65
-4
MainWindow.h
src/ui/MainWindow.h
+6
-5
MainWindow.ui
src/ui/MainWindow.ui
+11
-1
GCManipulator.cc
src/ui/map3D/GCManipulator.cc
+1
-1
ImageWindowGeode.cc
src/ui/map3D/ImageWindowGeode.cc
+115
-0
ImageWindowGeode.h
src/ui/map3D/ImageWindowGeode.h
+56
-0
Imagery.cc
src/ui/map3D/Imagery.cc
+594
-0
Imagery.h
src/ui/map3D/Imagery.h
+114
-0
Pixhawk3DWidget.cc
src/ui/map3D/Pixhawk3DWidget.cc
+278
-98
Pixhawk3DWidget.h
src/ui/map3D/Pixhawk3DWidget.h
+38
-4
PixhawkCheetahGeode.cc
src/ui/map3D/PixhawkCheetahGeode.cc
+1
-0
Q3DWidget.cc
src/ui/map3D/Q3DWidget.cc
+6
-8
Q3DWidget.h
src/ui/map3D/Q3DWidget.h
+1
-1
Q3DWidgetFactory.cc
src/ui/map3D/Q3DWidgetFactory.cc
+12
-3
Q3DWidgetFactory.h
src/ui/map3D/Q3DWidgetFactory.h
+1
-1
QMap3D.cc
src/ui/map3D/QMap3D.cc
+4
-0
QMap3D.h
src/ui/map3D/QMap3D.h
+3
-0
QOSGWidget.cc
src/ui/map3D/QOSGWidget.cc
+5
-23
QOSGWidget.h
src/ui/map3D/QOSGWidget.h
+81
-95
Texture.cc
src/ui/map3D/Texture.cc
+251
-0
Texture.h
src/ui/map3D/Texture.h
+94
-0
TextureCache.cc
src/ui/map3D/TextureCache.cc
+107
-0
TextureCache.h
src/ui/map3D/TextureCache.h
+61
-0
WebImage.cc
src/ui/map3D/WebImage.cc
+232
-0
WebImage.h
src/ui/map3D/WebImage.h
+90
-0
WebImageCache.cc
src/ui/map3D/WebImageCache.cc
+191
-0
WebImageCache.h
src/ui/map3D/WebImageCache.h
+65
-0
No files found.
models/cessna.osg
0 → 100644
View file @
6344a49d
This diff is collapsed.
Click to expand it.
qgroundcontrol.pri
View file @
6344a49d
...
...
@@ -34,9 +34,17 @@ release {
# DEFINES += QT_NO_WARNING_OUTPUT
}
QMAKE_PRE_LINK += echo "Copying files"
#QMAKE_PRE_LINK += && cp -rf $$BASEDIR/models $$TARGETDIR/debug/.
#QMAKE_PRE_LINK += && cp -rf $$BASEDIR/models $$TARGETDIR/release/.
# MAC OS X
macx {
COMPILER_VERSION = $$system(gcc -v)
message(Using compiler $$COMPILER_VERSION)
HARDWARE_PLATFORM = $$system(uname -a)
contains( HARDWARE_PLATFORM, 9.6.0 ) || contains( HARDWARE_PLATFORM, 9.7.0 ) || contains( HARDWARE_PLATFORM, 9.8.0 ) || contains( HARDWARE_PLATFORM, 9.9.0 ) {
# x86 Mac OS X Leopard 10.5 and earlier
...
...
@@ -55,18 +63,15 @@ macx {
message(Building for Mac OS X 64bit/Snow Leopard 10.6 and later)
}
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.
6
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.
5
DESTDIR = $$BASEDIR/bin/mac
INCLUDEPATH += -framework SDL \
$$BASEDIR/../mavlink/contrib/slugs/include \
$$BASEDIR/../mavlink/include
INCLUDEPATH += -framework SDL
LIBS += -framework IOKit \
-framework SDL \
-framework CoreFoundation \
-framework ApplicationServices \
# -framework GLUT \
-lm
ICON = $$BASEDIR/images/icons/macx.icns
...
...
@@ -74,24 +79,67 @@ macx {
# Copy audio files if needed
QMAKE_PRE_LINK += cp -rf $$BASEDIR/audio $$DESTDIR/qgroundcontrol.app/Contents/MacOs/.
exists(/opt/local/lib/osg):exists("/opt/local/lib/osgEarth") {
message("Building support for OSGEARTH")
DEPENDENCIES_PRESENT += osgearth
LIBS += -L/opt/local/lib/
INCLUDEPATH += /opt/local/include
# Include OpenSceneGraph and osgEarth libraries
LIBS += -losg \
-losgViewer \
-losgEarth \
-losgEarthUtil
exists(/Library/Frameworks/osg.framework):exists(/Library/Frameworks/OpenThreads.framework) {
# No check for GLUT.framework since it's a MAC default
message("Building support for OpenSceneGraph")
DEPENDENCIES_PRESENT += osg
DEFINES += QGC_OSG_ENABLED
# Include OpenSceneGraph libraries
INCLUDEPATH += -framework GLUT \
-framework Carbon \
-framework OpenThreads \
-framework osg \
-framework osgViewer \
-framework osgGA \
-framework osgDB \
-framework osgText \
-framework osgWidget
LIBS += -framework GLUT \
-framework Carbon \
-framework OpenThreads \
-framework osg \
-framework osgViewer \
-framework osgGA \
-framework osgDB \
-framework osgText \
-framework osgWidget
}
exists(/usr/include/osgEarth) {
message("Building support for osgEarth")
DEPENDENCIES_PRESENT += osgearth
# Include osgEarth libraries
INCLUDEPATH += -framework GDAL \
$$IN_PWD/lib/mac32-gcc/include \
-framework GEOS \
-framework SQLite3 \
-framework osgFX \
-framework osgTerrain
LIBS += -framework GDAL \
-framework GEOS \
-framework SQLite3 \
-framework osgFX \
-framework osgTerrain \
DEFINES += QGC_OSGEARTH_ENABLED
}
exists(/opt/local/include/libfreenect) {
message("Building support for libfreenect")
DEPENDENCIES_PRESENT += libfreenect
# Include libfreenect libraries
LIBS += -lfreenect
DEFINES += QGC_LIBFREENECT_ENABLED
}
# osg/osgEarth dynamic casts might fail without this compiler option.
# see http://osgearth.org/wiki/FAQ for details.
#QMAKE_CXXFLAGS += -Wl, -E
}
# GNU/Linux
linux-g++ {
CONFIG += debug
debug {
DESTDIR = $$BUILDDIR/debug
...
...
@@ -131,21 +179,41 @@ linux-g++ {
-lSDL \
-lSDLmain
exists(/usr/include/osgEarth) | exists(/usr/local/include/osgEarth) {
message("Building support for OSGEARTH")
DEPENDENCIES_PRESENT += osgearth
# Include OpenSceneGraph and osgEarth libraries
LIBS += -losg \
-losgViewer \
-losgEarth \
-losgEarthUtil
DEFINES += QGC_OSG_ENABLED
}
exists(/usr/include/osg) {
message("Building support for OpenSceneGraph")
DEPENDENCIES_PRESENT += osg
# Include OpenSceneGraph libraries
LIBS += -losg
DEFINES += QGC_OSG_ENABLED
}
QMAKE_CXXFLAGS += -Wl,-E
exists(/usr/include/osgEarth) | exists(/usr/local/include/osgEarth) {
message("Building support for osgEarth")
DEPENDENCIES_PRESENT += osgearth
# Include osgEarth libraries
LIBS += -losgViewer \
-losgEarth \
-losgEarthUtil
DEFINES += QGC_OSGEARTH_ENABLED
}
exists(/usr/local/include/libfreenect) {
message("Building suplocport for libfreenect")
DEPENDENCIES_PRESENT += libfreenect
INCLUDEPATH += /usr/include/libusb-1.0
# Include libfreenect libraries
LIBS += -lfreenect
DEFINES += QGC_LIBFREENECT_ENABLED
}
#-lflite_cmu_us_rms \
#-lflite_cmu_us_slt \
QMAKE_PRE_LINK += && cp -rf $$BASEDIR/models $$TARGETDIR/debug/.
QMAKE_PRE_LINK += && cp -rf $$BASEDIR/models $$TARGETDIR/release/.
QMAKE_PRE_LINK += && cp -rf $$BASEDIR/data $$TARGETDIR/debug/.
QMAKE_PRE_LINK += && cp -rf $$BASEDIR/data $$TARGETDIR/release/.
# osg/osgEarth dynamic casts might fail without this compiler option.
# see http://osgearth.org/wiki/FAQ for details.
QMAKE_CXXFLAGS += -Wl, -E
}
linux-g++-64 {
...
...
@@ -188,16 +256,36 @@ linux-g++-64 {
-lSDL \
-lSDLmain
exists(/usr/lib/osg):exists(/usr/lib/osgEarth) {
message("Building support for OSGEARTH")
DEPENDENCIES_PRESENT += osgearth
# Include OpenSceneGraph and osgEarth libraries
LIBS += -losg \
-losgViewer \
-losgEarth
DEFINES += QGC_OSG_ENABLED
}
exists(/usr/include/osg) {
message("Building support for OpenSceneGraph")
DEPENDENCIES_PRESENT += osg
# Include OpenSceneGraph libraries
LIBS += -losg
DEFINES += QGC_OSG_ENABLED
}
exists(/usr/include/osgEarth) {
message("Building support for osgEarth")
DEPENDENCIES_PRESENT += osgearth
# Include osgEarth libraries
LIBS += -losgViewer \
-losgEarth \
-losgEarthUtil
DEFINES += QGC_OSGEARTH_ENABLED
}
exists(/usr/local/include/libfreenect) {
message("Building support for libfreenect")
DEPENDENCIES_PRESENT += libfreenect
INCLUDEPATH += /usr/include/libusb-1.0
# Include libfreenect libraries
LIBS += -lfreenect
DEFINES += QGC_LIBFREENECT_ENABLED
}
# osg/osgEarth dynamic casts might fail without this compiler option.
# see http://osgearth.org/wiki/FAQ for details.
QMAKE_CXXFLAGS += -Wl, -E
}
# Windows (32bit)
...
...
@@ -222,7 +310,13 @@ win32-msvc2008 {
QMAKE_PRE_LINK += cp -f $$BASEDIR/lib/sdl/win32/SDL.dll $$TARGETDIR/debug/. &&
QMAKE_PRE_LINK += cp -f $$BASEDIR/lib/sdl/win32/SDL.dll $$TARGETDIR/release/. &&
QMAKE_PRE_LINK += cp -rf $$BASEDIR/audio $$TARGETDIR/debug/. &&
QMAKE_PRE_LINK += cp -rf $$BASEDIR/audio $$TARGETDIR/release/.
QMAKE_PRE_LINK += cp -rf $$BASEDIR/audio $$TARGETDIR/release/. &&
QMAKE_PRE_LINK += cp -rf $$BASEDIR/models $$TARGETDIR/debug/. &&
QMAKE_PRE_LINK += cp -rf $$BASEDIR/models $$TARGETDIR/release/.
# osg/osgEarth dynamic casts might fail without this compiler option.
# see http://osgearth.org/wiki/FAQ for details.
QMAKE_CXXFLAGS += /Wl /E
}
# Windows (32bit)
...
...
@@ -255,8 +349,14 @@ win32-g++ {
# Copy dependencies
QMAKE_PRE_LINK += cp -f $$BASEDIR/lib/sdl/win32/SDL.dll $$BUILDDIR/debug/. &&
QMAKE_PRE_LINK += cp -f $$BASEDIR/lib/sdl/win32/SDL.dll $$BUILDDIR/release/. &&
QMAKE_PRE_LINK += cp -rf $$BASEDIR/audio $$BUILDDIR/debug/. &&
QMAKE_PRE_LINK += cp -rf $$BASEDIR/audio $$BUILDDIR/release/.
QMAKE_PRE_LINK += cp -rf $$BASEDIR/audio $$TARGETDIR/debug/. &&
QMAKE_PRE_LINK += cp -rf $$BASEDIR/audio $$TARGETDIR/release/.
QMAKE_PRE_LINK += cp -rf $$BASEDIR/models $$TARGETDIR/debug/. &&
QMAKE_PRE_LINK += cp -rf $$BASEDIR/models $$TARGETDIR/release/.
# osg/osgEarth dynamic casts might fail without this compiler option.
# see http://osgearth.org/wiki/FAQ for details.
QMAKE_CXXFLAGS += -Wl, -E
}
# Windows (64bit)
...
...
@@ -291,5 +391,8 @@ win64-g++ {
QMAKE_PRE_LINK += cp -f $$BASEDIR/lib/sdl/win32/SDL.dll $$BUILDDIR/release/. &&
QMAKE_PRE_LINK += cp -rf $$BASEDIR/audio $$BUILDDIR/debug/. &&
QMAKE_PRE_LINK += cp -rf $$BASEDIR/audio $$BUILDDIR/release/.
}
# osg/osgEarth dynamic casts might fail without this compiler option.
# see http://osgearth.org/wiki/FAQ for details.
QMAKE_CXXFLAGS += -Wl, -E
}
qgroundcontrol.pro
View file @
6344a49d
...
...
@@ -231,18 +231,35 @@ HEADERS += src/MG.h \
src
/
ui
/
RadioCalibration
/
CurveCalibrator
.
h
\
src
/
ui
/
RadioCalibration
/
AbstractCalibrator
.
h
\
src
/
comm
/
QGCMAVLink
.
h
contains
(
DEPENDENCIES_PRESENT
,
osgearth
)
{
message
(
"Including headers for OSGEARTH"
)
contains
(
DEPENDENCIES_PRESENT
,
osg
)
{
message
(
"Including headers for OpenSceneGraph"
)
#
Enable
only
if
OpenSceneGraph
is
available
HEADERS
+=
src
/
ui
/
map3D
/
Q3DWidget
.
h
\
src
/
ui
/
map3D
/
GCManipulator
.
h
\
src
/
ui
/
map3D
/
ImageWindowGeode
.
h
\
src
/
ui
/
map3D
/
QOSGWidget
.
h
\
src
/
ui
/
map3D
/
QMap3D
.
h
\
src
/
ui
/
map3D
/
PixhawkCheetahGeode
.
h
\
src
/
ui
/
map3D
/
Pixhawk3DWidget
.
h
\
src
/
ui
/
map3D
/
Q3DWidgetFactory
.
h
\
src
/
ui
/
map3D
/
GCManipulator
.
h
src
/
ui
/
map3D
/
Q3DWidgetFactory
.
h
contains
(
DEPENDENCIES_PRESENT
,
osgearth
)
{
message
(
"Including headers for OSGEARTH"
)
#
Enable
only
if
OpenSceneGraph
is
available
HEADERS
+=
src
/
ui
/
map3D
/
QMap3D
.
h
}
}
contains
(
DEPENDENCIES_PRESENT
,
libfreenect
)
{
message
(
"Including headers for libfreenect"
)
#
Enable
only
if
libfreenect
is
available
HEADERS
+=
src
/
input
/
Freenect
.
h
}
SOURCES
+=
src
/
main
.
cc
\
src
/
Core
.
cc
\
src
/
uas
/
UASManager
.
cc
\
...
...
@@ -311,19 +328,39 @@ SOURCES += src/main.cc \
src
/
ui
/
RadioCalibration
/
SwitchCalibrator
.
cc
\
src
/
ui
/
RadioCalibration
/
CurveCalibrator
.
cc
\
src
/
ui
/
RadioCalibration
/
AbstractCalibrator
.
cc
\
src
/
ui
/
RadioCalibration
/
RadioCalibrationData
.
cc
#
src
/
ui
/
WaypointGlobalView
.
cc
\
contains
(
DEPENDENCIES_PRESENT
,
osgearth
)
{
message
(
"Including sources for OSGEARTH"
)
src
/
ui
/
RadioCalibration
/
RadioCalibrationData
.
cc
contains
(
DEPENDENCIES_PRESENT
,
osg
)
{
message
(
"Including sources for OpenSceneGraph"
)
#
Enable
only
if
OpenSceneGraph
is
available
SOURCES
+=
src
/
ui
/
map3D
/
Q3DWidget
.
cc
\
src
/
ui
/
map3D
/
QOSGWidget
.
cc
\
src
/
ui
/
map3D
/
QMap3D
.
cc
\
src
/
ui
/
map3D
/
ImageWindowGeode
.
cc
\
src
/
ui
/
map3D
/
GCManipulator
.
cc
\
src
/
ui
/
map3D
/
QOSGWidget
.
cc
\
src
/
ui
/
map3D
/
PixhawkCheetahGeode
.
cc
\
src
/
ui
/
map3D
/
Pixhawk3DWidget
.
cc
\
src
/
ui
/
map3D
/
Q3DWidgetFactory
.
cc
\
src
/
ui
/
map3D
/
GCManipulator
.
cc
src
/
ui
/
map3D
/
Q3DWidgetFactory
.
cc
contains
(
DEPENDENCIES_PRESENT
,
osgearth
)
{
message
(
"Including sources for osgEarth"
)
#
Enable
only
if
OpenSceneGraph
is
available
SOURCES
+=
src
/
ui
/
map3D
/
QMap3D
.
cc
}
}
contains
(
DEPENDENCIES_PRESENT
,
libfreenect
)
{
message
(
"Including sources for libfreenect"
)
#
Enable
only
if
libfreenect
is
available
SOURCES
+=
src
/
input
/
Freenect
.
cc
}
RESOURCES
+=
mavground
.
qrc
#
Include
RT
-
LAB
Library
...
...
src/input/Freenect.cc
0 → 100644
View file @
6344a49d
#include "Freenect.h"
#include <cmath>
#include <string.h>
#include <QDebug>
Freenect
::
Freenect
()
:
context
(
NULL
)
,
device
(
NULL
)
,
tiltAngle
(
0
)
{
for
(
int
i
=
0
;
i
<
2048
;
++
i
)
{
float
v
=
static_cast
<
float
>
(
i
)
/
2048.0
f
;
v
=
powf
(
v
,
3.0
f
)
*
6.0
f
;
gammaTable
[
i
]
=
static_cast
<
unsigned
short
>
(
v
*
6.0
f
*
256.0
f
);
}
}
Freenect
::~
Freenect
()
{
if
(
device
!=
NULL
)
{
freenect_stop_depth
(
device
);
freenect_stop_rgb
(
device
);
}
freenect_close_device
(
device
);
freenect_shutdown
(
context
);
}
bool
Freenect
::
init
(
int
userDeviceNumber
)
{
if
(
freenect_init
(
&
context
,
NULL
)
<
0
)
{
return
false
;
}
freenect_set_log_level
(
context
,
FREENECT_LOG_DEBUG
);
if
(
freenect_num_devices
(
context
)
<
1
)
{
return
false
;
}
if
(
freenect_open_device
(
context
,
&
device
,
userDeviceNumber
)
<
0
)
{
return
false
;
}
freenect_set_user
(
device
,
this
);
memset
(
rgb
,
0
,
FREENECT_RGB_SIZE
);
memset
(
depth
,
0
,
FREENECT_DEPTH_SIZE
);
// set Kinect parameters
if
(
freenect_set_tilt_degs
(
device
,
tiltAngle
)
!=
0
)
{
return
false
;
}
if
(
freenect_set_led
(
device
,
LED_RED
)
!=
0
)
{
return
false
;
}
if
(
freenect_set_rgb_format
(
device
,
FREENECT_FORMAT_RGB
)
!=
0
)
{
return
false
;
}
if
(
freenect_set_depth_format
(
device
,
FREENECT_FORMAT_11_BIT
)
!=
0
)
{
return
false
;
}
freenect_set_rgb_callback
(
device
,
rgbCallback
);
freenect_set_depth_callback
(
device
,
depthCallback
);
if
(
freenect_start_rgb
(
device
)
!=
0
)
{
return
false
;
}
if
(
freenect_start_depth
(
device
)
!=
0
)
{
return
false
;
}
thread
.
reset
(
new
FreenectThread
(
device
));
thread
->
start
();
return
true
;
}
bool
Freenect
::
process
(
void
)
{
if
(
freenect_process_events
(
context
)
<
0
)
{
return
false
;
}
freenect_get_raw_accel
(
device
,
&
ax
,
&
ay
,
&
az
);
freenect_get_mks_accel
(
device
,
&
dx
,
&
dy
,
&
dz
);
return
true
;
}
QSharedPointer
<
QByteArray
>
Freenect
::
getRgbData
(
void
)
{
QMutexLocker
locker
(
&
rgbMutex
);
return
QSharedPointer
<
QByteArray
>
(
new
QByteArray
(
rgb
,
FREENECT_RGB_SIZE
));
}
QSharedPointer
<
QByteArray
>
Freenect
::
getRawDepthData
(
void
)
{
QMutexLocker
locker
(
&
depthMutex
);
return
QSharedPointer
<
QByteArray
>
(
new
QByteArray
(
depth
,
FREENECT_DEPTH_SIZE
));
}
QSharedPointer
<
QByteArray
>
Freenect
::
getDistanceData
(
void
)
{
QMutexLocker
locker
(
&
distanceMutex
);
return
QSharedPointer
<
QByteArray
>
(
new
QByteArray
(
reinterpret_cast
<
char
*>
(
distance
),
FREENECT_FRAME_PIX
*
sizeof
(
float
)));
}
QSharedPointer
<
QByteArray
>
Freenect
::
getColoredDepthData
(
void
)
{
QMutexLocker
locker
(
&
coloredDepthMutex
);
return
QSharedPointer
<
QByteArray
>
(
new
QByteArray
(
coloredDepth
,
FREENECT_RGB_SIZE
));
}
int
Freenect
::
getTiltAngle
(
void
)
const
{
return
tiltAngle
;
}
void
Freenect
::
setTiltAngle
(
int
angle
)
{
if
(
angle
>
30
)
{
angle
=
30
;
}
if
(
angle
<
-
30
)
{
angle
=
-
30
;
}
tiltAngle
=
angle
;
}
Freenect
::
FreenectThread
::
FreenectThread
(
freenect_device
*
_device
)
{
device
=
_device
;
}
void
Freenect
::
FreenectThread
::
run
(
void
)
{
Freenect
*
freenect
=
static_cast
<
Freenect
*>
(
freenect_get_user
(
device
));
while
(
1
)
{
freenect
->
process
();
}
}
void
Freenect
::
rgbCallback
(
freenect_device
*
device
,
freenect_pixel
*
rgb
,
uint32_t
timestamp
)
{
Freenect
*
freenect
=
static_cast
<
Freenect
*>
(
freenect_get_user
(
device
));
QMutexLocker
locker
(
&
freenect
->
rgbMutex
);
memcpy
(
freenect
->
rgb
,
rgb
,
FREENECT_RGB_SIZE
);
}
void
Freenect
::
depthCallback
(
freenect_device
*
device
,
freenect_depth
*
depth
,
uint32_t
timestamp
)
{
Freenect
*
freenect
=
static_cast
<
Freenect
*>
(
freenect_get_user
(
device
));
freenect_depth
*
data
=
reinterpret_cast
<
freenect_depth
*>
(
depth
);
QMutexLocker
depthLocker
(
&
freenect
->
depthMutex
);
memcpy
(
freenect
->
depth
,
data
,
FREENECT_DEPTH_SIZE
);
QMutexLocker
distanceLocker
(
&
freenect
->
distanceMutex
);
for
(
int
i
=
0
;
i
<
FREENECT_FRAME_PIX
;
++
i
)
{
freenect
->
distance
[
i
]
=
100.
f
/
(
-
0.00307
f
*
static_cast
<
float
>
(
data
[
i
])
+
3.33
f
);
}
QMutexLocker
coloredDepthLocker
(
&
freenect
->
coloredDepthMutex
);
unsigned
short
*
src
=
reinterpret_cast
<
unsigned
short
*>
(
data
);
unsigned
char
*
dst
=
reinterpret_cast
<
unsigned
char
*>
(
freenect
->
coloredDepth
);
for
(
int
i
=
0
;
i
<
FREENECT_FRAME_PIX
;
++
i
)
{
unsigned
short
pval
=
freenect
->
gammaTable
[
src
[
i
]];
unsigned
short
lb
=
pval
&
0xFF
;
switch
(
pval
>>
8
)
{
case
0
:
dst
[
3
*
i
]
=
255
;
dst
[
3
*
i
+
1
]
=
255
-
lb
;
dst
[
3
*
i
+
2
]
=
255
-
lb
;
break
;
case
1
:
dst
[
3
*
i
]
=
255
;
dst
[
3
*
i
+
1
]
=
lb
;
dst
[
3
*
i
+
2
]
=
0
;
break
;
case
2
:
dst
[
3
*
i
]
=
255
-
lb
;
dst
[
3
*
i
+
1
]
=
255
;
dst
[
3
*
i
+
2
]
=
0
;
break
;
case
3
:
dst
[
3
*
i
]
=
0
;
dst
[
3
*
i
+
1
]
=
255
;
dst
[
3
*
i
+
2
]
=
lb
;
break
;
case
4
:
dst
[
3
*
i
]
=
0
;
dst
[
3
*
i
+
1
]
=
255
-
lb
;
dst
[
3
*
i
+
2
]
=
255
;
break
;
case
5
:
dst
[
3
*
i
]
=
0
;
dst
[
3
*
i
+
1
]
=
0
;
dst
[
3
*
i
+
2
]
=
255
-
lb
;
break
;
default:
dst
[
3
*
i
]
=
0
;
dst
[
3
*
i
+
1
]
=
0
;
dst
[
3
*
i
+
2
]
=
0
;
break
;
}
}
}
src/input/Freenect.h
0 → 100644
View file @
6344a49d
#ifndef FREENECT_H
#define FREENECT_H
#include <libfreenect.h>
#include <QMutex>
#include <QScopedPointer>
#include <QSharedPointer>
#include <QThread>
class
Freenect
{
public:
Freenect
();
~
Freenect
();
bool
init
(
int
userDeviceNumber
=
0
);
bool
process
(
void
);
QSharedPointer
<
QByteArray
>
getRgbData
(
void
);
QSharedPointer
<
QByteArray
>
getRawDepthData
(
void
);
QSharedPointer
<
QByteArray
>
getDistanceData
(
void
);
QSharedPointer
<
QByteArray
>
getColoredDepthData
(
void
);
int
getTiltAngle
(
void
)
const
;
void
setTiltAngle
(
int
angle
);
private:
static
void
rgbCallback
(
freenect_device
*
device
,
freenect_pixel
*
rgb
,
uint32_t
timestamp
);
static
void
depthCallback
(
freenect_device
*
device
,
freenect_depth
*
depth
,
uint32_t
timestamp
);
freenect_context
*
context
;
freenect_device
*
device
;
class
FreenectThread
:
public
QThread
{
public:
explicit
FreenectThread
(
freenect_device
*
_device
);
protected:
virtual
void
run
(
void
);
freenect_device
*
device
;
};
QScopedPointer
<
FreenectThread
>
thread
;
// tilt angle of Kinect camera
int
tiltAngle
;
// rgbd data
char
rgb
[
FREENECT_RGB_SIZE
];
QMutex
rgbMutex
;
char
depth
[
FREENECT_DEPTH_SIZE
];
QMutex
depthMutex
;
float
distance
[
FREENECT_FRAME_PIX
];
QMutex
distanceMutex
;
char
coloredDepth
[
FREENECT_RGB_SIZE
];
QMutex
coloredDepthMutex
;
// accelerometer data
short
ax
,
ay
,
az
;
double
dx
,
dy
,
dz
;
// gamma map
unsigned
short
gammaTable
[
2048
];
};
#endif // FREENECT_H
src/ui/MainWindow.cc
View file @
6344a49d
...
...
@@ -47,7 +47,7 @@ This file is part of the QGROUNDCONTROL project
#include "GAudioOutput.h"
#ifdef QGC_OSG_ENABLED
#include "Q
Map3D
.h"
#include "Q
3DWidgetFactory
.h"
#endif
// FIXME Move
...
...
@@ -136,10 +136,13 @@ void MainWindow::buildWidgets()
protocolWidget
=
new
XMLCommProtocolWidget
(
this
);
dataplotWidget
=
new
QGCDataPlot2D
(
this
);
#ifdef QGC_OSG_ENABLED
//_3DWidget = Q3DWidgetFactory::get(QGC_MAP3D_OSGEARTH);
_3DWidget
=
new
QMap3D
(
this
);
_3DWidget
=
Q3DWidgetFactory
::
get
(
"PIXHAWK"
);
#endif
#ifdef QGC_OSGEARTH_ENABLED
_3DMapWidget
=
Q3DWidgetFactory
::
get
(
"MAP3D"
);
#endif
// Dock widgets
controlDockWidget
=
new
QDockWidget
(
tr
(
"Control"
),
this
);
controlDockWidget
->
setWidget
(
new
UASControlWidget
(
this
)
);
...
...
@@ -232,6 +235,9 @@ void MainWindow::arrangeCenterStack()
if
(
mapWidget
)
centerStack
->
addWidget
(
mapWidget
);
#ifdef QGC_OSG_ENABLED
if
(
_3DWidget
)
centerStack
->
addWidget
(
_3DWidget
);
#endif
#ifdef QGC_OSGEARTH_ENABLED
if
(
_3DMapWidget
)
centerStack
->
addWidget
(
_3DMapWidget
);
#endif
if
(
hudWidget
)
centerStack
->
addWidget
(
hudWidget
);
if
(
dataplotWidget
)
centerStack
->
addWidget
(
dataplotWidget
);
...
...
@@ -373,6 +379,7 @@ void MainWindow::connectActions()
connect
(
ui
.
actionEngineerView
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
loadEngineerView
()));
connect
(
ui
.
actionOperatorView
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
loadOperatorView
()));
connect
(
ui
.
action3DView
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
load3DView
()));
connect
(
ui
.
action3DMapView
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
load3DMapView
()));
connect
(
ui
.
actionShow_full_view
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
loadAllView
()));
connect
(
ui
.
actionShow_MAVLink_view
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
loadMAVLinkView
()));
connect
(
ui
.
actionShow_data_analysis_view
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
loadDataView
()));
...
...
@@ -672,7 +679,7 @@ void MainWindow::loadPixhawkView()
clearView
();
// Engineer view, used in EMAV2009
#ifdef QGC_OSG_ENABLED
#ifdef QGC_OSG_ENABLED
// 3D map
if
(
_3DWidget
)
{
...
...
@@ -960,6 +967,60 @@ void MainWindow::loadGlobalOperatorView()
}
void
MainWindow
::
load3DMapView
()
{
#ifdef QGC_OSGEARTH_ENABLED
clearView
();
// 3D map
if
(
_3DMapWidget
)
{
QStackedWidget
*
centerStack
=
dynamic_cast
<
QStackedWidget
*>
(
centralWidget
());
if
(
centerStack
)
{
//map3DWidget->setActive(true);
centerStack
->
setCurrentWidget
(
_3DMapWidget
);
}
}
// UAS CONTROL
if
(
controlDockWidget
)
{
addDockWidget
(
Qt
::
LeftDockWidgetArea
,
controlDockWidget
);
controlDockWidget
->
show
();
}
// UAS LIST
if
(
listDockWidget
)