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 {
...
@@ -34,9 +34,17 @@ release {
# DEFINES += QT_NO_WARNING_OUTPUT
# 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
# MAC OS X
macx {
macx {
COMPILER_VERSION = $$system(gcc -v)
message(Using compiler $$COMPILER_VERSION)
HARDWARE_PLATFORM = $$system(uname -a)
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 ) {
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
# x86 Mac OS X Leopard 10.5 and earlier
...
@@ -55,18 +63,15 @@ macx {
...
@@ -55,18 +63,15 @@ macx {
message(Building for Mac OS X 64bit/Snow Leopard 10.6 and later)
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
DESTDIR = $$BASEDIR/bin/mac
INCLUDEPATH += -framework SDL \
INCLUDEPATH += -framework SDL
$$BASEDIR/../mavlink/contrib/slugs/include \
$$BASEDIR/../mavlink/include
LIBS += -framework IOKit \
LIBS += -framework IOKit \
-framework SDL \
-framework SDL \
-framework CoreFoundation \
-framework CoreFoundation \
-framework ApplicationServices \
-framework ApplicationServices \
# -framework GLUT \
-lm
-lm
ICON = $$BASEDIR/images/icons/macx.icns
ICON = $$BASEDIR/images/icons/macx.icns
...
@@ -74,24 +79,67 @@ macx {
...
@@ -74,24 +79,67 @@ macx {
# Copy audio files if needed
# Copy audio files if needed
QMAKE_PRE_LINK += cp -rf $$BASEDIR/audio $$DESTDIR/qgroundcontrol.app/Contents/MacOs/.
QMAKE_PRE_LINK += cp -rf $$BASEDIR/audio $$DESTDIR/qgroundcontrol.app/Contents/MacOs/.
exists(/opt/local/lib/osg):exists("/opt/local/lib/osgEarth") {
exists(/Library/Frameworks/osg.framework):exists(/Library/Frameworks/OpenThreads.framework) {
message("Building support for OSGEARTH")
# No check for GLUT.framework since it's a MAC default
DEPENDENCIES_PRESENT += osgearth
message("Building support for OpenSceneGraph")
LIBS += -L/opt/local/lib/
DEPENDENCIES_PRESENT += osg
INCLUDEPATH += /opt/local/include
# Include OpenSceneGraph and osgEarth libraries
LIBS += -losg \
-losgViewer \
-losgEarth \
-losgEarthUtil
DEFINES += QGC_OSG_ENABLED
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
# GNU/Linux
linux-g++ {
linux-g++ {
CONFIG += debug
debug {
debug {
DESTDIR = $$BUILDDIR/debug
DESTDIR = $$BUILDDIR/debug
...
@@ -131,21 +179,41 @@ linux-g++ {
...
@@ -131,21 +179,41 @@ linux-g++ {
-lSDL \
-lSDL \
-lSDLmain
-lSDLmain
exists(/usr/include/osgEarth) | exists(/usr/local/include/osgEarth) {
exists(/usr/include/osg) {
message("Building support for OSGEARTH")
message("Building support for OpenSceneGraph")
DEPENDENCIES_PRESENT += osgearth
DEPENDENCIES_PRESENT += osg
# Include OpenSceneGraph and osgEarth libraries
# Include OpenSceneGraph libraries
LIBS += -losg \
LIBS += -losg
-losgViewer \
DEFINES += QGC_OSG_ENABLED
-losgEarth \
}
-losgEarthUtil
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 \
QMAKE_PRE_LINK += && cp -rf $$BASEDIR/models $$TARGETDIR/debug/.
#-lflite_cmu_us_slt \
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 {
linux-g++-64 {
...
@@ -188,16 +256,36 @@ linux-g++-64 {
...
@@ -188,16 +256,36 @@ linux-g++-64 {
-lSDL \
-lSDL \
-lSDLmain
-lSDLmain
exists(/usr/lib/osg):exists(/usr/lib/osgEarth) {
exists(/usr/include/osg) {
message("Building support for OSGEARTH")
message("Building support for OpenSceneGraph")
DEPENDENCIES_PRESENT += osgearth
DEPENDENCIES_PRESENT += osg
# Include OpenSceneGraph and osgEarth libraries
# Include OpenSceneGraph libraries
LIBS += -losg \
LIBS += -losg
-losgViewer \
DEFINES += QGC_OSG_ENABLED
-losgEarth
}
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)
# Windows (32bit)
...
@@ -222,7 +310,13 @@ win32-msvc2008 {
...
@@ -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/debug/. &&
QMAKE_PRE_LINK += cp -f $$BASEDIR/lib/sdl/win32/SDL.dll $$TARGETDIR/release/. &&
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/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)
# Windows (32bit)
...
@@ -255,8 +349,14 @@ win32-g++ {
...
@@ -255,8 +349,14 @@ win32-g++ {
# Copy dependencies
# 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/debug/. &&
QMAKE_PRE_LINK += cp -f $$BASEDIR/lib/sdl/win32/SDL.dll $$BUILDDIR/release/. &&
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 $$TARGETDIR/debug/. &&
QMAKE_PRE_LINK += cp -rf $$BASEDIR/audio $$BUILDDIR/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 (64bit)
# Windows (64bit)
...
@@ -291,5 +391,8 @@ win64-g++ {
...
@@ -291,5 +391,8 @@ win64-g++ {
QMAKE_PRE_LINK += cp -f $$BASEDIR/lib/sdl/win32/SDL.dll $$BUILDDIR/release/. &&
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/debug/. &&
QMAKE_PRE_LINK += cp -rf $$BASEDIR/audio $$BUILDDIR/release/.
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 \
...
@@ -231,18 +231,35 @@ HEADERS += src/MG.h \
src
/
ui
/
RadioCalibration
/
CurveCalibrator
.
h
\
src
/
ui
/
RadioCalibration
/
CurveCalibrator
.
h
\
src
/
ui
/
RadioCalibration
/
AbstractCalibrator
.
h
\
src
/
ui
/
RadioCalibration
/
AbstractCalibrator
.
h
\
src
/
comm
/
QGCMAVLink
.
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
#
Enable
only
if
OpenSceneGraph
is
available
HEADERS
+=
src
/
ui
/
map3D
/
Q3DWidget
.
h
\
HEADERS
+=
src
/
ui
/
map3D
/
Q3DWidget
.
h
\
src
/
ui
/
map3D
/
GCManipulator
.
h
\
src
/
ui
/
map3D
/
ImageWindowGeode
.
h
\
src
/
ui
/
map3D
/
QOSGWidget
.
h
\
src
/
ui
/
map3D
/
QOSGWidget
.
h
\
src
/
ui
/
map3D
/
QMap3D
.
h
\
src
/
ui
/
map3D
/
PixhawkCheetahGeode
.
h
\
src
/
ui
/
map3D
/
PixhawkCheetahGeode
.
h
\
src
/
ui
/
map3D
/
Pixhawk3DWidget
.
h
\
src
/
ui
/
map3D
/
Pixhawk3DWidget
.
h
\
src
/
ui
/
map3D
/
Q3DWidgetFactory
.
h
\
src
/
ui
/
map3D
/
Q3DWidgetFactory
.
h
src
/
ui
/
map3D
/
GCManipulator
.
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
\
SOURCES
+=
src
/
main
.
cc
\
src
/
Core
.
cc
\
src
/
Core
.
cc
\
src
/
uas
/
UASManager
.
cc
\
src
/
uas
/
UASManager
.
cc
\
...
@@ -311,19 +328,39 @@ SOURCES += src/main.cc \
...
@@ -311,19 +328,39 @@ SOURCES += src/main.cc \
src
/
ui
/
RadioCalibration
/
SwitchCalibrator
.
cc
\
src
/
ui
/
RadioCalibration
/
SwitchCalibrator
.
cc
\
src
/
ui
/
RadioCalibration
/
CurveCalibrator
.
cc
\
src
/
ui
/
RadioCalibration
/
CurveCalibrator
.
cc
\
src
/
ui
/
RadioCalibration
/
AbstractCalibrator
.
cc
\
src
/
ui
/
RadioCalibration
/
AbstractCalibrator
.
cc
\
src
/
ui
/
RadioCalibration
/
RadioCalibrationData
.
cc
#
src
/
ui
/
WaypointGlobalView
.
cc
\
src
/
ui
/
RadioCalibration
/
RadioCalibrationData
.
cc
contains
(
DEPENDENCIES_PRESENT
,
osgearth
)
{
message
(
"Including sources for OSGEARTH"
)
contains
(
DEPENDENCIES_PRESENT
,
osg
)
{
message
(
"Including sources for OpenSceneGraph"
)
#
Enable
only
if
OpenSceneGraph
is
available
#
Enable
only
if
OpenSceneGraph
is
available
SOURCES
+=
src
/
ui
/
map3D
/
Q3DWidget
.
cc
\
SOURCES
+=
src
/
ui
/
map3D
/
Q3DWidget
.
cc
\
src
/
ui
/
map3D
/
QOSGWidget
.
cc
\
src
/
ui
/
map3D
/
ImageWindowGeode
.
cc
\
src
/
ui
/
map3D
/
QMap3D
.
cc
\
src
/
ui
/
map3D
/
GCManipulator
.
cc
\
src
/
ui
/
map3D
/
QOSGWidget
.
cc
\
src
/
ui
/
map3D
/
PixhawkCheetahGeode
.
cc
\
src
/
ui
/
map3D
/
PixhawkCheetahGeode
.
cc
\
src
/
ui
/
map3D
/
Pixhawk3DWidget
.
cc
\
src
/
ui
/
map3D
/
Pixhawk3DWidget
.
cc
\
src
/
ui
/
map3D
/
Q3DWidgetFactory
.
cc
\
src
/
ui
/
map3D
/
Q3DWidgetFactory
.
cc
src
/
ui
/
map3D
/
GCManipulator
.
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
RESOURCES
+=
mavground
.
qrc
#
Include
RT
-
LAB
Library
#
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
...
@@ -47,7 +47,7 @@ This file is part of the QGROUNDCONTROL project
#include "GAudioOutput.h"
#include "GAudioOutput.h"
#ifdef QGC_OSG_ENABLED
#ifdef QGC_OSG_ENABLED
#include "Q
Map3D
.h"
#include "Q
3DWidgetFactory
.h"
#endif
#endif
// FIXME Move
// FIXME Move
...
@@ -136,10 +136,13 @@ void MainWindow::buildWidgets()
...
@@ -136,10 +136,13 @@ void MainWindow::buildWidgets()
protocolWidget
=
new
XMLCommProtocolWidget
(
this
);
protocolWidget
=
new
XMLCommProtocolWidget
(
this
);
dataplotWidget
=
new
QGCDataPlot2D
(
this
);
dataplotWidget
=
new
QGCDataPlot2D
(
this
);
#ifdef QGC_OSG_ENABLED
#ifdef QGC_OSG_ENABLED
//_3DWidget = Q3DWidgetFactory::get(QGC_MAP3D_OSGEARTH);
_3DWidget
=
Q3DWidgetFactory
::
get
(
"PIXHAWK"
);
_3DWidget
=
new
QMap3D
(
this
);
#endif
#endif