From: kathy Date: Wed, 22 Dec 2010 10:21:59 +0000 (+0200) Subject: first import X-Git-Url: https://vcs.maemo.org/git/?p=mardrone;a=commitdiff_plain;h=5c7bd9dd6553426975ff21d029f59e0134f25394 first import --- diff --git a/mardrone/BarGauge.qml b/mardrone/BarGauge.qml new file mode 100644 index 0000000..7b7ce66 --- /dev/null +++ b/mardrone/BarGauge.qml @@ -0,0 +1,16 @@ +import Qt 4.7 + +Rectangle { + color:"#00000000" + border.color: "black" + width: 20 + height: 100 + property int val:0 + property int max:100 + Rectangle { + color:"green" + anchors.bottom: parent.bottom + height:parent.height*val/max + width: parent.width + } +} diff --git a/mardrone/ConfigDialog.qml b/mardrone/ConfigDialog.qml new file mode 100644 index 0000000..a4fed33 --- /dev/null +++ b/mardrone/ConfigDialog.qml @@ -0,0 +1,142 @@ +import Qt 4.7 +import com.meego 1.0 +Page { + id:dialog + Flickable { + id: dialogscrolarea + anchors.top: parent.top + anchors.bottom: parent.bottom + width: parent.width + anchors.leftMargin:50;anchors.rightMargin:50 + + /* anchors.horizontalCenter:parent.horizontalCenter */ + + contentHeight: dialogcontent.height + contentWidth: parent.width + + Grid { + columns:2 + id: dialogcontent + // width: parent.width + anchors.left:parent.left;anchors.right:parent.right + anchors.leftMargin:50;anchors.rightMargin:50 + + spacing: 30 + Text { + width:400 + text: "Drone IP" + + } + LineEdit { + id: droneip + width:300 + text: drone.confDroneIp + onTextChanged:{drone.confDroneIp=text;} + } + + Text { + text: "Video 640x480 / Full Screen" + } + Switch { + id: fullScreen + // enabled:drone.confFullScreen + checked:drone.confFullScreen + anchors.right:parent.right + // onEnabledChanged:{drone.confFullScreen=enabled;} + onCheckedChanged:{drone.confFullScreen=checked;} + } + + Text { + text: "Show debug" + } + Switch { + id: showDebug + // enabled:drone.confShowDebug + checked:drone.confShowDebug + anchors.right:parent.right +// onEnabledChanged:{drone.confShowDebug=enabled;} + onCheckedChanged:{drone.confShowDebug=checked;} + } + + Text { + text: "Show engine gauges" + + } + Switch { + id: showGauges +// enabled:drone.confShowGauges + checked:drone.confShowGauges + anchors.right:parent.right +// onEnabledChanged:{drone.confShowGauges=enabled;} + onCheckedChanged:{drone.confShowGauges=checked;} + } + + Text { + text: "Show horizon" + + } + Switch { + id: showHorizon + checked:drone.confShowHorizon + anchors.right:parent.right + onCheckedChanged:{drone.onfconfShowHorizon=enabled;} + } + + Text { + text: "Forward gain" + } + + Slider { + id: forwardGain + anchors.right:parent.right + maximumValue:1.0 + // stepSize:0.01 + steps:0.01 + value:drone.confForwardGain + onValueChanged:{drone.confForwardGain=value;} + } + Text { + text: "Backward gain" + } + + Slider { + id: backwardGain + anchors.right:parent.right + maximumValue:1.0 + // stepSize:0.01 + steps:0.01 + value:drone.confBackwardGain + onValueChanged:{drone.confBackwardGain=value;} + } + + Text { + text: "Left gain" + } + + Slider { + id: leftGain + anchors.right:parent.right + maximumValue:1.0 + // stepSize:0.01 + steps:0.01 + value:drone.confLeftGain + onValueChanged:{drone.confLeftGain=value;} + } + + Text { + text: "Right gain" + } + + Slider { + id: rightGain + anchors.right:parent.right + maximumValue:1.0 + // stepSize:0.01 + steps:0.01 + value:drone.confRightGain + onValueChanged:{drone.confRightGain=value;} + } + + } + } + } diff --git a/mardrone/JoyStick.qml b/mardrone/JoyStick.qml new file mode 100644 index 0000000..858c214 --- /dev/null +++ b/mardrone/JoyStick.qml @@ -0,0 +1,35 @@ +import Qt 4.7 + +Item { + id:joystick + property int xv:(knob.x-(width-knob.width)/2)*(200/(width-knob.width)) + property int yv:(knob.y-(height-knob.height)/2)*(200/(height-knob.height)) + width: 200 + height: 200 + + Rectangle { + id:knob + x:parent.width/2-width/2 + y:parent.width/2-height/2 + width:20; + height:20; + Image { + anchors.centerIn:parent + id: knobimage + source: "joyknob.png" + } + + //color:"black" + } + MouseArea { + id:mouse_area + anchors.fill:parent + drag.minimumX:0 + drag.minimumY:0 + drag.maximumX:parent.width-knob.width + drag.maximumY:parent.height-knob.height + drag.target:knob; + onReleased:{knob.x=parent.width/2-knob.width/2;knob.y=parent.height/2-knob.height/2 + } + } + } diff --git a/mardrone/JoyStick2.qml b/mardrone/JoyStick2.qml new file mode 100644 index 0000000..2e5aaef --- /dev/null +++ b/mardrone/JoyStick2.qml @@ -0,0 +1,81 @@ +import Qt 4.7 +import Qt.labs.gestures 2.0 + + +Rectangle { + id:joystick2 + property int xv:(knob.x-(width-knob.width)/2)*(200/(width-knob.width)) + property int yv:(knob.y-(height-knob.height)/2)*(200/(height-knob.height)) + width: 200 + height: 200 + Text { + id: xtext + text:xv + } + Text { + id: ytext + x:40 + text: yv + } + Text { + id: msg + x:100 + text: "" + } + + + + Rectangle { + id:knob + x:parent.width/2-width/2 + y:parent.width/2-height/2 + width:20; + height:20; + color:"black" + } + GestureArea { + anchors.fill: parent + focus: true + + // Only some of the many gesture properties are shown. See Gesture documentation. + +/* + Default { + + onStarted: console.log("onStarted pos = (",gesture.position.x,",",gesture.position.y,")") + onFinished:console.log("onFinished pos = (",gesture.position.x,",",gesture.position.y,")") + onUpdated: console.log("onUpdated pos = (",gesture.position.x,",",gesture.position.y,")"); + } + */ +/* + Tap { + onStarted:console.log("tap onStarted pos = (",gesture.position.x,",",gesture.position.y,")") + onFinished:console.log("tap onFinished pos = (",gesture.position.x,",",gesture.position.y,")") + onUpdated:{ + console.log("tap onUpdated pos = (",gesture.position.x,",",gesture.position.y,")"); + // msg.text=gesture.position.x+","+gesture.position.y + } + } + //onTapAndHold: + // console.log("tap and hold pos = (",gesture.position.x,",",gesture.position.y,")") +*/ + Pan { + onStarted: console.log("pan onStarted delta = (",gesture.delta.x,",",gesture.delta.y,") acceleration = ",gesture.acceleration) + onFinished:console.log("pan onFinished delta = (",gesture.delta.x,",",gesture.delta.y,") acceleration = ",gesture.acceleration) + onUpdated: { + console.log("pan onUpdated pos = (",gesture.delta.x,",",gesture.delta.y,")"); + msg.text=gesture.delta.x+","+gesture.delta.y; + } + } + + /* + onPinch: + console.log("pinch center = (",gesture.centerPoint.x,",",gesture.centerPoint.y,") rotation =",gesture.rotationAngle," scale =",gesture.scaleFactor) + onSwipe: + console.log("swipe angle=",gesture.swipeAngle) + onGesture: + console.log("gesture hot spot = (",gesture.hotSpot.x,",",gesture.hotSpot.y,")") + */ + } + +} diff --git a/mardrone/Makefile b/mardrone/Makefile new file mode 100644 index 0000000..aacec08 --- /dev/null +++ b/mardrone/Makefile @@ -0,0 +1,334 @@ +############################################################################# +# Makefile for building: mardrone +# Generated by qmake (2.01a) (Qt 4.7.0) on: Wed Dec 22 12:21:11 2010 +# Project: mardrone.pro +# Template: app +# Command: /usr/bin/qmake -o Makefile mardrone.pro +############################################################################# + +####### Compiler, tools and options + +CC = gcc +CXX = g++ +DEFINES = -DQT_GL_NO_SCISSOR_TEST -DQT_DEFAULT_TEXTURE_GLYPH_CACHE_WIDTH=1024 -DQT_NO_DEBUG -DQT_DECLARATIVE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED +CFLAGS = -pipe -O3 -fno-omit-frame-pointer -fno-optimize-sibling-calls -Wall -W -D_REENTRANT $(DEFINES) +CXXFLAGS = -pipe -O3 -fno-omit-frame-pointer -fno-optimize-sibling-calls -Wall -W -D_REENTRANT $(DEFINES) +INCPATH = -I/targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/linux-g++-maemo5 -I. -I/targets/FREMANTLE_ARMEL/usr/include/QtCore -I/targets/FREMANTLE_ARMEL/usr/include/QtNetwork -I/targets/FREMANTLE_ARMEL/usr/include/QtGui -I/targets/FREMANTLE_ARMEL/usr/include/QtDeclarative -I/targets/FREMANTLE_ARMEL/usr/include -I../../../../ARDrone_SDK_1_5_Version_20101004/ARDroneLib/Soft/Common -I../../../../ARDrone_SDK_1_5_Version_20101004/ARDroneLib/VP_SDK -I../../../../ARDrone_SDK_1_5_Version_20101004/ARDroneLib/VP_SDK/VP_Os/linux -I../../../../ARDrone_SDK_1_5_Version_20101004/ARDroneLib/VP_SDK/VP_Os -I../../../../ARDrone_SDK_1_5_Version_20101004/ARDroneLib/Soft/Lib -I../../../../ARDrone_SDK_1_5_Version_20101004/ARDroneLib/VLIB -I../../../../ARDrone_SDK_1_5_Version_20101004/ARDroneLib -I. +LINK = g++ +LFLAGS = -Wl,-rpath-link,/usr/lib -Wl,-O1 -Wl,--hash-style=gnu +LIBS = $(SUBLIBS) -L/usr/lib -lQtComponents -L/home/kathy/ARDrone_SDK_1_5_Version_20101004/lib -lvlib -lsdk -lQtDeclarative -L/usr/lib -L/usr/X11R6/lib -lQtScript -lQtSvg -lQtSql -lQtXmlPatterns -lQtOpenGL -lQtGui -lQtNetwork -lQtDBus -lQtXml -lQtCore -lpthread +AR = ar cqs +RANLIB = +QMAKE = /usr/bin/qmake +TAR = tar -cf +COMPRESS = gzip -9f +COPY = cp -f +SED = sed +COPY_FILE = $(COPY) +COPY_DIR = $(COPY) -r +STRIP = strip +INSTALL_FILE = install -m 644 -p +INSTALL_DIR = $(COPY_DIR) +INSTALL_PROGRAM = install -m 755 -p +DEL_FILE = rm -f +SYMLINK = ln -f -s +DEL_DIR = rmdir +MOVE = mv -f +CHK_DIR_EXISTS= test -d +MKDIR = mkdir -p + +####### Output directory + +OBJECTS_DIR = ./ + +####### Files + +SOURCES = main.cpp \ + dronecontrol.cpp \ + navdata.cpp \ + video.cpp \ + gauge.cpp \ + gaugelabel.cpp \ + gaugehorizon.cpp moc_dronecontrol.cpp \ + moc_navdata.cpp \ + moc_video.cpp \ + moc_gauge.cpp \ + moc_gaugelabel.cpp \ + moc_gaugehorizon.cpp \ + qrc_ardrone.cpp +OBJECTS = main.o \ + dronecontrol.o \ + navdata.o \ + video.o \ + gauge.o \ + gaugelabel.o \ + gaugehorizon.o \ + moc_dronecontrol.o \ + moc_navdata.o \ + moc_video.o \ + moc_gauge.o \ + moc_gaugelabel.o \ + moc_gaugehorizon.o \ + qrc_ardrone.o +DIST = /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/common/unix.conf \ + /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/common/linux.conf \ + /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/qconfig.pri \ + /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \ + /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/qt_functions.prf \ + /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/qt_config.prf \ + /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/exclusive_builds.prf \ + /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/default_pre.prf \ + /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/release.prf \ + /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/default_post.prf \ + /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/warn_on.prf \ + /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/qt.prf \ + /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/unix/thread.prf \ + /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/moc.prf \ + /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/resources.prf \ + /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/uic.prf \ + /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/yacc.prf \ + /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/lex.prf \ + /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/include_source_dir.prf \ + mardrone.pro +QMAKE_TARGET = mardrone +DESTDIR = +TARGET = mardrone + +first: all +####### Implicit rules + +.SUFFIXES: .o .c .cpp .cc .cxx .C + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.C.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<" + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<" + +####### Build rules + +all: Makefile $(TARGET) + +$(TARGET): $(OBJECTS) + $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) + +Makefile: mardrone.pro /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/linux-g++-maemo5/qmake.conf /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/common/unix.conf \ + /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/common/linux.conf \ + /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/qconfig.pri \ + /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \ + /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/qt_functions.prf \ + /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/qt_config.prf \ + /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/exclusive_builds.prf \ + /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/default_pre.prf \ + /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/release.prf \ + /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/default_post.prf \ + /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/warn_on.prf \ + /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/qt.prf \ + /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/unix/thread.prf \ + /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/moc.prf \ + /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/resources.prf \ + /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/uic.prf \ + /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/yacc.prf \ + /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/lex.prf \ + /targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/include_source_dir.prf \ + /usr/lib/libQtDeclarative.prl \ + /usr/lib/libQtScript.prl \ + /usr/lib/libQtCore.prl \ + /usr/lib/libQtSvg.prl \ + /usr/lib/libQtGui.prl \ + /usr/lib/libQtDBus.prl \ + /usr/lib/libQtXml.prl \ + /usr/lib/libQtSql.prl \ + /usr/lib/libQtXmlPatterns.prl \ + /usr/lib/libQtNetwork.prl \ + /usr/lib/libQtOpenGL.prl + $(QMAKE) -o Makefile mardrone.pro +/targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/common/unix.conf: +/targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/common/linux.conf: +/targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/qconfig.pri: +/targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/modules/qt_webkit_version.pri: +/targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/qt_functions.prf: +/targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/qt_config.prf: +/targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/exclusive_builds.prf: +/targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/default_pre.prf: +/targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/release.prf: +/targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/default_post.prf: +/targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/warn_on.prf: +/targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/qt.prf: +/targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/unix/thread.prf: +/targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/moc.prf: +/targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/resources.prf: +/targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/uic.prf: +/targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/yacc.prf: +/targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/lex.prf: +/targets/FREMANTLE_ARMEL/usr/share/qt4/mkspecs/features/include_source_dir.prf: +/usr/lib/libQtDeclarative.prl: +/usr/lib/libQtScript.prl: +/usr/lib/libQtCore.prl: +/usr/lib/libQtSvg.prl: +/usr/lib/libQtGui.prl: +/usr/lib/libQtDBus.prl: +/usr/lib/libQtXml.prl: +/usr/lib/libQtSql.prl: +/usr/lib/libQtXmlPatterns.prl: +/usr/lib/libQtNetwork.prl: +/usr/lib/libQtOpenGL.prl: +qmake: FORCE + @$(QMAKE) -o Makefile mardrone.pro + +dist: + @$(CHK_DIR_EXISTS) .tmp/mardrone1.0.0 || $(MKDIR) .tmp/mardrone1.0.0 + $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/mardrone1.0.0/ && $(COPY_FILE) --parents dronecontrol.h navdata.h video.h gauge.h gaugelabel.h gaugehorizon.h .tmp/mardrone1.0.0/ && $(COPY_FILE) --parents ardrone.qrc .tmp/mardrone1.0.0/ && $(COPY_FILE) --parents main.cpp dronecontrol.cpp navdata.cpp video.cpp gauge.cpp gaugelabel.cpp gaugehorizon.cpp .tmp/mardrone1.0.0/ && (cd `dirname .tmp/mardrone1.0.0` && $(TAR) mardrone1.0.0.tar mardrone1.0.0 && $(COMPRESS) mardrone1.0.0.tar) && $(MOVE) `dirname .tmp/mardrone1.0.0`/mardrone1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/mardrone1.0.0 + + +clean:compiler_clean + -$(DEL_FILE) $(OBJECTS) + -$(DEL_FILE) *~ core *.core + + +####### Sub-libraries + +distclean: clean + -$(DEL_FILE) $(TARGET) + -$(DEL_FILE) Makefile + + +check: first + +mocclean: compiler_moc_header_clean compiler_moc_source_clean + +mocables: compiler_moc_header_make_all compiler_moc_source_make_all + +compiler_moc_header_make_all: moc_dronecontrol.cpp moc_navdata.cpp moc_video.cpp moc_gauge.cpp moc_gaugelabel.cpp moc_gaugehorizon.cpp +compiler_moc_header_clean: + -$(DEL_FILE) moc_dronecontrol.cpp moc_navdata.cpp moc_video.cpp moc_gauge.cpp moc_gaugelabel.cpp moc_gaugehorizon.cpp +moc_dronecontrol.cpp: navdata.h \ + dronecontrol.h + /usr/bin/moc $(DEFINES) $(INCPATH) dronecontrol.h -o moc_dronecontrol.cpp + +moc_navdata.cpp: navdata.h + /usr/bin/moc $(DEFINES) $(INCPATH) navdata.h -o moc_navdata.cpp + +moc_video.cpp: dronecontrol.h \ + navdata.h \ + video.h + /usr/bin/moc $(DEFINES) $(INCPATH) video.h -o moc_video.cpp + +moc_gauge.cpp: gauge.h + /usr/bin/moc $(DEFINES) $(INCPATH) gauge.h -o moc_gauge.cpp + +moc_gaugelabel.cpp: gauge.h \ + gaugelabel.h + /usr/bin/moc $(DEFINES) $(INCPATH) gaugelabel.h -o moc_gaugelabel.cpp + +moc_gaugehorizon.cpp: gauge.h \ + gaugehorizon.h + /usr/bin/moc $(DEFINES) $(INCPATH) gaugehorizon.h -o moc_gaugehorizon.cpp + +compiler_rcc_make_all: qrc_ardrone.cpp +compiler_rcc_clean: + -$(DEL_FILE) qrc_ardrone.cpp +qrc_ardrone.cpp: ardrone.qrc \ + joyknob.png \ + joybox.png \ + BarGauge.qml \ + ConfigDialog.qml \ + ardrone.qml \ + JoyStick.qml + /usr/bin/rcc -name ardrone ardrone.qrc -o qrc_ardrone.cpp + +compiler_image_collection_make_all: qmake_image_collection.cpp +compiler_image_collection_clean: + -$(DEL_FILE) qmake_image_collection.cpp +compiler_moc_source_make_all: +compiler_moc_source_clean: +compiler_uic_make_all: +compiler_uic_clean: +compiler_yacc_decl_make_all: +compiler_yacc_decl_clean: +compiler_yacc_impl_make_all: +compiler_yacc_impl_clean: +compiler_lex_make_all: +compiler_lex_clean: +compiler_clean: compiler_moc_header_clean compiler_rcc_clean + +####### Compile + +main.o: main.cpp dronecontrol.h \ + navdata.h \ + video.h \ + gaugehorizon.h \ + gauge.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp + +dronecontrol.o: dronecontrol.cpp dronecontrol.h \ + navdata.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o dronecontrol.o dronecontrol.cpp + +navdata.o: navdata.cpp navdata.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o navdata.o navdata.cpp + +video.o: video.cpp video.h \ + dronecontrol.h \ + navdata.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o video.o video.cpp + +gauge.o: gauge.cpp gauge.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o gauge.o gauge.cpp + +gaugelabel.o: gaugelabel.cpp gaugelabel.h \ + gauge.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o gaugelabel.o gaugelabel.cpp + +gaugehorizon.o: gaugehorizon.cpp gaugehorizon.h \ + gauge.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o gaugehorizon.o gaugehorizon.cpp + +moc_dronecontrol.o: moc_dronecontrol.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_dronecontrol.o moc_dronecontrol.cpp + +moc_navdata.o: moc_navdata.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_navdata.o moc_navdata.cpp + +moc_video.o: moc_video.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_video.o moc_video.cpp + +moc_gauge.o: moc_gauge.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_gauge.o moc_gauge.cpp + +moc_gaugelabel.o: moc_gaugelabel.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_gaugelabel.o moc_gaugelabel.cpp + +moc_gaugehorizon.o: moc_gaugehorizon.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_gaugehorizon.o moc_gaugehorizon.cpp + +qrc_ardrone.o: qrc_ardrone.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o qrc_ardrone.o qrc_ardrone.cpp + +####### Install + +install_target: first FORCE + @$(CHK_DIR_EXISTS) $(INSTALL_ROOT)/opt/usr/bin/ || $(MKDIR) $(INSTALL_ROOT)/opt/usr/bin/ + -$(INSTALL_PROGRAM) "$(QMAKE_TARGET)" "$(INSTALL_ROOT)/opt/usr/bin/$(QMAKE_TARGET)" + -$(STRIP) "$(INSTALL_ROOT)/opt/usr/bin/$(QMAKE_TARGET)" + +uninstall_target: FORCE + -$(DEL_FILE) "$(INSTALL_ROOT)/opt/usr/bin/$(QMAKE_TARGET)" + -$(DEL_DIR) $(INSTALL_ROOT)/opt/usr/bin/ + + +install: install_target FORCE + +uninstall: uninstall_target FORCE + +FORCE: + diff --git a/mardrone/ardrone.qml b/mardrone/ardrone.qml new file mode 100644 index 0000000..2d8af42 --- /dev/null +++ b/mardrone/ardrone.qml @@ -0,0 +1,160 @@ +import Qt 4.7 +import com.meego 1.0 +import Drone 1.0 + + +Window { + id:mainWindow + fullscreen:true + property Component dialogComponent +// property alias m: mainPage + DroneControl { + id:drone + } + + Component { + id: mainpageComponent + Page { + id:mainPage + onEntered:(mainWindow.fullscreen=true) + + state:"Landscape" + DroneVideo { + y:0 + x:00 + anchors.horizontalCenter:parent.horizontalCenter + width:drone.confFullScreen? parent.width:640 ;height:480*width/640; + } + + GaugeHorizon { + y:0 + x:100 + visible:drone.confShowHorizon + value:drone.droneRoll + value2:drone.dronePitch +// value:lj.xv +// value2:lj.yv + opacity:0.5 + width:640;height:480; + } + + Text { + y:115 + visible:drone.confShowDebug + color: "#00FF00" + id: droneNavData + font.pixelSize:20 + text: "pitch=" + Math.round(drone.dronePitch) + " roll= " + Math.round(drone.droneRoll) + "yaw=" + Math.round(drone.droneYaw) + " alt= " + Math.round(drone.droneAltitude) + } + + Text { + y:130 + visible:drone.confShowDebug + color: "#00FF00" + id: droneStatus + font.pixelSize:20 + text: drone.decodedStatus + } + Button { + y:150;x:0 + height: 50 + width: 50 + text: "conf" + onClicked:{ mainWindow.fullscreen = false ; + mainWindow.nextPage(dialogComponent) + } + } + Image { + x:10;y:200 + width:280;height:280; + source: "joybox.png" + + JoyStick { + id:lj + anchors.fill:parent + anchors.margins:50 + onYvChanged:{drone.pitch=yv;} + onXvChanged:{drone.roll=xv;} + + + } + } + Image { + y:200 + anchors.right:parent.right + width:280;height:280; + source: "joybox.png" + JoyStick { + id:rj + anchors.fill:parent + anchors.margins:50 + onYvChanged:{drone.vVelocity=yv;} + onXvChanged:{drone.yaw=xv;} + } + } + Row { + spacing: 5 + anchors.right:parent.right + anchors.rightMargin: 10 + y:100 + height:100 + BarGauge { + val:drone.pwm_motor1; + max: 255 + height:100 + } + BarGauge { + val:drone.pwm_motor2; + max: 255 + height:100 + } + BarGauge { + val:drone.pwm_motor3; + max: 255 + height:100 + } + BarGauge { + val:drone.pwm_motor4; + max: 255 + height:100 + } + BarGauge { + val:drone.droneVBat + max: 100 + height:100 + } + } + + Button { + x:400 + width:60 + id:flyButton + anchors.bottom:parent.bottom + anchors.margins:15 + text:"Fly"; + checkable:true + onClicked:{drone.fly=checked; + // mainWindow.fullsecreen=checked; + } + } + Button { + x:400;y:100 + width:120 + id:emergencyButton + anchors.top:parent.top + anchors.margins:15 + text:"Energency"; + checkable:true + onClicked:{drone.emergency=checked;} + } + + } // Main page + } + + Component.onCompleted: { + mainWindow.fullscreen = true ; + dialogComponent = Qt.createComponent("ConfigDialog.qml"); + mainWindow.nextPage(mainpageComponent) + + } + } diff --git a/mardrone/ardrone.qrc b/mardrone/ardrone.qrc new file mode 100644 index 0000000..1025c12 --- /dev/null +++ b/mardrone/ardrone.qrc @@ -0,0 +1,10 @@ + + + ardrone.qml + BarGauge.qml + ConfigDialog.qml + JoyStick.qml + joybox.png + joyknob.png + + diff --git a/mardrone/ardrone1.pro.user b/mardrone/ardrone1.pro.user new file mode 100644 index 0000000..844065e --- /dev/null +++ b/mardrone/ardrone1.pro.user @@ -0,0 +1,572 @@ + + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + System + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop + Qt4ProjectManager.Target.DesktopTarget + 3 + 0 + 0 + + + + qmake + qmake + QtProjectManager.QMakeBuildStep + + + + Make + Make + Qt4ProjectManager.MakeStep + false + + sbox-make + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + Make + Make + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Qt in PATH Release + Qt in PATH Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + /mnt/hgfs/scratchbox/harmattan/qtdemo/ardrone1-build-desktop + 11 + 0 + true + + + + + qmake + qmake + QtProjectManager.QMakeBuildStep + + + + Make + Make + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + Make + Make + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + 4.5.0 Debug + 4.5.0 Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + /mnt/hgfs/scratchbox/harmattan/qtdemo/ardrone1-build-desktop + 6 + 0 + true + + + + + qmake + qmake + QtProjectManager.QMakeBuildStep + + + + Make + Make + Qt4ProjectManager.MakeStep + false + + sbox-make + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + Make + Make + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + 4.5.0 Release + 4.5.0 Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + /mnt/hgfs/scratchbox/harmattan/qtdemo/ardrone1-build-desktop + 11 + 0 + false + + + + + qmake + qmake + QtProjectManager.QMakeBuildStep + + + + Make + Make + Qt4ProjectManager.MakeStep + false + + make + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + Make + Make + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + 4.7.0 Debug + 4.7.0 Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + /mnt/hgfs/scratchbox/harmattan/qtdemo/ardrone1-build-desktop + 15 + 0 + true + + + + + qmake + qmake + QtProjectManager.QMakeBuildStep + + + + Make + Make + Qt4ProjectManager.MakeStep + false + + sbox-make + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + Make + Make + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + 4.7.0 Release + 4.7.0 Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + /mnt/hgfs/scratchbox/harmattan/qtdemo/ardrone1-build-desktop + 15 + 0 + false + + + + + qmake + + QtProjectManager.QMakeBuildStep + + + + Make + + Qt4ProjectManager.MakeStep + false + + sbox-qmake + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + Make + + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Sbox-qt Debug + + Qt4ProjectManager.Qt4BuildConfiguration + 2 + /mnt/hgfs/scratchbox/harmattan/qtdemo/ardrone1-build-desktop + 11 + 0 + false + + + + + qmake + + QtProjectManager.QMakeBuildStep + + + + Make + + Qt4ProjectManager.MakeStep + false + + sbox-make + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + Make + + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Sbox-qt Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + /mnt/hgfs/scratchbox/harmattan/qtdemo/ardrone1-build-desktop + 11 + 0 + false + + 7 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + No deployment + No deployment + ProjectExplorer.DefaultDeployConfiguration + + 1 + + ardrone1 + ardrone1 + Qt4ProjectManager.Qt4RunConfiguration + 2 + + ardrone1.pro + false + false + + false + + 3768 + true + false + + 1 + + + + ProjectExplorer.Project.Target.1 + + Maemo + Maemo + Qt4ProjectManager.Target.MaemoDeviceTarget + 0 + 0 + 0 + + + + + -d + sb/harmattan/qtdemo/ardrone1 + qmake + + /usr/bin/scratchbox + true + $BUILDDIR + Scratchbox qmake + Scratchbox qmake + ProjectExplorer.ProcessStep + + + + -d + sb/harmattan/qtdemo/ardrone1 + make + + /usr/bin/scratchbox + true + $BUILDDIR + Custom Process Step + Custom Process Step + ProjectExplorer.ProcessStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + Make + Make + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + /mnt/hgfs/scratchbox/harmattan/qtdemo/ardrone1-build-maemo + 5 + 9 + true + + + + + qmake + qmake + QtProjectManager.QMakeBuildStep + + + + Make + Make + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + Make + Make + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + /mnt/hgfs/scratchbox/harmattan/qtdemo/ardrone1-build-maemo + 5 + 9 + true + + 2 + + + + + + Qt4ProjectManager.MaemoDeployStep + true + 0 + + + + + + 1 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + Deploy to Maemo device + Deploy to Maemo device + ProjectExplorer.DefaultDeployConfiguration + + 1 + + ardrone1 + ardrone1 on Maemo device + Qt4ProjectManager.MaemoRunConfiguration + + 1 + + ardrone1.pro + + false + + 3768 + true + false + + 1 + + + + ProjectExplorer.Project.TargetCount + 2 + + + ProjectExplorer.Project.Updater.EnvironmentId + {900e65ba-cc00-43b1-ab21-347709bd318b} + + + ProjectExplorer.Project.Updater.FileVersion + 8 + + diff --git a/mardrone/ardrone1.pro.user.2.1pre1 b/mardrone/ardrone1.pro.user.2.1pre1 new file mode 100644 index 0000000..90779b4 --- /dev/null +++ b/mardrone/ardrone1.pro.user.2.1pre1 @@ -0,0 +1,316 @@ + + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + System + + + + ProjectExplorer.Project.Target.0 + + Desktop + Qt4ProjectManager.Target.DesktopTarget + 3 + 0 + + + qmake + QtProjectManager.QMakeBuildStep + + + + Make + Qt4ProjectManager.MakeStep + false + + sbox-make + + 2 + + Make + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + false + + Qt in PATH Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + /mnt/hgfs/scratchbox/harmattan/qtdemo/ardrone1-build-desktop + 11 + 0 + true + + + + qmake + QtProjectManager.QMakeBuildStep + + + + Make + Qt4ProjectManager.MakeStep + false + + + + 2 + + Make + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + false + + 4.5.0 Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + /mnt/hgfs/scratchbox/harmattan/qtdemo/ardrone1-build-desktop + 6 + 0 + true + + + + qmake + QtProjectManager.QMakeBuildStep + + + + Make + Qt4ProjectManager.MakeStep + false + + + + 2 + + Make + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + false + + 4.5.0 Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + /mnt/hgfs/scratchbox/harmattan/qtdemo/ardrone1-build-desktop + 6 + 0 + true + + + + qmake + QtProjectManager.QMakeBuildStep + + + + Make + Qt4ProjectManager.MakeStep + false + + sbox-make + + 2 + + Make + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + false + + 4.7.0 Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + /mnt/hgfs/scratchbox/harmattan/qtdemo/ardrone1-build-desktop + 11 + 0 + false + + + + qmake + QtProjectManager.QMakeBuildStep + + + + Make + Qt4ProjectManager.MakeStep + false + + sbox-make + + 2 + + Make + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + false + + 4.7.0 Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + /mnt/hgfs/scratchbox/harmattan/qtdemo/ardrone1-build-desktop + 15 + 0 + false + + 5 + + ardrone1 + Qt4ProjectManager.Qt4RunConfiguration + 2 + + ardrone1.pro + false + false + + false + false + + + 1 + + + + ProjectExplorer.Project.Target.1 + + Maemo + Qt4ProjectManager.Target.MaemoDeviceTarget + 0 + 0 + + + + -d + sb/harmattan/qtdemo/ardrone1 + qmake + + /usr/bin/scratchbox + true + $BUILDDIR + Scratchbox qmake + ProjectExplorer.ProcessStep + + + + -d + sb/harmattan/qtdemo/ardrone1 + make + + /usr/bin/scratchbox + true + $BUILDDIR + Custom Process Step + ProjectExplorer.ProcessStep + + 2 + + Make + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + false + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + /mnt/hgfs/scratchbox/harmattan/qtdemo/ardrone1-build-maemo + 5 + 9 + true + + + + qmake + QtProjectManager.QMakeBuildStep + + + + Make + Qt4ProjectManager.MakeStep + false + + + + 2 + + Make + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + false + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + /mnt/hgfs/scratchbox/harmattan/qtdemo/ardrone1-build-maemo + 5 + 9 + true + + 2 + + ardrone1.pro + ardrone1 on Maemo device + Qt4ProjectManager.MaemoRunConfiguration + + + 0 + + + + 1 + + + + ProjectExplorer.Project.TargetCount + 2 + + + ProjectExplorer.Project.Updater.FileVersion + 4 + + diff --git a/mardrone/build-stamp b/mardrone/build-stamp new file mode 100644 index 0000000..e69de29 diff --git a/mardrone/configure-stamp b/mardrone/configure-stamp new file mode 100644 index 0000000..e69de29 diff --git a/mardrone/debian/README b/mardrone/debian/README new file mode 100644 index 0000000..bc73835 --- /dev/null +++ b/mardrone/debian/README @@ -0,0 +1,6 @@ +The Debian Package ardrone1 +---------------------------- + +Comments regarding the Package + + -- Kate Alhola Wed, 03 Nov 2010 15:06:48 +0200 diff --git a/mardrone/debian/ardrone1.debhelper.log b/mardrone/debian/ardrone1.debhelper.log new file mode 100644 index 0000000..30f3c4d --- /dev/null +++ b/mardrone/debian/ardrone1.debhelper.log @@ -0,0 +1,12 @@ +dh_installdirs +dh_installchangelogs +dh_installdocs +dh_installexamples +dh_installman +dh_link +dh_compress +dh_fixperms +dh_installdeb +dh_gencontrol +dh_md5sums +dh_builddeb diff --git a/mardrone/debian/ardrone1.substvars b/mardrone/debian/ardrone1.substvars new file mode 100644 index 0000000..abd3ebe --- /dev/null +++ b/mardrone/debian/ardrone1.substvars @@ -0,0 +1 @@ +misc:Depends= diff --git a/mardrone/debian/ardrone1/DEBIAN/control b/mardrone/debian/ardrone1/DEBIAN/control new file mode 100644 index 0000000..8f52536 --- /dev/null +++ b/mardrone/debian/ardrone1/DEBIAN/control @@ -0,0 +1,10 @@ +Package: ardrone1 +Version: 0.0.1 +Architecture: armel +Maintainer: Kate Alhola +Installed-Size: 1093 +Section: user/hidden +Priority: optional +Homepage: +Description: AR-Drone flict controll app + diff --git a/mardrone/debian/ardrone1/DEBIAN/digsigsums b/mardrone/debian/ardrone1/DEBIAN/digsigsums new file mode 100644 index 0000000..adbdb57 --- /dev/null +++ b/mardrone/debian/ardrone1/DEBIAN/digsigsums @@ -0,0 +1 @@ +S 15 com.nokia.maemo H 40 26de4fef16a037dbf6d77595bdd55a06f6644083 R 22 usr/local/bin/ardrone1 diff --git a/mardrone/debian/ardrone1/DEBIAN/md5sums b/mardrone/debian/ardrone1/DEBIAN/md5sums new file mode 100644 index 0000000..ee74206 --- /dev/null +++ b/mardrone/debian/ardrone1/DEBIAN/md5sums @@ -0,0 +1,4 @@ +541c6f9bc17da48d2ad74b4aa25bd12d usr/local/bin/ardrone1 +9a5fabdfbec19c1bd2142756a4fe660a usr/share/applications/ardrone1.desktop +95488b5d54a11537a308d46dad867df8 usr/share/doc/ardrone1/changelog.gz +c008ad65eba6a7e0bc314031b96c0edb usr/share/doc/ardrone1/copyright diff --git a/mardrone/debian/ardrone1/usr/local/bin/ardrone1 b/mardrone/debian/ardrone1/usr/local/bin/ardrone1 new file mode 100755 index 0000000..9b1e370 Binary files /dev/null and b/mardrone/debian/ardrone1/usr/local/bin/ardrone1 differ diff --git a/mardrone/debian/ardrone1/usr/share/applications/ardrone1.desktop b/mardrone/debian/ardrone1/usr/share/applications/ardrone1.desktop new file mode 100644 index 0000000..087b45c --- /dev/null +++ b/mardrone/debian/ardrone1/usr/share/applications/ardrone1.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Encoding=UTF-8 +Version=1.0 +Type=Application +Terminal=false +Name=ardrone1 +Exec=/usr/local/bin/ardrone1 +Icon=ardrone1 +X-Window-Icon= +X-HildonDesk-ShowInToolbar=true +X-Osso-Type=application/x-executable diff --git a/mardrone/debian/ardrone1/usr/share/doc/ardrone1/changelog.gz b/mardrone/debian/ardrone1/usr/share/doc/ardrone1/changelog.gz new file mode 100644 index 0000000..67ebc40 Binary files /dev/null and b/mardrone/debian/ardrone1/usr/share/doc/ardrone1/changelog.gz differ diff --git a/mardrone/debian/ardrone1/usr/share/doc/ardrone1/copyright b/mardrone/debian/ardrone1/usr/share/doc/ardrone1/copyright new file mode 100644 index 0000000..b653c18 --- /dev/null +++ b/mardrone/debian/ardrone1/usr/share/doc/ardrone1/copyright @@ -0,0 +1,40 @@ +This package was debianized by Kate Alhola on +Wed, 03 Nov 2010 15:06:48 +0200. + +It was downloaded from + +Upstream Author(s): + + + + +Copyright: + + + + +License: + + This package 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 2 of the License, or + (at your option) any later version. + + This package 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 this package; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +On Debian systems, the complete text of the GNU General +Public License can be found in `/usr/share/common-licenses/GPL'. + +The Debian packaging is (C) 2010, Kate Alhola and +is licensed under the GPL, see above. + + +# Please also look if there are files or directories which have a +# different copyright/license attached and list them here. diff --git a/mardrone/debian/changelog b/mardrone/debian/changelog new file mode 100644 index 0000000..8b3d996 --- /dev/null +++ b/mardrone/debian/changelog @@ -0,0 +1,5 @@ +ardrone1 (0.0.1) unstable; urgency=low + + * Initial Release. + + -- Kate Alhola Wed, 03 Nov 2010 15:06:48 +0200 diff --git a/mardrone/debian/compat b/mardrone/debian/compat new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/mardrone/debian/compat @@ -0,0 +1 @@ +5 diff --git a/mardrone/debian/control b/mardrone/debian/control new file mode 100644 index 0000000..d8e892c --- /dev/null +++ b/mardrone/debian/control @@ -0,0 +1,13 @@ +Source: ardrone1 +Section: user/hidden +Priority: optional +Maintainer: Kate Alhola +Build-Depends: debhelper (>= 5), libqt4-dev +Standards-Version: 3.7.3 +Homepage: + +Package: ardrone1 +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: AR-Drone flict controll app + diff --git a/mardrone/debian/copyright b/mardrone/debian/copyright new file mode 100644 index 0000000..b653c18 --- /dev/null +++ b/mardrone/debian/copyright @@ -0,0 +1,40 @@ +This package was debianized by Kate Alhola on +Wed, 03 Nov 2010 15:06:48 +0200. + +It was downloaded from + +Upstream Author(s): + + + + +Copyright: + + + + +License: + + This package 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 2 of the License, or + (at your option) any later version. + + This package 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 this package; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +On Debian systems, the complete text of the GNU General +Public License can be found in `/usr/share/common-licenses/GPL'. + +The Debian packaging is (C) 2010, Kate Alhola and +is licensed under the GPL, see above. + + +# Please also look if there are files or directories which have a +# different copyright/license attached and list them here. diff --git a/mardrone/debian/files b/mardrone/debian/files new file mode 100644 index 0000000..e1d7fc1 --- /dev/null +++ b/mardrone/debian/files @@ -0,0 +1 @@ +ardrone1_0.0.1_armel.deb user/hidden optional diff --git a/mardrone/debian/rules b/mardrone/debian/rules new file mode 100755 index 0000000..1260ad0 --- /dev/null +++ b/mardrone/debian/rules @@ -0,0 +1,91 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + + + + + +configure: configure-stamp +configure-stamp: + dh_testdir + # Add here commands to configure the package. + + touch configure-stamp + + +build: build-stamp + +build-stamp: configure-stamp + dh_testdir + + # Add here commands to compile the package. + $(MAKE) + #docbook-to-man debian/ardrone1.sgml > ardrone1.1 + + touch $@ + +clean: + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + + # Add here commands to clean up after the build process. + $(MAKE) clean + + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + # Add here commands to install the package into debian/ardrone1. + $(MAKE) INSTALL_ROOT="$(CURDIR)"/debian/ardrone1 install + + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs + dh_installexamples +# dh_install +# dh_installmenu +# dh_installdebconf +# dh_installlogrotate +# dh_installemacsen +# dh_installpam +# dh_installmime +# dh_python +# dh_installinit +# dh_installcron +# dh_installinfo + dh_installman + dh_link + # dh_strip + dh_compress + dh_fixperms +# dh_perl +# dh_makeshlibs + dh_installdeb + # dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure diff --git a/mardrone/doc/main_ui.png b/mardrone/doc/main_ui.png new file mode 100644 index 0000000..cc6af4c Binary files /dev/null and b/mardrone/doc/main_ui.png differ diff --git a/mardrone/doc/screenshot00.png b/mardrone/doc/screenshot00.png new file mode 100644 index 0000000..923169d Binary files /dev/null and b/mardrone/doc/screenshot00.png differ diff --git a/mardrone/doc/screenshot01.png b/mardrone/doc/screenshot01.png new file mode 100644 index 0000000..53f9d7f Binary files /dev/null and b/mardrone/doc/screenshot01.png differ diff --git a/mardrone/doc/screenshot02.png b/mardrone/doc/screenshot02.png new file mode 100644 index 0000000..65a003f Binary files /dev/null and b/mardrone/doc/screenshot02.png differ diff --git a/mardrone/doc/screenshot03.png b/mardrone/doc/screenshot03.png new file mode 100644 index 0000000..fecf86d Binary files /dev/null and b/mardrone/doc/screenshot03.png differ diff --git a/mardrone/doc/screenshot04.png b/mardrone/doc/screenshot04.png new file mode 100644 index 0000000..84003d4 Binary files /dev/null and b/mardrone/doc/screenshot04.png differ diff --git a/mardrone/dronecontrol.cpp b/mardrone/dronecontrol.cpp new file mode 100644 index 0000000..8266cbd --- /dev/null +++ b/mardrone/dronecontrol.cpp @@ -0,0 +1,403 @@ +#include "dronecontrol.h" +#include + +DroneControl::DroneControl():QObject() +{ + qDebug() << "DroneControl::DroneControl"; + +// ctlSock=new QTcpSocket(); +// ctlSock->bind(QHostAddress::Any,5559); +// navSock=new QUdpSocket(); +// navSock->bind(QHostAddress::Any,5554) + //connect(navSocket,SIGNAL(readyRead()),SLOT(navDataReady())); + droneHost.setAddress("192.168.1.1"); + droneThread=new DroneThread(this,droneHost); + connect(droneThread->navData(),SIGNAL(navDataUpdated()),this,SLOT(navDataUpdated())); + connect(droneThread->navData(),SIGNAL(stateUpdated()),this,SLOT(statusUpdated())); + droneSettings=new QSettings("katix.org","ardrone"); + m_pitch=0; + m_roll=0; + m_yaw=0; + m_vv=0; + +} +void DroneControl::navDataUpdated() +{ + emit navDataChanged(); + +} +void DroneControl::statusUpdated() +{ + emit statusChanged(); + +} + +void DroneControl::setPitch(float val_) +{ + m_pitch=val_; +// qDebug() << "setPitch=" << val_; + droneThread->setDroneControl(m_pitch,m_roll,m_yaw,m_vv); +}; +float DroneControl::pitch() {return m_pitch;}; + +void DroneControl::setRoll(float val_) +{ + m_roll=val_; +// qDebug() << "setRoll=" << val_; + droneThread->setDroneControl(m_pitch,m_roll,m_yaw,m_vv); +}; +float DroneControl::roll() {return m_roll;}; +void DroneControl::setYaw(float val_) { + m_yaw=val_; + // qDebug() << "setYaw=" << val_; + droneThread->setDroneControl(m_pitch,m_roll,m_yaw,m_vv); +}; +float DroneControl::yaw() {return m_yaw;}; +void DroneControl::setVVelocity(float val_) { + m_vv=val_; +// qDebug() << "setVv=" << val_; + droneThread->setDroneControl(m_pitch,m_roll,m_yaw,m_vv); +}; +float DroneControl::vVelocity() {return m_vv;}; +void DroneControl::setAltitude(float val_) { + m_altitude=val_; +}; +float DroneControl::altitude() {return m_altitude;}; +void DroneControl::setEnabled(int val_) { m_enabled=val_;}; +int DroneControl::enabled() {return m_enabled;}; +void DroneControl::setFly(bool val_) +{ + m_fly=val_; + qDebug() << "setFly=" << val_; + droneThread->setFly(m_fly); +}; +bool DroneControl::fly() {return m_fly;}; +void DroneControl::setEmergency(bool val_) +{ + m_emergency=val_; + qDebug() << "setEmergency=" << val_; + droneThread->setEmergency(m_emergency); +}; +bool DroneControl::emergency() {return m_emergency;}; + + +// Getters to drone actual valyes sent by drone +float DroneControl::droneAltitude() +{ + return droneThread->navData()->altitude; +}; +float DroneControl::dronePitch() +{ + return droneThread->navData()->pitch; +}; +float DroneControl::droneRoll() +{ + return droneThread->navData()->roll; +}; +float DroneControl::droneYaw() +{ + return droneThread->navData()->yaw; +}; +float DroneControl::droneVBat() +{ + return droneThread->navData()->vbat; +}; +QString DroneControl::decodedStatus() +{ + return droneThread->navData()->decodedState; +}; +int DroneControl::pwm_motor1() +{ + return droneThread->navData()->pwm_motor1; +}; +int DroneControl::pwm_motor2() +{ + return droneThread->navData()->pwm_motor2; +}; +int DroneControl::pwm_motor3() +{ + return droneThread->navData()->pwm_motor3; +}; +int DroneControl::pwm_motor4() +{ + return droneThread->navData()->pwm_motor4; +}; + + + + + +QString DroneControl::confDroneIp() +{ + qDebug() << "confDroneIp:" << droneSettings->value("droneIp","192.168.1.1").toString(); + return droneSettings->value("droneIp","192.168.1.1").toString(); +}; +void DroneControl::setConfDroneIp(QString ip) +{ + qDebug() << "setConfDroneIp:" << ip; + droneSettings->setValue("droneIp",ip); + emit configChanged(); +}; +bool DroneControl::confShowDebug() +{ +return droneSettings->value("showDebug",true).toBool(); +}; +void DroneControl::setConfShowDebug(bool val) +{ + droneSettings->setValue("showDebug",val); + emit configChanged(); +}; +bool DroneControl::confShowHorizon() +{ + return droneSettings->value("showHorizon",true).toBool(); +}; +void DroneControl::setConfShowHorizon(bool val) +{ + droneSettings->setValue("showHorizon",val); + emit configChanged(); +}; +bool DroneControl::confShowGauges() +{ + return droneSettings->value("showGuges",true).toBool(); +}; +void DroneControl::setConfShowGauges(bool val) +{ + droneSettings->setValue("showGauges",val); + emit configChanged(); +}; +bool DroneControl::confUseAccel() +{ + return droneSettings->value("useAccel",false).toBool(); +}; +void DroneControl::setConfUseAccel(bool val) +{ + droneSettings->setValue("useAccel",val); + emit configChanged(); +}; +bool DroneControl::confUseJoyStick() +{ + return droneSettings->value("useJouStick",false).toBool(); +}; +void DroneControl::setConfUseJoyStick(bool val) +{ + droneSettings->setValue("useJoyStick",val); + emit configChanged(); +}; + +bool DroneControl::confFullScreen() +{ + return droneSettings->value("fullScreen",true).toBool(); +}; +void DroneControl::setConfFullScreen(bool val) +{ + droneSettings->setValue("fullScreen",val); + emit configChanged(); +}; + +float DroneControl::confForwardGain() +{ + return droneSettings->value("forwardGain",1.0).toFloat(); +}; +void DroneControl::setConfForwardGain(float val) +{ + droneSettings->setValue("forwardGain",val); + emit configChanged(); +}; + + +float DroneControl::confBackwardGain() +{ + return droneSettings->value("backwardGain",1.0).toFloat(); +}; +void DroneControl::setConfBackwardGain(float val) +{ + droneSettings->setValue("backwardGain",val); + emit configChanged(); +}; + +float DroneControl::confLeftGain() +{ + return droneSettings->value("leftGain",1.0).toFloat(); +}; +void DroneControl::setConfLeftGain(float val) +{ + droneSettings->setValue("leftGain",val); + emit configChanged(); +}; +float DroneControl::confRightGain() +{ + return droneSettings->value("rightGain",1.0).toFloat(); +}; +void DroneControl::setConfRightGain(float val) +{ + droneSettings->setValue("rightGain",val); + emit configChanged(); +}; + +/*================================================= + + DroneThread class starts here + +==================================================*/ + + +void DroneThread::setFly(bool fly) +{ + if(state==ready) { + m_fly=fly; + state=flying; + stateTimer->setInterval(50); // More frequent updates + sendCmd(QString("AT*FTRIM=%1\r").arg(seq++)); + + } + if(state==flying) { + if(!fly) { + stateTimer->setInterval(200); // Less frequent updates + state=ready; + } + m_fly=fly; + } + sendCmd(QString("AT*REF=%1,%2\r").arg(seq++).arg((1<<18) + (1<<20) + (1<<22) + (1<<24) +(1<<28) +(state==flying ? 1<<9:0))); +}; + +void DroneThread::setEmergency(bool emg) +{ + m_emergency=emg; + sendCmd(QString("AT*REF=%1,%2\r").arg(seq++).arg((1<<18) + (1<<20) + (1<<22) + (1<<24) +(1<<28) + (m_emergency ? 1<<8:0))); + // if(m_emergency==1) + state=ready; +} ; +void DroneThread::setDroneControl(float pitch,float roll,float yaw,float vv) +{ + m_pitch=pitch/100.0; + m_roll=roll/100.0; + m_yaw=yaw/200.0; + m_vv=vv/200.0; + qDebug() << QString("pitch=%1 roll=%2 yaw=%3 vv=%4\r").arg(m_pitch,3,'F',2).arg(m_roll,3,'F',2).arg(m_yaw,3,'F',2).arg(m_vv,3,'F',2); +}; + +void DroneThread::setDroneGain(float fgain,float bgain,float lgain,float rgain) +{ + m_fgain=fgain; + m_bgain=bgain; + m_rgain=rgain; + m_lgain=lgain; +}; + +void DroneThread::sendCmd(QString cmd) +{ + QByteArray dgram; + QString seqCmd=cmd; + if(cmd.contains("%")) seqCmd=cmd.arg(seq++); + dgram=seqCmd.toLatin1(); + cmdSock->writeDatagram(dgram.data(),dgram.size(),droneHost,5556); + seqCmd.chop(1); // Remove training cr + qDebug() << "DroneThread::sendCmd= " << seqCmd << "to " << droneHost ; +} + +void DroneThread::navDataReady() +{ + qint64 l; + char buf[2048]; + QHostAddress host; + quint16 port; + while(navSock->hasPendingDatagrams()) l=navSock->readDatagram(buf,sizeof(buf),&host,&port); +// qDebug() << "DroneThread::navDataReady state=" << state <<" l=" << l << "read=" << buf << "from" << host ; + nd.parseRawNavData((char *)&buf,l); + if(nd.state& (ARDRONE_COM_WATCHDOG_MASK )) + sendCmd(QString("AT*COMWDG=%1\r").arg(seq++)); + switch(state) { + case notInitialized: + sendCmd("AT*CONFIG=%1,\"general:navdata_demo\",\"FALSE\"\r"); + state=initialized; + break; + case initialized: + sendCmd("AT*CTRL=0\r"); + state=ready; + break; + case ready: + break; + } +} + +void DroneThread::sendNav(QString cmd) +{ + QByteArray dgram; + dgram=cmd.toLatin1(); + qDebug() << "DroneThread::sendNav= " << cmd+"\n" << "to " << droneHost ; + navSock->writeDatagram(dgram.data(),dgram.size(),droneHost,5554); +} + + +DroneThread::DroneThread(DroneControl *parentp,QHostAddress host) +{ + qDebug() << "DroneThread::DroneThread"; + stopped=false; + state=notInitialized; + parent=parentp; + navSock=new QUdpSocket(); + navSock->bind(QHostAddress::Any,5554); + cmdSock=new QUdpSocket(); + cmdSock->bind(QHostAddress::Any,5556); + droneHost=host; + seq=1; + m_pitch=0; + m_roll=0; + m_yaw=0; + m_vv=0; + m_fgain=1.0; + m_bgain=1.0; + m_rgain=1.0; + m_lgain=1.0; + start(); + + +}; + +void DroneThread::run() +{ + qDebug() << "DroneThread::DroneThread"; + stateTimer=new QTimer(this); + connect(stateTimer,SIGNAL(timeout()),this,SLOT(timer())); + connect(navSock,SIGNAL(readyRead()),this,SLOT(navDataReady())); + stateTimer->start(1000); + while(!stopped) { + exec(); + } + +} + +void DroneThread::timer() +{ + // qDebug() << "thread Timer"; + switch(state) { + case notInitialized: + sendNav("AT"); + break; + case initialized: + break; + case ready: + sendCmd(QString("AT*REF=%1,%2\r").arg(seq++).arg((1<<18) + (1<<20) + (1<<22) + (1<<24) +(1<<28))); + break; + case flying: { + float_or_int_t _pitch,_roll,_yaw,_vv; + int r=(m_pitch!=0.0 || m_roll!=0.0)?1:0; + + + _pitch.f=m_pitch; + _roll.f=m_roll; + _yaw.f=m_yaw; + _vv.f=m_vv; +// qDebug() << QString("AT*PCMD=%1,0,%2,%3,%4,%5\r").arg(seq).arg(_roll.f,3,'F',2).arg(_pitch.f,3,'F',2).arg(_vv.f,3,'F',2).arg(_yaw.f,3,'F',2); +// qDebug() << QString("AT*PCMD=%1,0,%2,%3,%4,%5\r").arg(seq).arg(_roll.i,8,16).arg(_pitch.i,8,16).arg(_vv.i,8,16).arg(_yaw.i,8,16); + sendCmd(QString("AT*COMWDG=%1\r").arg(seq++)); + sendCmd(QString("AT*PCMD=%1,%2,%3,%4,%5,%6\r").arg(seq++).arg(r).arg(_roll.i).arg(_pitch.i).arg(_vv.i).arg(_yaw.i)); + + + break; + } +} +} + + + diff --git a/mardrone/dronecontrol.h b/mardrone/dronecontrol.h new file mode 100644 index 0000000..9b6a3a2 --- /dev/null +++ b/mardrone/dronecontrol.h @@ -0,0 +1,169 @@ +#ifndef DRONECONTROL_H +#define DRONECONTROL_H + +#include +#include +#include +#include +#include +#include +#include +#include +#undef _GNU_SOURCE // just get rid of error message double definition +#include + +class DroneThread; + +class DroneControl : public QObject +{ + Q_OBJECT + Q_PROPERTY(float pitch READ pitch WRITE setPitch) + Q_PROPERTY(float roll READ roll WRITE setRoll) + Q_PROPERTY(float yaw READ yaw WRITE setYaw) + Q_PROPERTY(float altitude READ altitude WRITE setAltitude) + Q_PROPERTY(float vVelocity READ vVelocity WRITE setVVelocity) + Q_PROPERTY(int enabled READ enabled WRITE setEnabled) + Q_PROPERTY(bool fly READ fly WRITE setFly) + Q_PROPERTY(float dronePitch READ dronePitch NOTIFY navDataChanged) + Q_PROPERTY(float droneRoll READ droneRoll NOTIFY navDataChanged) + Q_PROPERTY(float droneYaw READ droneYaw NOTIFY navDataChanged) + Q_PROPERTY(float droneVBat READ droneVBat NOTIFY navDataChanged) + Q_PROPERTY(float droneAltitude READ droneAltitude NOTIFY navDataChanged) + Q_PROPERTY(bool emergency READ emergency WRITE setEmergency) + Q_PROPERTY(QString decodedStatus READ decodedStatus NOTIFY statusChanged) + Q_PROPERTY(int pwm_motor1 READ pwm_motor1 NOTIFY navDataChanged) + Q_PROPERTY(int pwm_motor2 READ pwm_motor1 NOTIFY navDataChanged) + Q_PROPERTY(int pwm_motor3 READ pwm_motor1 NOTIFY navDataChanged) + Q_PROPERTY(int pwm_motor4 READ pwm_motor1 NOTIFY navDataChanged) + + + // Config variables from QSettings + Q_PROPERTY(QString confDroneIp READ confDroneIp WRITE setConfDroneIp NOTIFY configChanged) + Q_PROPERTY(bool confShowDebug READ confShowDebug WRITE setConfShowDebug NOTIFY configChanged) + Q_PROPERTY(bool confShowHorizon READ confShowHorizon WRITE setConfShowHorizon NOTIFY configChanged) + Q_PROPERTY(bool confShowGauges READ confShowGauges WRITE setConfShowGauges NOTIFY configChanged) + Q_PROPERTY(bool confUseAccel READ confUseAccel WRITE setConfUseAccel NOTIFY configChanged) + Q_PROPERTY(bool confUseJoyStick READ confUseJoyStick WRITE setConfUseJoyStick NOTIFY configChanged) + Q_PROPERTY(bool confFullScreen READ confFullScreen WRITE setConfFullScreen NOTIFY configChanged) + Q_PROPERTY(float confForwardGain READ confForwardGain WRITE setConfForwardGain NOTIFY configChanged) + Q_PROPERTY(float confBackwardGain READ confBackwardGain WRITE setConfBackwardGain NOTIFY configChanged) + Q_PROPERTY(float confLeftGain READ confLeftGain WRITE setConfLeftGain NOTIFY configChanged) + Q_PROPERTY(float confRightGain READ confRightGain WRITE setConfRightGain NOTIFY configChanged) + +public: + explicit DroneControl(); + + + float pitch(); void setPitch(float val_); + float roll() ; void setRoll(float val_); + float yaw() ; void setYaw(float val_); + float altitude(); void setAltitude(float val_) ; + float vVelocity();void setVVelocity(float val_) ; + int enabled() ; void setEnabled(int val_) ; + bool emergency();void setEmergency(bool val_) ; + bool fly() ; void setFly(bool val_) ; + +// Read only telemetry and drone status + QString decodedStatus(); + int pwm_motor1(); + int pwm_motor2(); + int pwm_motor3(); + int pwm_motor4(); + float droneAltitude(); + float dronePitch(); + float droneRoll(); + float droneYaw(); + float droneVBat(); + +//Config variables + QString confDroneIp(); void setConfDroneIp(QString ip); + bool confShowDebug(); void setConfShowDebug(bool val); + bool confShowHorizon(); void setConfShowHorizon(bool val); + bool confShowGauges(); void setConfShowGauges(bool val); + bool confUseAccel(); void setConfUseAccel(bool val); + bool confFullScreen();void setConfFullScreen(bool val); + bool confUseJoyStick(); void setConfUseJoyStick(bool val); + float confForwardGain(); void setConfForwardGain(float val); + float confBackwardGain(); void setConfBackwardGain(float val); + float confLeftGain(); void setConfLeftGain(float val); + float confRightGain(); void setConfRightGain(float val); + +signals: + void navDataChanged(); + void statusChanged(); + void configChanged(); +public slots: + void navDataUpdated(); + void statusUpdated(); +private: + + float m_pitch; // pitch in horizon + float m_roll; // Roll in horizon + float m_yaw; // low value to display + float m_vv; // Verticl velocity + float m_altitude; // altitude + int m_enabled; // Enable flag + bool m_emergency; // Emergency flag + QString _emgReason; // Reason of emergency + bool m_fly; // Fly flag + + QTcpSocket *ctlSock; // TCP port for control/config data + QUdpSocket *navSock; // Navigation data receive socket port 5554 + QHostAddress droneHost; // Ip address of the drone + + DroneThread *droneThread; + QSettings *droneSettings; +}; + + + +class DroneThread:public QThread { + Q_OBJECT +public: + DroneThread(DroneControl *parentp,QHostAddress host); + + // ~DroneThread (); + void run(); + void sendNav(QString cmd); + void sendCmd(QString cmd); + NavData *navData() { return &nd; }; + + enum droneState { + notInitialized, + initialized, + ready, + flying + + }; +public slots: + void navDataReady(); + void timer(); + void setFly(bool fly); + void setEmergency(bool emg); + void setDroneControl(float pitch,float roll,float yaw,float vv); + void setDroneGain(float fgain,float bgain,float lgain,float rgain); + +private: + + QHostAddress droneHost; // Ip address of the drone + QTimer *stateTimer; + volatile bool stopped; + DroneControl *parent; + QUdpSocket *navSock; // Navigation data receive socket port 5554 + QUdpSocket *cmdSock; // Ay command socket port 5556 + int state; + int seq; // Drone command seq number + bool m_fly; + bool m_emergency; + float m_pitch; + float m_roll; + float m_yaw; + float m_vv; + float m_fgain; + float m_bgain; + float m_rgain; + float m_lgain; + NavData nd; +}; + +#endif // DRONECONTROL_H diff --git a/mardrone/gauge.cpp b/mardrone/gauge.cpp new file mode 100644 index 0000000..6e8a8d7 --- /dev/null +++ b/mardrone/gauge.cpp @@ -0,0 +1,33 @@ +#include "gauge.h" +#include "qgraphicswidget.h" +#include "QGraphicsItem" +#include +#include + +Gauge::Gauge(QGraphicsItem *parent) : + QGraphicsWidget(parent) +{ + qDebug() << "Gauge::Gauge()"; +} +#if 1 +void Gauge::paint(QPainter *painter, + const QStyleOptionGraphicsItem *option, + QWidget *widget) + { + + } +#endif +void Gauge::setValue(float val_) +{ + m_value=val_; + update(boundingRect()); // Value updated, schedule redtaw +}; +float Gauge::value() +{ + return m_value; +}; + +QRectF Gauge::boundingRect() const + { + return QRectF(0.0,0.0,size().width(),size().height()); + } diff --git a/mardrone/gauge.h b/mardrone/gauge.h new file mode 100644 index 0000000..c6d6f17 --- /dev/null +++ b/mardrone/gauge.h @@ -0,0 +1,82 @@ +#ifndef GAUGEBAND_H +#define GAUGEBAND_H + +#include +#include +#include + +#define UP 1 +#define RIGHT 2 +#define DOWN 3 +#define LEFT 4 + +#define SCROLL 0x10 +#define SCROLL_UP 0x11 +#define SCROLL_RIGHT 0x12 +#define SCROLL_DOWN 0x13 +#define SCROLL_LEFT 0x14 + +class Gauge : public QGraphicsWidget +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(QString format READ format WRITE setFormat) + Q_PROPERTY(int gaugeStyle READ gaugeStyle WRITE setGaugeStyle) + Q_PROPERTY(float value2 READ value2 WRITE setValue2) + Q_PROPERTY(float value READ value WRITE setValue) + Q_PROPERTY(float low READ low WRITE setLow) + Q_PROPERTY(float high READ high WRITE setHigh) + Q_PROPERTY(float lowRed READ lowRed WRITE setLowRed) + Q_PROPERTY(float highRed READ highRed WRITE setHighRed) + Q_PROPERTY(float tickIncrement READ tickIncrement WRITE setTickIncrement) + +public: + explicit Gauge(QGraphicsItem *parent = 0); + + + virtual void paint(QPainter *painter,const QStyleOptionGraphicsItem *option, + QWidget *widget); + + QRectF boundingRect() const; + + QString name() const { return m_name;}; + void setName(const QString &name_) {m_name=name_;} + QString format() const { return m_format;}; + void setFormat(const QString &name_) {m_format=name_;} + void setGaugeStyle(int val_) { m_style=val_;}; + int gaugeStyle() {return m_style;}; + void setValue(float val_); + float value(); + void setValue2(float val_) { m_value2=val_;}; + float value2() {return m_value2;}; + void setLow(float val_) { m_low=val_;}; + float low() {return m_low;}; + void setHigh(float val_) { m_high=val_;}; + float high() {return m_high;}; + void setLowRed(float val_) { m_lowred=val_;}; + float lowRed() {return m_lowred;}; + void setHighRed(float val_) { m_highred=val_;}; + float highRed() {return m_highred;}; + void setTickIncrement(float val_) { m_tickIncrement=val_;}; + float tickIncrement() {return m_tickIncrement;}; + +signals: + +public slots: +public: + QString m_name; + QString m_format; + int m_tickIncrement; // Tick increment + int m_tspc; // Tick spacing + int m_style; + float m_value; // primary value,pitch in horizon + float m_value2; // Roll in horizon + float m_low; // low value to display + float m_high; // High value to display + float m_lowred; // low red limit + float m_lowyellow; // low yellow limit + float m_highyellow; // higest yellow limit + float m_highred; +}; + +#endif // GAUGE_H diff --git a/mardrone/gaugehorizon.cpp b/mardrone/gaugehorizon.cpp new file mode 100644 index 0000000..b100d3c --- /dev/null +++ b/mardrone/gaugehorizon.cpp @@ -0,0 +1,101 @@ +#include "gaugehorizon.h" +#include +#include + +GaugeHorizon::GaugeHorizon(QGraphicsItem *parent) : + Gauge(parent) +{ +} + + + +void GaugeHorizon::paint(QPainter *painter,const QStyleOptionGraphicsItem *option, + QWidget *widget) +{ + drawHorizon(painter,-1.0*m_value,5*m_value2); +}; +////////////////////////////////////////////////////////////////////////// +void GaugeHorizon::drawHorizon(QPainter *painter, float roll, float pitch) + { + QRect update_rect; + QPoint points[10]; + //QPoint plane[10]; + QVector plane; + QVector fixo; + int tx, ctx, xd, i, j ; + int xo, yo, x1, x2, y1, y2; + + xo=size().width()/2; + yo=size().height()/2; + + plane+=QLine(xo-50,yo,xo-20,yo); + plane+=QLine(xo-20,yo,xo-10,yo+10); + plane+=QLine(xo-10,yo+10,xo,yo); + plane+=QLine(xo,yo,xo+10,yo+10); + plane+=QLine(xo+20,yo,xo+10,yo+10); + plane+=QLine(xo+50,yo,xo+20,yo); + + + static float sintable[]={sin(15*3.141592653/180.0), + sin(30*3.141592653/180.0), + sin(45*3.141592653/180.0), + sin(60*3.141592653/180.0)}; + + static float costable[]={cos(15*3.141592653/180.0), + cos(30*3.141592653/180.0), + cos(45*3.141592653/180.0), + cos(60*3.141592653/180.0)}; + + i = 0; + int arc0=130; + int arc1=150; + fixo+=QLine(xo,yo-arc0,xo,yo-arc1); + for (i = 0; i < 4; i++) { + fixo+=QLine(xo+arc0*costable[i],yo-arc0*sintable[i],xo+arc1*costable[i],yo-arc1*sintable[i]); + fixo+=QLine(xo-arc0*costable[i],yo-arc0*sintable[i],xo-arc1*costable[i],yo-arc1*sintable[i]); + }; + + + tx = (int)(xo * tan(roll * 3.141592653/180.0)); + xd = yo + pitch * 4; + + QTransform savematrix= painter->transform (); + // painter->setClipRect(QRect(0,0, size().width(),size().height()/2)); + + painter->setTransform(QTransform().translate(xo+scenePos().x(), yo+scenePos().y()+pitch).rotate(roll)); + + QBrush whitebrush(Qt::green); + painter->setBrush(whitebrush); + QPen whitepen(Qt::green); + whitepen.setWidth(2); + painter->setPen(whitepen); + xo=0;yo=0; + + painter->drawLine(50+xo, 0+yo,-50+xo, 0+yo); + painter->drawLine(40+xo, 50+yo,-40+xo, 50+yo); + painter->drawLine(40+xo, 100+yo,-40+xo, 100+yo); + painter->drawLine(40+xo, -50+yo,-40+xo, -50+yo); + painter->drawLine(40+xo, -100+yo,-40+xo,-100+yo); + + painter->drawText( 43+xo,-40+yo,"10"); + painter->drawText(-63+xo,-40+yo,"10"); + painter->drawText( 43+xo,-90+yo,"20"); + painter->drawText(-63+xo,-90+yo,"20"); + painter->drawText( 43+xo, 40+yo,"10"); + painter->drawText(-63+xo, 40+yo,"10"); + painter->drawText( 43+xo, 90+yo,"20"); + painter->drawText(-63+xo, 90+yo,"20"); + + + // painter->rotate(0); + painter->setTransform(savematrix); + QPen bluepen(Qt::blue); + bluepen.setWidth(2); + painter->setPen(bluepen); + painter->drawLines(fixo); + painter->drawLines(plane); + + + +} + diff --git a/mardrone/gaugehorizon.h b/mardrone/gaugehorizon.h new file mode 100644 index 0000000..bf46920 --- /dev/null +++ b/mardrone/gaugehorizon.h @@ -0,0 +1,16 @@ +#ifndef GAUGELABEL_H +#define GAUGELABEL_H +#include "gauge.h" + +class GaugeHorizon : public Gauge +{ + Q_OBJECT +public: + explicit GaugeHorizon(QGraphicsItem *parent = 0); + void paint(QPainter *painter,const QStyleOptionGraphicsItem *option, + QWidget *widget); + void drawHorizon(QPainter *painter,float pitch,float roll); +signals: +}; + +#endif // GAUGELABEL_H diff --git a/mardrone/gaugelabel.cpp b/mardrone/gaugelabel.cpp new file mode 100644 index 0000000..38d6046 --- /dev/null +++ b/mardrone/gaugelabel.cpp @@ -0,0 +1,154 @@ +#include "gaugelabel.h" +#include + + +GaugeLabel::GaugeLabel(QGraphicsItem *parent) : + Gauge(parent) +{ +} + +void GaugeLabel::paint(QPainter *painter,const QStyleOptionGraphicsItem *option, + QWidget *widget) +{ + drawNumLabel(painter); +}; +////////////////////////////////////////////////////////////////////////// +void GaugeLabel::drawNumLabel(QPainter *painter) +{ + int ld,ldo,ud,lo; + int split,uw,base; + char text[20] = {0}; + int h=size().height(); + int w=size().width(); + int val=m_value; + painter->save(); + qDebug() <<"drawnumlabel=" << m_name << " h=" << h << "w=" << w; + if(m_style&SCROLL) { + QFont sansFont("Helvetica [Cronyx]", 12); + QFontMetrics fm(sansFont); + painter->setFont(sansFont); + + ld=abs(val%100); + ud=val/100; + ldo=ld%10; + printf("ld=%d ldo=%d lo=%d h=%d\n",ld,ldo,lo,h); + lo=(ldo*h)/-20; + drawLabel(painter, text, m_style); + sprintf(text, "%3d", ud); + split=w/2; + base=(h+fm.ascent())/2; + uw=fm.width(text); + + painter->drawText(split-uw+6, base, text); + sprintf(text, "%02d", abs((ld-ldo-20)%100)); + painter->drawText(split+ 7, base -h +lo, text); + sprintf(text, "%02d", abs((ld-ldo-10)%100)); + painter->drawText(split+ 7, base -h/2 +lo, text); + sprintf(text, "%02d", abs((ld-ldo)%100)); + painter->drawText(split +7, base +lo, text); + sprintf(text, "%02d", abs((ld-ldo+10)%100)); + painter->drawText(split + 7,base + h/2 +lo , text); + sprintf(text, "%02d", abs((ld-ldo+20)%100)); + painter->drawText(split + 7,base + h +lo , text); + + + } else { + sprintf(text, "%3d", val); + drawLabel(painter, text,m_style); + } + painter->restore(); // Restore and remove clicping rectabgle +} + +/////////////////////////////////////////////////////////////////////////// +void GaugeLabel::drawLabel(QPainter *painter,char *text,int style) +{ + int textlen = 0, i = 0; + int xplace=0; + int yplace=0; + int height=size().height(); + int width=size().width(); + int scrbox=(height*10)/30; + + + QVector nboxv; + + QPen pen(Qt::white); + painter->setPen(pen); + + + if (style&7 == LEFT) xplace+=5; + + nboxv.push_back(QPoint(xplace,yplace)); + + + + if (style&7 == UP) { + nboxv.push_back(QPoint(xplace+(width/2)-5,yplace )); + nboxv.push_back(QPoint(xplace+(width/2) ,yplace-5)); + nboxv.push_back(QPoint(xplace+(width/2)+5,yplace )); + } + + if (style&SCROLL) { + nboxv.push_back(QPoint(xplace+width/2,yplace)); + nboxv.push_back(QPoint(xplace+width/2,yplace-scrbox)); + nboxv.push_back(QPoint(xplace+width,yplace-scrbox )); + } else + nboxv.push_back(QPoint(xplace+width,yplace )); + + + if (style&7== RIGHT) { + + nboxv.push_back(QPoint(xplace+width ,yplace+(height/2)-5)); + nboxv.push_back(QPoint(xplace+width+5,yplace+(height/2) )); + nboxv.push_back(QPoint(xplace+width ,yplace+(height/2)+5)); + } + + if (style&SCROLL) { + nboxv.push_back(QPoint(xplace+width,yplace+height+scrbox)); + nboxv.push_back(QPoint(xplace+width/2,yplace+height+scrbox)); + nboxv.push_back(QPoint(xplace+width/2,yplace+height)); + } else + nboxv.push_back(QPoint(xplace+width,yplace+height)); + + if (style&7== DOWN) { + nboxv.push_back(QPoint(xplace+(width/2)-5,yplace+height)); + nboxv.push_back(QPoint(xplace+(width/2) ,yplace+height+5)); + nboxv.push_back(QPoint(xplace+(width/2)+5,yplace+height)); + } + + nboxv.push_back(QPoint(xplace,yplace+height)); + + if (style&7 == LEFT) { + nboxv.push_back(QPoint(xplace ,yplace+(height/2)+5)); + nboxv.push_back(QPoint(xplace-5,yplace+(height/2) )); + nboxv.push_back(QPoint(xplace ,yplace+(height/2)-5)); + } + + nboxv.push_back(QPoint(xplace,yplace)); + + textlen = strlen(text) + 2; + + // pdrawable->draw_rectangle(pwidget->get_style()->get_black_gc(), + // true, xplace, yplace, width, height); + + if (style&SCROLL) + painter->setClipRect(QRect(xplace-5,yplace-scrbox, width+10, height+2*scrbox+1)); + + QBrush brush(QColor(0,0,0,255)); + // QFont tapeFont("Helvetica [Cronyx]", 18); + // painter->setFont(tapeFont); + // painter->setPen(pen); + painter->setBrush(brush); + + painter->drawPolygon(nboxv); + + painter->drawLines(nboxv); + + // painter->setBrush(brush); + QFont sansFont("Helvetica [Cronyx]", 12); + QFontMetrics fm(sansFont); + painter->setFont(sansFont); + + painter->drawText(xplace + 3, yplace + (height+fm.ascent())/2, text); +} + diff --git a/mardrone/gaugelabel.h b/mardrone/gaugelabel.h new file mode 100644 index 0000000..bd8348c --- /dev/null +++ b/mardrone/gaugelabel.h @@ -0,0 +1,17 @@ +#ifndef GAUGELABEL_H +#define GAUGELABEL_H +#include "gauge.h" + +class GaugeLabel : public Gauge +{ + Q_OBJECT +public: + explicit GaugeLabel(QGraphicsItem *parent = 0); + void paint(QPainter *painter,const QStyleOptionGraphicsItem *option, + QWidget *widget); + void drawNumLabel(QPainter *painter); + void drawLabel(QPainter *painter,char *text,int style); +signals: +}; + +#endif // GAUGELABEL_H diff --git a/mardrone/joybox.png b/mardrone/joybox.png new file mode 100644 index 0000000..e812715 Binary files /dev/null and b/mardrone/joybox.png differ diff --git a/mardrone/joyknob.png b/mardrone/joyknob.png new file mode 100644 index 0000000..8d45b97 Binary files /dev/null and b/mardrone/joyknob.png differ diff --git a/mardrone/main.cpp b/mardrone/main.cpp new file mode 100644 index 0000000..258ed86 --- /dev/null +++ b/mardrone/main.cpp @@ -0,0 +1,34 @@ +#include +#include "dronecontrol.h" +#include "video.h" +#include "gaugehorizon.h" +#include +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + qmlRegisterType("Drone", 1, 0, "DroneControl"); + qmlRegisterType("Drone", 1, 0, "DroneVideo"); + qmlRegisterType("Drone", 1, 0, "GaugeHorizon"); + QApplication app(argc, argv); + QUrl *url; + + qDebug() << "./ardrone.qml exists " << QFile("ardrone.qml").exists(); + qDebug() << ":/ardrone.qml exists " << QFile(":/ardrone.qml").exists(); + + if(QFile("ardrone.qml").exists()) { + QDir::setCurrent(app.applicationDirPath()); + url=new QUrl(QUrl::fromLocalFile("ardrone.qml")); + } + else { + QDir::setCurrent(":/"); + url=new QUrl("qrc:/ardrone.qml"); + } + QDeclarativeWindow window(*url); + window.window()->show(); + + return app.exec(); +} diff --git a/mardrone/mainwindow.cpp b/mardrone/mainwindow.cpp new file mode 100644 index 0000000..f73bd48 --- /dev/null +++ b/mardrone/mainwindow.cpp @@ -0,0 +1,26 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); +} + +MainWindow::~MainWindow() +{ + delete ui; +} + +void MainWindow::changeEvent(QEvent *e) +{ + QMainWindow::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} diff --git a/mardrone/mainwindow.h b/mardrone/mainwindow.h new file mode 100644 index 0000000..4f4c5db --- /dev/null +++ b/mardrone/mainwindow.h @@ -0,0 +1,25 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +namespace Ui { + class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = 0); + ~MainWindow(); + +protected: + void changeEvent(QEvent *e); + +private: + Ui::MainWindow *ui; +}; + +#endif // MAINWINDOW_H diff --git a/mardrone/mainwindow.ui b/mardrone/mainwindow.ui new file mode 100644 index 0000000..7ebf873 --- /dev/null +++ b/mardrone/mainwindow.ui @@ -0,0 +1,21 @@ + + MainWindow + + + + 0 + 0 + 800 + 480 + + + + MainWindow + + + + + + + + diff --git a/mardrone/mardrone b/mardrone/mardrone new file mode 100755 index 0000000..db71e7f Binary files /dev/null and b/mardrone/mardrone differ diff --git a/mardrone/mardrone.desktop.maemo5 b/mardrone/mardrone.desktop.maemo5 new file mode 100644 index 0000000..ab43682 --- /dev/null +++ b/mardrone/mardrone.desktop.maemo5 @@ -0,0 +1,11 @@ +[Desktop Entry] +Encoding=UTF-8 +Version=1.0 +Type=Application +Terminal=false +Name=ardrone1 +Exec=/opt/usr/bin/ardrone1 -graphicssystem native +Icon=ardrone1 +X-Window-Icon= +X-HildonDesk-ShowInToolbar=true +X-Osso-Type=application/x-executable diff --git a/mardrone/mardrone.desktop.meego b/mardrone/mardrone.desktop.meego new file mode 100644 index 0000000..087b45c --- /dev/null +++ b/mardrone/mardrone.desktop.meego @@ -0,0 +1,11 @@ +[Desktop Entry] +Encoding=UTF-8 +Version=1.0 +Type=Application +Terminal=false +Name=ardrone1 +Exec=/usr/local/bin/ardrone1 +Icon=ardrone1 +X-Window-Icon= +X-HildonDesk-ShowInToolbar=true +X-Osso-Type=application/x-executable diff --git a/mardrone/mardrone.pro b/mardrone/mardrone.pro new file mode 100644 index 0000000..92169f8 --- /dev/null +++ b/mardrone/mardrone.pro @@ -0,0 +1,75 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2010-10-12T20:45:34 +# +#------------------------------------------------- + +QT += core gui declarative network + + +CONFIG += mobility +TARGET = mardrone +TEMPLATE = app +AR_DRONE_SDK= $$(HOME)/ARDrone_SDK_1_5_Version_20101004 +LIBS +=-lQtComponents -L$${AR_DRONE_SDK}/lib -lvlib -lsdk + + +SOURCES += main.cpp\ + dronecontrol.cpp \ + navdata.cpp \ + video.cpp \ + gauge.cpp \ + gaugelabel.cpp \ + gaugehorizon.cpp + +INCLUDEPATH += $${AR_DRONE_SDK}/ARDroneLib/Soft/Common \ + $${AR_DRONE_SDK}/ARDroneLib/VP_SDK \ + $${AR_DRONE_SDK}/ARDroneLib/VP_SDK/VP_Os/linux \ + $${AR_DRONE_SDK}/ARDroneLib/VP_SDK/VP_Os \ + $${AR_DRONE_SDK}/ARDroneLib/Soft/Lib \ + $${AR_DRONE_SDK}/ARDroneLib/VLIB \ + $${AR_DRONE_SDK}/ARDroneLib + +HEADERS += dronecontrol.h \ + navdata.h \ + video.h \ + gauge.h \ + gaugelabel.h \ + gaugehorizon.h + + +OTHER_FILES += \ + ardrone.qml \ + JoyStick.qml \ + JoyStick2.qml \ + debian/changelog \ + debian/compat \ + debian/control \ + debian/copyright \ + debian/README \ + debian/rules \ + ardrone1.desktop \ + BarGauge.qml \ + ConfigDialog.qml + +unix:!symbian { + maemo5 { + target.path = /opt/usr/bin + } else { + target.path = /usr/local/bin + } + INSTALLS += target +} + +unix:!symbian { + desktopfile.files = $${TARGET}.desktop + maemo5 { + desktopfile.path = /usr/share/applications/hildon + } else { + desktopfile.path = /usr/share/applications + } + INSTALLS += desktopfile +} + +RESOURCES += \ + ardrone.qrc diff --git a/mardrone/navdata.cpp b/mardrone/navdata.cpp new file mode 100644 index 0000000..ff1c3c8 --- /dev/null +++ b/mardrone/navdata.cpp @@ -0,0 +1,156 @@ +#include +#include "navdata.h" + + +NavData::NavData(QObject *parent) : + QObject(parent) +{ + vx=0;vy=0;vz=0;pwm_motor1=0;pwm_motor2=0;pwm_motor3=0;pwm_motor4=0; + vbat=0.0;pitch=0.0;roll=0.0;yaw=0.0;altitude=0.0; +} + +void NavData::parseRawNavData(char *buf,unsigned int len) +{ + int opt=0; + navdata_option_t *op; + _navdata_t *nd=(_navdata_t *)buf; + state=nd->ardrone_state; + if(state!=oldState) { + oldState=state; + decodedState=decodeState(state,0); + emit stateUpdated(); + }; +#if 0 + qDebug("parseRawNavData hdr=%8x state=%08x seq=%06d opt[0].tag=%d size=%d", + nd->header,nd->ardrone_state,nd->sequence,nd->options[0].tag,nd->options[0].size); +#endif + qDebug() << decodedState; + op=&(nd->options[0]); + while((((unsigned int)op-(unsigned int)buf)size>0)) + { + parseOption(op); + op=(navdata_option_t *)((unsigned int)op+op->size); + } +}; + +void NavData::parseOption(navdata_option_t *op) +{ + // qDebug("parseOption tag=%d size=%d",op->tag,op->size); + switch(op->tag) { + case NAVDATA_DEMO_TAG: + { + _navdata_demo_t *ndemo=(_navdata_demo_t*)op; + vbat=ndemo->vbat_flying_percentage; + pitch=ndemo->theta/1000.0; + roll=ndemo->phi/1000.0; + yaw=ndemo->psi/1000.0; + altitude=ndemo->altitude; + vx=ndemo->vx; + vy=ndemo->vy; + vz=ndemo->vz; + emit navDataUpdated(); + qDebug("pitch=%2.1f roll=%2.1f yaw=%2.1f alt=%2.1f v(%2.1f,%2.1f,%2.1f bat=%2.1f",pitch,roll,yaw,altitude,vx,vy,vz,vbat); + } + break; + case NAVDATA_TIME_TAG: + { + _navdata_time_t *ntdime=(_navdata_time_t*)op; + } + break; + case NAVDATA_RAW_MEASURES_TAG: + { + _navdata_raw_measures_t *nraw=(_navdata_raw_measures_t*)op; + } + break; + case NAVDATA_PHYS_MEASURES_TAG: + { + _navdata_phys_measures_t *nphys=(_navdata_phys_measures_t*)op; + } + break; + case NAVDATA_GYROS_OFFSETS_TAG: + break; + case NAVDATA_EULER_ANGLES_TAG: + break; + case NAVDATA_REFERENCES_TAG: + break; + case NAVDATA_TRIMS_TAG: // 7 + { + _navdata_trims_t *ntrim=( _navdata_trims_t*)op; + } + break; + case NAVDATA_RC_REFERENCES_TAG: //8 + break; + case NAVDATA_PWM_TAG: + { + _navdata_pwm_t *npwm=( _navdata_pwm_t*)op; + current_motor1=npwm->current_motor1; + pwm_motor1=npwm->motor1; + current_motor2=npwm->current_motor2; + pwm_motor2=npwm->motor2; + current_motor3=npwm->current_motor3; + pwm_motor3=npwm->motor3; + current_motor4=npwm->current_motor4; + pwm_motor4=npwm->motor4; + emit navDataUpdated(); + qDebug("pwm1=%3d I1=%4f pwm2=%3d I2=%4f pwm3=%3d I3=%4f pwm4=%3d I4=%4f", + pwm_motor1,current_motor1,pwm_motor2,current_motor2,pwm_motor3,current_motor3,pwm_motor4,current_motor4); + } + break; + case NAVDATA_ALTITUDE_TAG: //10 + break; + case NAVDATA_VISION_RAW_TAG: + break; + case NAVDATA_VISION_OF_TAG: //12 + break; + case NAVDATA_VISION_TAG: + break; + case NAVDATA_VISION_PERF_TAG: + break; + case NAVDATA_TRACKERS_SEND_TAG: + break; + case NAVDATA_VISION_DETECT_TAG: //16 + break; + case NAVDATA_WATCHDOG_TAG: + break; + case NAVDATA_ADC_DATA_FRAME_TAG: + break; + case NAVDATA_CKS_TAG: //65535 + break; + } +}; + +QString NavData::decodeState(unsigned int state,int level) +{ + QString s="%1 "; + s=s.arg(state,8,16); + s+=(state & ARDRONE_FLY_MASK)==0 ? "landed ":"flying "; + if(level>1) s+=(state & ARDRONE_VIDEO_MASK)==0 ?"video disable ":"video ena "; + if(level>1)s+=(state & ARDRONE_VISION_MASK)==0 ? "vision disable ":"vision ena "; + if(level>1)s+=(state & ARDRONE_CONTROL_MASK)==0 ? "euler angles ":"angular speed "; + if(level>1)s+=(state & ARDRONE_ALTITUDE_MASK)==0 ? "alt ctrl inact ":"alt ctrl act "; + //s+=(state & ARDRONE_USER_FEEDBACK_START)==0 ? /*!< USER feedback : Start button state */ + s+=(state & ARDRONE_COMMAND_MASK)==0 ? "CMD NAK ":"CMD ACK "; + // s+=(state & ARDRONE_FW_FILE_MASK)==0 ? /* Firmware file is good; + // s+=(state & ARDRONE_FW_VER_MASK )==0 ? /* Firmware update is newer; + // ARDRONE_FW_UPD_MASK = 1 << 9, /* Firmware update is ongoing (1; + s+=(state & ARDRONE_NAVDATA_DEMO_MASK )==0 ? "All navdata ":"navdata demo "; + s+=(state & ARDRONE_NAVDATA_BOOTSTRAP)==0 ? "":"Navdata bootstrap "; + // s+=(state & ARDRONE_MOTORS_MASK)==0 ? /*!< Motors status : (0) Ok, (1) Motors problem */ + s+=(state & ARDRONE_COM_LOST_MASK)? "Com Lost ":"Com ok "; + if(level>1)s+=(state & ARDRONE_VBAT_LOW) ? "VBat low ":"Vbat Ok "; + if(level>1)s+=(state & ARDRONE_USER_EL) ? "User EL ":""; + s+=(state & ARDRONE_TIMER_ELAPSED) ? "Timer elapsed ":""; + s+=(state & ARDRONE_ANGLES_OUT_OF_RANGE) ? "Angles out of range ":""; + s+=(state & ARDRONE_ULTRASOUND_MASK) ? "Ultrasonic sensor deaf ":""; + s+=(state & ARDRONE_CUTOUT_MASK) ? "Cutout system detection detected":""; +// s+=(state & ARDRONE_PIC_VERSION_MASK)==0 ? /*!< PIC Version number OK : (0) a bad version number, (1) version number is OK */ +// s+=(state & ARDRONE_ATCODEC_THREAD_ON)==0 ? /*!< ATCodec thread ON : (0) thread OFF (1) thread ON */ + if(level>2)s+=(state & ARDRONE_NAVDATA_THREAD_ON)==0 ? "Navdata thread OFF ":"Navdata thread ON "; + if(level>2)s+=(state & ARDRONE_VIDEO_THREAD_ON )==0 ? "Video thread OFF ":"Video thread ON "; +// s+=+(state & ARDRONE_ACQ_THREAD_ON)==0 ? "Acquisition thread OFF ":"Acquisition thread ON "; + s+=(state & ARDRONE_CTRL_WATCHDOG_MASK) ? "CTRL watchdog ":""; + s+=(state & ARDRONE_ADC_WATCHDOG_MASK) ? "ADC Watchdog ":""; + s+=(state & ARDRONE_COM_WATCHDOG_MASK) ? "Comm Watchdog ":""; + s+=(state & ARDRONE_EMERGENCY_MASK)? "Emg landing":""; + return s; +} diff --git a/mardrone/navdata.h b/mardrone/navdata.h new file mode 100644 index 0000000..8707766 --- /dev/null +++ b/mardrone/navdata.h @@ -0,0 +1,44 @@ +#ifndef NAVDATA_H +#define NAVDATA_H + +#include +#undef _GNU_SOURCE // just get rid of error message double definition +#include +#include "config.h" + +class NavData : public QObject +{ + Q_OBJECT +public: + explicit NavData(QObject *parent = 0); + void parseRawNavData(char *buf,unsigned int len); + void parseOption(navdata_option_t *op); + QString decodeState(unsigned int state,int level); + + unsigned int state,oldState; + QString decodedState; + float vbat; + float pitch; + float roll; + float yaw; + float altitude; + float vx; + float vy; + float vf; + float vz; + float current_motor1; + float current_motor2; + float current_motor3; + float current_motor4; + int pwm_motor1; + int pwm_motor2; + int pwm_motor3; + int pwm_motor4; +signals: + void navDataUpdated(); + void stateUpdated(); +public slots: + +}; + +#endif // NAVDATA_H diff --git a/mardrone/test.qml b/mardrone/test.qml new file mode 100644 index 0000000..16af9d7 --- /dev/null +++ b/mardrone/test.qml @@ -0,0 +1,6 @@ +import Qt 4.6 + +Rectangle { + width: 640 + height: 480 +} diff --git a/mardrone/video.cpp b/mardrone/video.cpp new file mode 100644 index 0000000..43a12ac --- /dev/null +++ b/mardrone/video.cpp @@ -0,0 +1,154 @@ +#include "video.h" +#include + +DroneVideo::DroneVideo() +{ + droneHost.setAddress("192.168.1.1"); + initialized=false; +} + +VideoThread::VideoThread(DroneVideo *parentp,QHostAddress host,QImage *_image) +{ + image=_image; + qDebug() << "videoThread::videoThread"; + stopped=false; + parent=parentp; + videoSock=new QUdpSocket(); + videoSock->bind(QHostAddress::Any,5555); + droneHost=host; + start(); + +}; + +void DroneVideo::paint(QPainter *painter,const QStyleOptionGraphicsItem *option, + QWidget *widget) + { + if(!initialized) { // We need initialize QImage here because we don't know display depth before + int depth=0; + + depth=painter->device()->depth(); + qDebug() << "depth=" << depth; + + if(depth==24) { + image=new QImage(320,240, QImage::Format_RGB32); + image->fill(0x555555); + } + else { + image=new QImage(320,240, QImage::Format_RGB16); + image->fill(0x5555); + } + QPainter p(image); + p.drawLine(0,0,image->width(),image->height()); + p.drawLine(image->width(),0,0,image->height()); + update(boundingRect()); + videoThread=new VideoThread(this,droneHost,image); + initialized=true; + } else + painter->drawImage(boundingRect(),*image,image->rect()); + }; + +QRectF DroneVideo::boundingRect() const +{ + return QRectF(0.0,0.0,size().width(),size().height()); +} + + +void VideoThread::run() +{ +#define ACQ_WIDTH 320 +#define ACQ_HEIGHT 240 +#undef memset + memset(&controller,0,sizeof(controller)); + memset(&picture,0,sizeof(picture)); + pictureWidth= image->width(); + pictureHeight=image->height(); + int codec_type=UVLC_CODEC; + qDebug() << "videoThread::run()"; + stateTimer=new QTimer(); + connect(stateTimer,SIGNAL(timeout()),this,SLOT(timer())); + connect(videoSock,SIGNAL(readyRead()),this,SLOT(videoDataReady())); + qDebug() << "videoThread::run() 2"; + luma_only=FALSE; + num_picture_decoded=0; + /// Picture configuration + picture.format = PIX_FMT_YUV420P; + picture.width = pictureWidth; + picture.height = pictureHeight; + picture.framerate = 30; + picture.y_buf = (uint8_t*)(void*)vp_os_malloc((size_t) pictureWidth*pictureHeight ); + picture.cr_buf = (uint8_t*)vp_os_malloc( pictureWidth*pictureHeight/4 ); + picture.cb_buf = (uint8_t*)vp_os_malloc( pictureWidth*pictureHeight/4 ); + picture.y_line_size = pictureWidth; + picture.cb_line_size = pictureWidth / 2; + picture.cr_line_size = pictureWidth / 2; + picture.y_pad = 0; + picture.c_pad = 0; + qDebug() << "videoThread::run() 3"; + video_codec_open(&controller, (codec_type_t)UVLC_CODEC); + //stateTimer->start(1000); + qDebug() << "videoThread::run() initialized"; + sendVideoPort("AT"); + while(!stopped) { + exec(); + } + +} + +void VideoThread::timer() +{ + // qDebug() << "thread Timer"; + +} + +void VideoThread::sendVideoPort(QString cmd) +{ + QByteArray dgram; + dgram=cmd.toLatin1(); + qDebug() << "videoThread::sendCmd= " << cmd+"\n" << "to " << droneHost ; + videoSock->writeDatagram(dgram.data(),dgram.size(),droneHost,5555); +} + +void VideoThread::videoDataReady() +{ + qint64 l; + QByteArray videoData; + + QHostAddress host; + quint16 port; + videoData.resize(videoSock->pendingDatagramSize ()); + l=videoSock->readDatagram(videoData.data(),videoData.size(),&host,&port); + qDebug() << "videoThread::videoDataReady" <<" l=" << l << "from" << host ; + decodeTransform(videoData); +} + +void VideoThread::decodeTransform(QByteArray &videoData) +{ + controller.in_stream.bytes = (uint32_t*)videoData.data(); + controller.in_stream.used = videoData.size(); + controller.in_stream.size = videoData.size(); + controller.in_stream.index = 0; + controller.in_stream.length = 32; + controller.in_stream.code = 0; + + bool_t got_image = FALSE; + //qDebug() <<"VideoThread::decodeTransform"; + video_decode_blockline( &controller, &picture, &got_image ); + //qDebug() <<"VideoThread::decodeTransform 2"; + //video_decode_picture( &controller, &picture, &stream, &got_image ); + if( got_image ) + { + qDebug() <<"VideoThread::decodeTransform got image" << picture.width << picture.height << image->byteCount() << image->bytesPerLine(); + // we got one picture + // out->size = 1; + picture.complete = 1; + num_picture_decoded++; + vp_stages_YUV420P_to_RGB565(NULL,&picture,image->bits(),image->bytesPerLine()); + + + qDebug() << "pic " << num_picture_decoded; + } + + +}; + + diff --git a/mardrone/video.h b/mardrone/video.h new file mode 100644 index 0000000..2dce006 --- /dev/null +++ b/mardrone/video.h @@ -0,0 +1,75 @@ +#ifndef VIDEO_H +#define VIDEO_H + +#include +#include +#include +#include +#include +#include +#include +#include "dronecontrol.h" +#undef _GNU_SOURCE // just get rid of error message double definition +#define TARGET_CPU_ARM 1 +#include +#include +#include +extern "C" +{ +#include +void vp_stages_YUV420P_to_RGB565(void *cfg, vp_api_picture_t *picture, uint8_t *dst, uint32_t dst_rbytes); + +} + + +class VideoThread; + +class DroneVideo:public QGraphicsWidget +{ + Q_OBJECT +public: + DroneVideo(); + void paint(QPainter *painter,const QStyleOptionGraphicsItem *option, + QWidget *widget); + QRectF boundingRect() const; + +private: + QHostAddress droneHost; // Ip address of the drone + VideoThread *videoThread; + QImage *image; + bool initialized; +}; + +class VideoThread:public QThread { + Q_OBJECT +public: + VideoThread(DroneVideo *parentp,QHostAddress host,QImage *_image); + + // ~DroneThread (); + void run(); + void sendVideoPort(QString cmd); + void decodeTransform(QByteArray &videoData); + +public slots: + void videoDataReady(); + void timer(); + + + +private: + QImage *image; + video_controller_t controller; + vp_api_picture_t picture; + int pictureWidth; + int pictureHeight; + bool luma_only; + unsigned int num_picture_decoded; + QHostAddress droneHost; // Ip address of the drone + QTimer *stateTimer; + volatile bool stopped; + DroneVideo *parent; + QUdpSocket *videoSock; // Navigation data receive socket port 5554 + +}; + +#endif // VIDEO_H diff --git a/mardrone/zz b/mardrone/zz new file mode 100644 index 0000000..a199d34 --- /dev/null +++ b/mardrone/zz @@ -0,0 +1,5 @@ +" T*PCMD=317,0,0.28,0.04,0.00,0.00 +" T*PCMD=317,0,3e91eb85,3d0f5c29, 0, 0 +DroneThread::sendCmd= "AT*PCMD=317,0,1049750405,1024416809,0,0" to QHostAddress( "192.168.1.1" ) +" f802475 flying CMD ACK navdata demo Com Lost " +pitch=-1.3 roll=0.7 yaw=115.5 alt=43.0 v(-48.9,-15.9,0.0 bat=54.0