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
aafc4330
Commit
aafc4330
authored
Jan 13, 2012
by
LM
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor cleanups in various places
parent
4d41cb20
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
210 additions
and
80 deletions
+210
-80
qgroundcontrol.pri
qgroundcontrol.pri
+17
-5
JoystickInput.cc
src/input/JoystickInput.cc
+48
-59
UAS.cc
src/uas/UAS.cc
+38
-4
UAS.h
src/uas/UAS.h
+10
-3
UASInterface.h
src/uas/UASInterface.h
+8
-3
UASManager.cc
src/uas/UASManager.cc
+6
-3
QGCMAVLinkInspector.cc
src/ui/QGCMAVLinkInspector.cc
+60
-1
QGCMAVLinkInspector.h
src/ui/QGCMAVLinkInspector.h
+11
-0
QGCMAVLinkInspector.ui
src/ui/QGCMAVLinkInspector.ui
+12
-2
No files found.
qgroundcontrol.pri
View file @
aafc4330
...
@@ -42,8 +42,8 @@ macx|macx-g++42|macx-g++: {
...
@@ -42,8 +42,8 @@ macx|macx-g++42|macx-g++: {
# COMPILER_VERSION = $$system(gcc -v)
# COMPILER_VERSION = $$system(gcc -v)
#message(Using compiler $$COMPILER_VERSION)
#message(Using compiler $$COMPILER_VERSION)
CONFIG += x86 cocoa phonon
CONFIG += x86
_64
cocoa phonon
CONFIG -= x86
_64
CONFIG -= x86
#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" ) {
...
@@ -94,7 +94,7 @@ macx|macx-g++42|macx-g++: {
...
@@ -94,7 +94,7 @@ macx|macx-g++42|macx-g++: {
QMAKE_POST_LINK += && cp -rf $$BASEDIR/files $$TARGETDIR/qgroundcontrol.app/Contents/MacOS
QMAKE_POST_LINK += && cp -rf $$BASEDIR/files $$TARGETDIR/qgroundcontrol.app/Contents/MacOS
# Copy libraries
# Copy libraries
QMAKE_POST_LINK += && mkdir -p $$TARGETDIR/qgroundcontrol.app/Contents/libs
QMAKE_POST_LINK += && mkdir -p $$TARGETDIR/qgroundcontrol.app/Contents/libs
QMAKE_POST_LINK += && cp -rf $$BASEDIR/lib/mac
32
/lib/* $$TARGETDIR/qgroundcontrol.app/Contents/libs
QMAKE_POST_LINK += && cp -rf $$BASEDIR/lib/mac
64
/lib/* $$TARGETDIR/qgroundcontrol.app/Contents/libs
# Fix library paths inside executable
# Fix library paths inside executable
QMAKE_POST_LINK += && install_name_tool -change libOpenThreads.dylib "@executable_path/../libs/libOpenThreads.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/MacOS/qgroundcontrol
QMAKE_POST_LINK += && install_name_tool -change libOpenThreads.dylib "@executable_path/../libs/libOpenThreads.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/MacOS/qgroundcontrol
...
@@ -164,11 +164,11 @@ macx|macx-g++42|macx-g++: {
...
@@ -164,11 +164,11 @@ macx|macx-g++42|macx-g++: {
# Include OpenSceneGraph libraries
# Include OpenSceneGraph libraries
INCLUDEPATH += -framework GLUT \
INCLUDEPATH += -framework GLUT \
-framework Cocoa \
-framework Cocoa \
$$BASEDIR/lib/mac
32
/include
$$BASEDIR/lib/mac
64
/include
LIBS += -framework GLUT \
LIBS += -framework GLUT \
-framework Cocoa \
-framework Cocoa \
-L$$BASEDIR/lib/mac
32
/lib \
-L$$BASEDIR/lib/mac
64
/lib \
-lOpenThreads \
-lOpenThreads \
-losg \
-losg \
-losgViewer \
-losgViewer \
...
@@ -178,6 +178,18 @@ macx|macx-g++42|macx-g++: {
...
@@ -178,6 +178,18 @@ macx|macx-g++42|macx-g++: {
-losgWidget
-losgWidget
#}
#}
exists(/usr/local/include/google/protobuf) {
message("Building support for Protocol Buffers")
DEPENDENCIES_PRESENT += protobuf
# Include Protocol Buffers libraries
LIBS += -L/usr/local/lib \
-lprotobuf \
-lprotobuf-lite \
-lprotoc
DEFINES += QGC_PROTOBUF_ENABLED
}
exists(/opt/local/include/libfreenect)|exists(/usr/local/include/libfreenect) {
exists(/opt/local/include/libfreenect)|exists(/usr/local/include/libfreenect) {
message("Building support for libfreenect")
message("Building support for libfreenect")
DEPENDENCIES_PRESENT += libfreenect
DEPENDENCIES_PRESENT += libfreenect
...
...
src/input/JoystickInput.cc
View file @
aafc4330
/*=====================================================================
/*=====================================================================
PIXHAWK Micro Air Vehicle Flying Robotics Toolkit
(c) 2009, 2010 PIXHAWK PROJECT <http://pixhawk.ethz.ch>
This file is part of the PIXHAWK project
PIXHAWK 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 3 of the License, or
(at your option) any later version.
PIXHAWK 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 PIXHAWK. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
======================================================================*/
/**
/**
...
@@ -44,17 +24,17 @@ This file is part of the PIXHAWK project
...
@@ -44,17 +24,17 @@ This file is part of the PIXHAWK project
* @image html http://pixhawk.ethz.ch/wiki/_media/standards/body-frame.png Aeronautical frame
* @image html http://pixhawk.ethz.ch/wiki/_media/standards/body-frame.png Aeronautical frame
*/
*/
JoystickInput
::
JoystickInput
()
:
JoystickInput
::
JoystickInput
()
:
sdlJoystickMin
(
-
32768.0
f
),
sdlJoystickMin
(
-
32768.0
f
),
sdlJoystickMax
(
32767.0
f
),
sdlJoystickMax
(
32767.0
f
),
defaultIndex
(
0
),
defaultIndex
(
0
),
uas
(
NULL
),
uas
(
NULL
),
uasButtonList
(
QList
<
int
>
()),
uasButtonList
(
QList
<
int
>
()),
done
(
false
),
done
(
false
),
thrustAxis
(
2
),
thrustAxis
(
2
),
xAxis
(
0
),
xAxis
(
0
),
yAxis
(
1
),
yAxis
(
1
),
yawAxis
(
3
),
yawAxis
(
3
),
joystickName
(
tr
(
"Unitinialized"
))
joystickName
(
tr
(
"Unitinialized"
))
{
{
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
calibrationPositive
[
i
]
=
sdlJoystickMax
;
calibrationPositive
[
i
]
=
sdlJoystickMax
;
...
@@ -69,12 +49,12 @@ JoystickInput::JoystickInput() :
...
@@ -69,12 +49,12 @@ JoystickInput::JoystickInput() :
JoystickInput
::~
JoystickInput
()
JoystickInput
::~
JoystickInput
()
{
{
{
done
=
true
;
QMutexLocker
locker
(
&
this
->
m_doneMutex
);
while
(
done
)
done
=
true
;
{
}
QGC
::
SLEEP
::
usleep
(
5000
);
this
->
wait
();
}
this
->
deleteLater
();
this
->
deleteLater
();
}
}
...
@@ -82,9 +62,11 @@ void JoystickInput::setActiveUAS(UASInterface* uas)
...
@@ -82,9 +62,11 @@ void JoystickInput::setActiveUAS(UASInterface* uas)
{
{
// Only connect / disconnect is the UAS is of a controllable UAS class
// Only connect / disconnect is the UAS is of a controllable UAS class
UAS
*
tmp
=
0
;
UAS
*
tmp
=
0
;
if
(
this
->
uas
)
{
if
(
this
->
uas
)
{
tmp
=
dynamic_cast
<
UAS
*>
(
this
->
uas
);
tmp
=
dynamic_cast
<
UAS
*>
(
this
->
uas
);
if
(
tmp
)
{
if
(
tmp
)
{
disconnect
(
this
,
SIGNAL
(
joystickChanged
(
double
,
double
,
double
,
double
,
int
,
int
)),
tmp
,
SLOT
(
setManualControlCommands
(
double
,
double
,
double
,
double
)));
disconnect
(
this
,
SIGNAL
(
joystickChanged
(
double
,
double
,
double
,
double
,
int
,
int
)),
tmp
,
SLOT
(
setManualControlCommands
(
double
,
double
,
double
,
double
)));
disconnect
(
this
,
SIGNAL
(
buttonPressed
(
int
)),
tmp
,
SLOT
(
receiveButton
(
int
)));
disconnect
(
this
,
SIGNAL
(
buttonPressed
(
int
)),
tmp
,
SLOT
(
receiveButton
(
int
)));
}
}
...
@@ -97,7 +79,8 @@ void JoystickInput::setActiveUAS(UASInterface* uas)
...
@@ -97,7 +79,8 @@ void JoystickInput::setActiveUAS(UASInterface* uas)
connect
(
this
,
SIGNAL
(
joystickChanged
(
double
,
double
,
double
,
double
,
int
,
int
)),
tmp
,
SLOT
(
setManualControlCommands
(
double
,
double
,
double
,
double
)));
connect
(
this
,
SIGNAL
(
joystickChanged
(
double
,
double
,
double
,
double
,
int
,
int
)),
tmp
,
SLOT
(
setManualControlCommands
(
double
,
double
,
double
,
double
)));
connect
(
this
,
SIGNAL
(
buttonPressed
(
int
)),
tmp
,
SLOT
(
receiveButton
(
int
)));
connect
(
this
,
SIGNAL
(
buttonPressed
(
int
)),
tmp
,
SLOT
(
receiveButton
(
int
)));
}
}
if
(
!
isRunning
())
{
if
(
!
isRunning
())
{
start
();
start
();
}
}
}
}
...
@@ -113,17 +96,20 @@ void JoystickInput::init()
...
@@ -113,17 +96,20 @@ void JoystickInput::init()
int
numJoysticks
=
SDL_NumJoysticks
();
int
numJoysticks
=
SDL_NumJoysticks
();
// Wait for joysticks if none is connected
// Wait for joysticks if none is connected
while
(
numJoysticks
==
0
)
{
while
(
numJoysticks
==
0
)
MG
::
SLEEP
::
msleep
(
200
);
{
MG
::
SLEEP
::
msleep
(
800
);
// INITIALIZE SDL Joystick support
// INITIALIZE SDL Joystick support
if
(
SDL_InitSubSystem
(
SDL_INIT_JOYSTICK
|
SDL_INIT_NOPARACHUTE
)
<
0
)
{
if
(
SDL_InitSubSystem
(
SDL_INIT_JOYSTICK
|
SDL_INIT_NOPARACHUTE
)
<
0
)
{
printf
(
"Couldn't initialize SimpleDirectMediaLayer: %s
\n
"
,
SDL_GetError
());
printf
(
"Couldn't initialize SimpleDirectMediaLayer: %s
\n
"
,
SDL_GetError
());
}
}
numJoysticks
=
SDL_NumJoysticks
();
numJoysticks
=
SDL_NumJoysticks
();
}
}
printf
(
"%d Input devices found:
\n
"
,
numJoysticks
);
printf
(
"%d Input devices found:
\n
"
,
numJoysticks
);
for
(
int
i
=
0
;
i
<
SDL_NumJoysticks
();
i
++
)
{
for
(
int
i
=
0
;
i
<
SDL_NumJoysticks
();
i
++
)
{
printf
(
"
\t
- %s
\n
"
,
SDL_JoystickName
(
i
));
printf
(
"
\t
- %s
\n
"
,
SDL_JoystickName
(
i
));
joystickName
=
QString
(
SDL_JoystickName
(
i
));
joystickName
=
QString
(
SDL_JoystickName
(
i
));
}
}
...
@@ -147,16 +133,14 @@ void JoystickInput::run()
...
@@ -147,16 +133,14 @@ void JoystickInput::run()
init
();
init
();
forever
forever
{
{
{
if
(
done
)
QMutexLocker
locker
(
&
this
->
m_doneMutex
);
{
if
(
done
)
done
=
false
;
{
exit
();
done
=
false
;
}
break
;
while
(
SDL_PollEvent
(
&
event
))
}
{
}
while
(
SDL_PollEvent
(
&
event
))
{
SDL_JoystickUpdate
();
SDL_JoystickUpdate
();
...
@@ -197,7 +181,8 @@ void JoystickInput::run()
...
@@ -197,7 +181,8 @@ void JoystickInput::run()
}
}
// Display all axes
// Display all axes
for
(
int
i
=
0
;
i
<
SDL_JoystickNumAxes
(
joystick
);
i
++
)
{
for
(
int
i
=
0
;
i
<
SDL_JoystickNumAxes
(
joystick
);
i
++
)
{
//qDebug() << "\rAXIS" << i << "is: " << SDL_JoystickGetAxis(joystick, i);
//qDebug() << "\rAXIS" << i << "is: " << SDL_JoystickGetAxis(joystick, i);
}
}
...
@@ -268,15 +253,19 @@ void JoystickInput::run()
...
@@ -268,15 +253,19 @@ void JoystickInput::run()
// Display all buttons
// Display all buttons
for
(
int
i
=
0
;
i
<
SDL_JoystickNumButtons
(
joystick
);
i
++
)
{
for
(
int
i
=
0
;
i
<
SDL_JoystickNumButtons
(
joystick
);
i
++
)
{
//qDebug() << "BUTTON" << i << "is: " << SDL_JoystickGetAxis(joystick, i);
//qDebug() << "BUTTON" << i << "is: " << SDL_JoystickGetAxis(joystick, i);
if
(
SDL_JoystickGetButton
(
joystick
,
i
))
{
if
(
SDL_JoystickGetButton
(
joystick
,
i
))
{
emit
buttonPressed
(
i
);
emit
buttonPressed
(
i
);
// Check if button is a UAS select button
// Check if button is a UAS select button
if
(
uasButtonList
.
contains
(
i
))
{
if
(
uasButtonList
.
contains
(
i
))
{
UASInterface
*
uas
=
UASManager
::
instance
()
->
getUASForId
(
i
);
UASInterface
*
uas
=
UASManager
::
instance
()
->
getUASForId
(
i
);
if
(
uas
)
{
if
(
uas
)
{
UASManager
::
instance
()
->
setActiveUAS
(
uas
);
UASManager
::
instance
()
->
setActiveUAS
(
uas
);
}
}
}
}
...
...
src/uas/UAS.cc
View file @
aafc4330
...
@@ -185,6 +185,38 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message)
...
@@ -185,6 +185,38 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message)
// qDebug() << __FILE__ << __LINE__ << "ADDED LINK!" << link->getName();
// qDebug() << __FILE__ << __LINE__ << "ADDED LINK!" << link->getName();
}
}
if
(
!
components
.
contains
(
message
.
compid
))
{
QString
componentName
;
switch
(
message
.
compid
)
{
case
MAV_COMP_ID_ALL
:
{
componentName
=
"ANONYMOUS"
;
break
;
}
case
MAV_COMP_ID_IMU
:
{
componentName
=
"IMU #1"
;
break
;
}
case
MAV_COMP_ID_CAMERA
:
{
componentName
=
"CAMERA"
;
break
;
}
case
MAV_COMP_ID_MISSIONPLANNER
:
{
componentName
=
"MISSIONPLANNER"
;
break
;
}
}
components
.
insert
(
message
.
compid
,
componentName
);
emit
componentCreated
(
uasId
,
message
.
compid
,
componentName
);
}
// qDebug() << "UAS RECEIVED from" << message.sysid << "component" << message.compid << "msg id" << message.msgid << "seq no" << message.seq;
// qDebug() << "UAS RECEIVED from" << message.sysid << "component" << message.compid << "msg id" << message.msgid << "seq no" << message.seq;
// Only accept messages from this system (condition 1)
// Only accept messages from this system (condition 1)
...
@@ -2261,15 +2293,17 @@ void UAS::removeLink(QObject* object)
...
@@ -2261,15 +2293,17 @@ void UAS::removeLink(QObject* object)
}
}
}
}
/**
* @brief Get the links associated with this robot
*
**/
QList
<
LinkInterface
*>*
UAS
::
getLinks
()
QList
<
LinkInterface
*>*
UAS
::
getLinks
()
{
{
return
links
;
return
links
;
}
}
QMap
<
int
,
QString
>
UAS
::
getComponents
()
{
return
components
;
}
void
UAS
::
setBattery
(
BatteryType
type
,
int
cells
)
void
UAS
::
setBattery
(
BatteryType
type
,
int
cells
)
...
...
src/uas/UAS.h
View file @
aafc4330
...
@@ -81,6 +81,9 @@ public:
...
@@ -81,6 +81,9 @@ public:
int
getAirframe
()
const
{
int
getAirframe
()
const
{
return
airframe
;
return
airframe
;
}
}
/** @brief Get the components */
QMap
<
int
,
QString
>
getComponents
();
/** @brief The time interval the robot is switched on */
/** @brief The time interval the robot is switched on */
quint64
getUptime
()
const
;
quint64
getUptime
()
const
;
/** @brief Get the status flag for the communication */
/** @brief Get the status flag for the communication */
...
@@ -90,13 +93,16 @@ public:
...
@@ -90,13 +93,16 @@ public:
/** @brief Get the links associated with this robot */
/** @brief Get the links associated with this robot */
QList
<
LinkInterface
*>*
getLinks
();
QList
<
LinkInterface
*>*
getLinks
();
double
getLocalX
()
const
{
double
getLocalX
()
const
{
return
localX
;
return
localX
;
}
}
double
getLocalY
()
const
{
double
getLocalY
()
const
{
return
localY
;
return
localY
;
}
}
double
getLocalZ
()
const
{
double
getLocalZ
()
const
{
return
localZ
;
return
localZ
;
}
}
double
getLatitude
()
const
{
double
getLatitude
()
const
{
...
@@ -160,6 +166,7 @@ protected: //COMMENTS FOR TEST UNIT
...
@@ -160,6 +166,7 @@ protected: //COMMENTS FOR TEST UNIT
QList
<
double
>
motorValues
;
QList
<
double
>
motorValues
;
QList
<
QString
>
motorNames
;
QList
<
QString
>
motorNames
;
QMap
<
int
,
QString
>
components
;
///< IDs and names of all detected onboard components
double
thrustSum
;
///< Sum of forward/up thrust of all thrust actuators, in Newtons
double
thrustSum
;
///< Sum of forward/up thrust of all thrust actuators, in Newtons
double
thrustMax
;
///< Maximum forward/up thrust of this vehicle, in Newtons
double
thrustMax
;
///< Maximum forward/up thrust of this vehicle, in Newtons
...
...
src/uas/UASInterface.h
View file @
aafc4330
...
@@ -198,9 +198,12 @@ public:
...
@@ -198,9 +198,12 @@ public:
/** @brief Get the type of the autopilot (PIXHAWK, APM, UDB, PPZ,..) */
/** @brief Get the type of the autopilot (PIXHAWK, APM, UDB, PPZ,..) */
virtual
int
getAutopilotType
()
=
0
;
virtual
int
getAutopilotType
()
=
0
;
virtual
QString
getAutopilotTypeName
()
=
0
;
virtual
QString
getAutopilotTypeName
()
=
0
;
virtual
void
setAutopilotType
(
int
apType
)
=
0
;
virtual
void
setAutopilotType
(
int
apType
)
=
0
;
QColor
getColor
()
{
virtual
QMap
<
int
,
QString
>
getComponents
()
=
0
;
QColor
getColor
()
{
return
color
;
return
color
;
}
}
...
@@ -315,8 +318,10 @@ protected:
...
@@ -315,8 +318,10 @@ protected:
QColor
color
;
QColor
color
;
signals:
signals:
/** @brief The robot state has changed *
*
/
/** @brief The robot state has changed */
void
statusChanged
(
int
stateFlag
);
void
statusChanged
(
int
stateFlag
);
/** @brief A new component was detected or created */
void
componentCreated
(
int
uas
,
int
component
,
const
QString
&
name
);
/** @brief The robot state has changed
/** @brief The robot state has changed
*
*
* @param uas this robot
* @param uas this robot
...
...
src/uas/UASManager.cc
View file @
aafc4330
...
@@ -258,13 +258,15 @@ void UASManager::addUAS(UASInterface* uas)
...
@@ -258,13 +258,15 @@ void UASManager::addUAS(UASInterface* uas)
// returns the UAS once the UASCreated() signal
// returns the UAS once the UASCreated() signal
// is emitted. The code is thus NOT redundant.
// is emitted. The code is thus NOT redundant.
bool
firstUAS
=
false
;
bool
firstUAS
=
false
;
if
(
activeUAS
==
NULL
)
{
if
(
activeUAS
==
NULL
)
{
firstUAS
=
true
;
firstUAS
=
true
;
activeUAS
=
uas
;
activeUAS
=
uas
;
}
}
// Only execute if there is no UAS at this index
// Only execute if there is no UAS at this index
if
(
!
systems
.
contains
(
uas
))
{
if
(
!
systems
.
contains
(
uas
))
{
systems
.
append
(
uas
);
systems
.
append
(
uas
);
connect
(
uas
,
SIGNAL
(
destroyed
(
QObject
*
)),
this
,
SLOT
(
removeUAS
(
QObject
*
)));
connect
(
uas
,
SIGNAL
(
destroyed
(
QObject
*
)),
this
,
SLOT
(
removeUAS
(
QObject
*
)));
// Set home position on UAV if set in UI
// Set home position on UAV if set in UI
...
@@ -275,7 +277,8 @@ void UASManager::addUAS(UASInterface* uas)
...
@@ -275,7 +277,8 @@ void UASManager::addUAS(UASInterface* uas)
}
}
// If there is no active UAS yet, set the first one as the active UAS
// If there is no active UAS yet, set the first one as the active UAS
if
(
firstUAS
)
{
if
(
firstUAS
)
{
setActiveUAS
(
uas
);
setActiveUAS
(
uas
);
}
}
}
}
...
...
src/ui/QGCMAVLinkInspector.cc
View file @
aafc4330
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
#include "QGCMAVLink.h"
#include "QGCMAVLink.h"
#include "QGCMAVLinkInspector.h"
#include "QGCMAVLinkInspector.h"
#include "UASManager.h"
#include "ui_QGCMAVLinkInspector.h"
#include "ui_QGCMAVLinkInspector.h"
#include <QDebug>
#include <QDebug>
...
@@ -11,12 +12,15 @@ const unsigned int QGCMAVLinkInspector::updateInterval = 1000U;
...
@@ -11,12 +12,15 @@ const unsigned int QGCMAVLinkInspector::updateInterval = 1000U;
QGCMAVLinkInspector
::
QGCMAVLinkInspector
(
MAVLinkProtocol
*
protocol
,
QWidget
*
parent
)
:
QGCMAVLinkInspector
::
QGCMAVLinkInspector
(
MAVLinkProtocol
*
protocol
,
QWidget
*
parent
)
:
QWidget
(
parent
),
QWidget
(
parent
),
selectedSystemID
(
0
),
selectedComponentID
(
0
),
ui
(
new
Ui
::
QGCMAVLinkInspector
)
ui
(
new
Ui
::
QGCMAVLinkInspector
)
{
{
ui
->
setupUi
(
this
);
ui
->
setupUi
(
this
);
/* Insert system */
/* Insert system */
ui
->
systemComboBox
->
addItem
(
tr
(
"All Systems"
),
-
1
);
ui
->
systemComboBox
->
addItem
(
tr
(
"All Systems"
),
0
);
ui
->
componentComboBox
->
addItem
(
tr
(
"All Components"
),
0
);
mavlink_message_info_t
msg
[
256
]
=
MAVLINK_MESSAGE_INFO
;
mavlink_message_info_t
msg
[
256
]
=
MAVLINK_MESSAGE_INFO
;
memcpy
(
messageInfo
,
msg
,
sizeof
(
mavlink_message_info_t
)
*
256
);
memcpy
(
messageInfo
,
msg
,
sizeof
(
mavlink_message_info_t
)
*
256
);
...
@@ -29,9 +33,62 @@ QGCMAVLinkInspector::QGCMAVLinkInspector(MAVLinkProtocol* protocol, QWidget *par
...
@@ -29,9 +33,62 @@ QGCMAVLinkInspector::QGCMAVLinkInspector(MAVLinkProtocol* protocol, QWidget *par
header
<<
tr
(
"Type"
);
header
<<
tr
(
"Type"
);
ui
->
treeWidget
->
setHeaderLabels
(
header
);
ui
->
treeWidget
->
setHeaderLabels
(
header
);
connect
(
&
updateTimer
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
refreshView
()));
connect
(
&
updateTimer
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
refreshView
()));
// ARM UI
connect
(
ui
->
systemComboBox
,
SIGNAL
(
currentIndexChanged
(
int
)),
this
,
SLOT
(
selectDropDownMenuSystem
(
int
)));
connect
(
ui
->
componentComboBox
,
SIGNAL
(
currentIndexChanged
(
int
)),
this
,
SLOT
(
selectDropDownMenuComponent
(
int
)));
// ARM external connections
connect
(
UASManager
::
instance
(),
SIGNAL
(
UASCreated
(
UASInterface
*
)),
this
,
SLOT
(
addSystem
(
UASInterface
*
)));
// Start
updateTimer
.
start
(
updateInterval
);
updateTimer
.
start
(
updateInterval
);
}
}
void
QGCMAVLinkInspector
::
addSystem
(
UASInterface
*
uas
)
{
ui
->
systemComboBox
->
addItem
(
uas
->
getUASName
(),
uas
->
getUASID
());
}
void
QGCMAVLinkInspector
::
selectDropDownMenuSystem
(
int
dropdownid
)
{
selectedSystemID
=
ui
->
systemComboBox
->
itemData
(
dropdownid
).
toInt
();
rebuildComponentList
();
}
void
QGCMAVLinkInspector
::
selectDropDownMenuComponent
(
int
dropdownid
)
{
selectedComponentID
=
ui
->
componentComboBox
->
itemData
(
dropdownid
).
toInt
();
}
void
QGCMAVLinkInspector
::
rebuildComponentList
()
{
ui
->
componentComboBox
->
clear
();
// Fill
UASInterface
*
uas
=
UASManager
::
instance
()
->
getUASForId
(
selectedSystemID
);
if
(
uas
)
{
QMap
<
int
,
QString
>
components
=
uas
->
getComponents
();
foreach
(
int
id
,
components
.
keys
())
{
QString
name
=
components
.
value
(
id
);
ui
->
componentComboBox
->
addItem
(
name
,
id
);
}
}
}
void
QGCMAVLinkInspector
::
addComponent
(
int
uas
,
int
component
,
const
QString
&
name
)
{
Q_UNUSED
(
component
);
Q_UNUSED
(
name
);
if
(
uas
!=
selectedSystemID
)
return
;
rebuildComponentList
();
}
void
QGCMAVLinkInspector
::
refreshView
()
void
QGCMAVLinkInspector
::
refreshView
()
{
{
for
(
int
i
=
0
;
i
<
256
;
++
i
)
//mavlink_message_t msg, receivedMessages)
for
(
int
i
=
0
;
i
<
256
;
++
i
)
//mavlink_message_t msg, receivedMessages)
...
@@ -76,6 +133,8 @@ void QGCMAVLinkInspector::refreshView()
...
@@ -76,6 +133,8 @@ void QGCMAVLinkInspector::refreshView()
void
QGCMAVLinkInspector
::
receiveMessage
(
LinkInterface
*
link
,
mavlink_message_t
message
)
void
QGCMAVLinkInspector
::
receiveMessage
(
LinkInterface
*
link
,
mavlink_message_t
message
)
{
{
Q_UNUSED
(
link
);
Q_UNUSED
(
link
);
if
(
selectedSystemID
!=
0
&&
selectedSystemID
!=
message
.
sysid
)
return
;
if
(
selectedComponentID
!=
0
&&
selectedComponentID
!=
message
.
compid
)
return
;
// Only overwrite if system filter is set
// Only overwrite if system filter is set
memcpy
(
receivedMessages
+
message
.
msgid
,
&
message
,
sizeof
(
mavlink_message_t
));
memcpy
(
receivedMessages
+
message
.
msgid
,
&
message
,
sizeof
(
mavlink_message_t
));
...
...
src/ui/QGCMAVLinkInspector.h
View file @
aafc4330
...
@@ -12,6 +12,7 @@ namespace Ui {
...
@@ -12,6 +12,7 @@ namespace Ui {
}
}
class
QTreeWidgetItem
;
class
QTreeWidgetItem
;
class
UASInterface
;
class
QGCMAVLinkInspector
:
public
QWidget
class
QGCMAVLinkInspector
:
public
QWidget
{
{
...
@@ -24,8 +25,16 @@ public:
...
@@ -24,8 +25,16 @@ public:
public
slots
:
public
slots
:
void
receiveMessage
(
LinkInterface
*
link
,
mavlink_message_t
message
);
void
receiveMessage
(
LinkInterface
*
link
,
mavlink_message_t
message
);
void
refreshView
();
void
refreshView
();
void
addSystem
(
UASInterface
*
uas
);
void
addComponent
(
int
uas
,
int
component
,
const
QString
&
name
);
/** @Brief Select a system through the drop down menu */
void
selectDropDownMenuSystem
(
int
dropdownid
);
/** @Brief Select a component through the drop down menu */
void
selectDropDownMenuComponent
(
int
dropdownid
);
protected:
protected:
int
selectedSystemID
;
///< Currently selected system
int
selectedComponentID
;
///< Currently selected component
QMap
<
int
,
quint64
>
lastMessageUpdate
;
///< Used to switch between highlight and non-highlighting color
QMap
<
int
,
quint64
>
lastMessageUpdate
;
///< Used to switch between highlight and non-highlighting color
QMap
<
int
,
float
>
messagesHz
;
///< Used to store update rate in Hz
QMap
<
int
,
float
>
messagesHz
;
///< Used to store update rate in Hz
QMap
<
int
,
unsigned
int
>
messageCount
;
///< Used to store the message count
QMap
<
int
,
unsigned
int
>
messageCount
;
///< Used to store the message count
...
@@ -36,6 +45,8 @@ protected:
...
@@ -36,6 +45,8 @@ protected:
// Update one message field
// Update one message field
void
updateField
(
int
msgid
,
int
fieldid
,
QTreeWidgetItem
*
item
);
void
updateField
(
int
msgid
,
int
fieldid
,
QTreeWidgetItem
*
item
);
/** @brief Rebuild the list of components */
void
rebuildComponentList
();
static
const
unsigned
int
updateInterval
;
static
const
unsigned
int
updateInterval
;
static
const
float
updateHzLowpass
;
static
const
float
updateHzLowpass
;
...
...
src/ui/QGCMAVLinkInspector.ui
View file @
aafc4330
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
<property
name=
"margin"
>
<property
name=
"margin"
>
<number>
6
</number>
<number>
6
</number>
</property>
</property>
<item
row=
"
1
"
column=
"0"
colspan=
"2"
>
<item
row=
"
2
"
column=
"0"
colspan=
"2"
>
<widget
class=
"QTreeWidget"
name=
"treeWidget"
>
<widget
class=
"QTreeWidget"
name=
"treeWidget"
>
<column>
<column>
<property
name=
"text"
>
<property
name=
"text"
>
...
@@ -29,13 +29,23 @@
...
@@ -29,13 +29,23 @@
<item
row=
"0"
column=
"0"
>
<item
row=
"0"
column=
"0"
>
<widget
class=
"QLabel"
name=
"label"
>
<widget
class=
"QLabel"
name=
"label"
>
<property
name=
"text"
>
<property
name=
"text"
>
<string>
System
Filter
</string>
<string>
System
</string>
</property>
</property>
</widget>
</widget>
</item>
</item>
<item
row=
"0"
column=
"1"
>
<item
row=
"0"
column=
"1"
>
<widget
class=
"QComboBox"
name=
"systemComboBox"
/>
<widget
class=
"QComboBox"
name=
"systemComboBox"
/>
</item>
</item>
<item
row=
"1"
column=
"1"
>
<widget
class=
"QComboBox"
name=
"componentComboBox"
/>
</item>
<item
row=
"1"
column=
"0"
>
<widget
class=
"QLabel"
name=
"label_2"
>
<property
name=
"text"
>
<string>
Component
</string>
</property>
</widget>
</item>
</layout>
</layout>
</widget>
</widget>
<resources/>
<resources/>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment