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
e9035f5b
Commit
e9035f5b
authored
Feb 26, 2011
by
lm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allowed to transmit parameters with actions
parent
20723799
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
213 additions
and
30 deletions
+213
-30
UAS.cc
src/uas/UAS.cc
+25
-2
UAS.h
src/uas/UAS.h
+2
-0
UASInterface.h
src/uas/UASInterface.h
+2
-0
QGCCommandButton.cc
src/ui/designer/QGCCommandButton.cc
+50
-4
QGCCommandButton.ui
src/ui/designer/QGCCommandButton.ui
+134
-24
No files found.
src/uas/UAS.cc
View file @
e9035f5b
...
...
@@ -1770,8 +1770,31 @@ void UAS::executeCommand(MAV_CMD command)
{
mavlink_message_t
msg
;
mavlink_command_t
cmd
;
//mavlink_msg_action_pack(mavlink->getSystemId(), mavlink->getComponentId(), &msg, this->getUASID(), 0, action);
// Send message twice to increase chance that it reaches its goal
cmd
.
command
=
(
uint8_t
)
command
;
cmd
.
confirmation
=
0
;
cmd
.
param1
=
0.0
f
;
cmd
.
param2
=
0.0
f
;
cmd
.
param3
=
0.0
f
;
cmd
.
param4
=
0.0
f
;
cmd
.
target_system
=
uasId
;
cmd
.
target_component
=
0
;
mavlink_msg_command_encode
(
mavlink
->
getSystemId
(),
mavlink
->
getComponentId
(),
&
msg
,
&
cmd
);
sendMessage
(
msg
);
}
void
UAS
::
executeCommand
(
MAV_CMD
command
,
int
confirmation
,
float
param1
,
float
param2
,
float
param3
,
float
param4
,
int
component
)
{
mavlink_message_t
msg
;
mavlink_command_t
cmd
;
cmd
.
command
=
(
uint8_t
)
command
;
cmd
.
confirmation
=
confirmation
;
cmd
.
param1
=
param1
;
cmd
.
param2
=
param2
;
cmd
.
param3
=
param3
;
cmd
.
param4
=
param4
;
cmd
.
target_system
=
uasId
;
cmd
.
target_component
=
component
;
mavlink_msg_command_encode
(
mavlink
->
getSystemId
(),
mavlink
->
getComponentId
(),
&
msg
,
&
cmd
);
sendMessage
(
msg
);
}
...
...
src/uas/UAS.h
View file @
e9035f5b
...
...
@@ -216,6 +216,8 @@ public slots:
void
setAction
(
MAV_ACTION
action
);
/** @brief Executes a command **/
void
executeCommand
(
MAV_CMD
command
);
/** @brief Executes a command **/
void
executeCommand
(
MAV_CMD
command
,
int
confirmation
,
float
param1
,
float
param2
,
float
param3
,
float
param4
,
int
component
);
/** @brief Set the current battery type and voltages */
void
setBatterySpecs
(
const
QString
&
specs
);
/** @brief Get the current battery type and specs */
...
...
src/uas/UASInterface.h
View file @
e9035f5b
...
...
@@ -191,6 +191,8 @@ public slots:
virtual
void
setAction
(
MAV_ACTION
action
)
=
0
;
/** @brief Execute command immediately **/
virtual
void
executeCommand
(
MAV_CMD
command
)
=
0
;
/** @brief Executes a command **/
virtual
void
executeCommand
(
MAV_CMD
command
,
int
confirmation
,
float
param1
,
float
param2
,
float
param3
,
float
param4
,
int
component
)
=
0
;
/** @brief Selects the airframe */
virtual
void
setAirframe
(
int
airframe
)
=
0
;
...
...
src/ui/designer/QGCCommandButton.cc
View file @
e9035f5b
...
...
@@ -5,7 +5,7 @@
#include "UASManager.h"
QGCCommandButton
::
QGCCommandButton
(
QWidget
*
parent
)
:
QGCToolWidgetItem
(
"CommandButton"
,
parent
),
QGCToolWidgetItem
(
"Command
Button"
,
parent
),
ui
(
new
Ui
::
QGCCommandButton
),
uas
(
NULL
)
{
...
...
@@ -21,6 +21,13 @@ QGCCommandButton::QGCCommandButton(QWidget *parent) :
ui
->
editFinishButton
->
hide
();
ui
->
editNameLabel
->
hide
();
ui
->
editButtonName
->
hide
();
ui
->
editConfirmationCheckBox
->
hide
();
ui
->
editComponentSpinBox
->
hide
();
ui
->
editParamsVisibleCheckBox
->
hide
();
ui
->
editParam1SpinBox
->
hide
();
ui
->
editParam2SpinBox
->
hide
();
ui
->
editParam3SpinBox
->
hide
();
ui
->
editParam4SpinBox
->
hide
();
// Add commands to combo box
ui
->
editCommandComboBox
->
addItem
(
"DO: Control Video"
,
MAV_CMD_DO_CONTROL_VIDEO
);
...
...
@@ -37,10 +44,16 @@ void QGCCommandButton::sendCommand()
if
(
QGCToolWidgetItem
::
uas
)
{
// FIXME
int
index
=
0
;
//ui->editCommandComboBox->userData()
int
index
=
ui
->
editCommandComboBox
->
itemData
(
ui
->
editCommandComboBox
->
currentIndex
()).
toInt
();
MAV_CMD
command
=
static_cast
<
MAV_CMD
>
(
index
);
QGCToolWidgetItem
::
uas
->
executeCommand
(
command
);
int
confirm
=
(
ui
->
editConfirmationCheckBox
->
isChecked
())
?
1
:
0
;
float
param1
=
ui
->
editParam1SpinBox
->
value
();
float
param2
=
ui
->
editParam2SpinBox
->
value
();
float
param3
=
ui
->
editParam3SpinBox
->
value
();
float
param4
=
ui
->
editParam4SpinBox
->
value
();
int
component
=
ui
->
editComponentSpinBox
->
value
();
QGCToolWidgetItem
::
uas
->
executeCommand
(
command
,
confirm
,
param1
,
param2
,
param3
,
param4
,
component
);
}
else
{
...
...
@@ -59,6 +72,13 @@ void QGCCommandButton::startEditMode()
ui
->
editFinishButton
->
show
();
ui
->
editNameLabel
->
show
();
ui
->
editButtonName
->
show
();
ui
->
editConfirmationCheckBox
->
show
();
ui
->
editComponentSpinBox
->
show
();
ui
->
editParamsVisibleCheckBox
->
show
();
ui
->
editParam1SpinBox
->
show
();
ui
->
editParam2SpinBox
->
show
();
ui
->
editParam3SpinBox
->
show
();
ui
->
editParam4SpinBox
->
show
();
isInEditMode
=
true
;
}
...
...
@@ -68,6 +88,16 @@ void QGCCommandButton::endEditMode()
ui
->
editFinishButton
->
hide
();
ui
->
editNameLabel
->
hide
();
ui
->
editButtonName
->
hide
();
ui
->
editConfirmationCheckBox
->
hide
();
ui
->
editComponentSpinBox
->
hide
();
ui
->
editParamsVisibleCheckBox
->
hide
();
if
(
!
ui
->
editParamsVisibleCheckBox
->
isChecked
())
{
ui
->
editParam1SpinBox
->
hide
();
ui
->
editParam2SpinBox
->
hide
();
ui
->
editParam3SpinBox
->
hide
();
ui
->
editParam4SpinBox
->
hide
();
}
// Write to settings
emit
editingFinished
();
...
...
@@ -81,6 +111,7 @@ void QGCCommandButton::writeSettings(QSettings& settings)
settings
.
setValue
(
"QGC_ACTION_BUTTON_DESCRIPTION"
,
ui
->
nameLabel
->
text
());
settings
.
setValue
(
"QGC_ACTION_BUTTON_BUTTONTEXT"
,
ui
->
commandButton
->
text
());
settings
.
setValue
(
"QGC_ACTION_BUTTON_ACTIONID"
,
ui
->
editCommandComboBox
->
currentIndex
());
settings
.
setValue
(
"QGC_COMMAND_BUTTON_PARAMS_VISIBLE"
,
ui
->
editParamsVisibleCheckBox
->
isChecked
());
settings
.
sync
();
}
...
...
@@ -93,5 +124,20 @@ void QGCCommandButton::readSettings(const QSettings& settings)
ui
->
nameLabel
->
setText
(
settings
.
value
(
"QGC_ACTION_BUTTON_DESCRIPTION"
,
"ERROR LOADING BUTTON"
).
toString
());
ui
->
commandButton
->
setText
(
settings
.
value
(
"QGC_ACTION_BUTTON_BUTTONTEXT"
,
"UNKNOWN"
).
toString
());
ui
->
editCommandComboBox
->
setCurrentIndex
(
settings
.
value
(
"QGC_ACTION_BUTTON_ACTIONID"
,
0
).
toInt
());
ui
->
editParamsVisibleCheckBox
->
setChecked
(
settings
.
value
(
"QGC_COMMAND_BUTTON_PARAMS_VISIBLE"
).
toBool
());
if
(
ui
->
editParamsVisibleCheckBox
->
isChecked
())
{
ui
->
editParam1SpinBox
->
show
();
ui
->
editParam2SpinBox
->
show
();
ui
->
editParam3SpinBox
->
show
();
ui
->
editParam4SpinBox
->
show
();
}
else
{
ui
->
editParam1SpinBox
->
hide
();
ui
->
editParam2SpinBox
->
hide
();
ui
->
editParam3SpinBox
->
hide
();
ui
->
editParam4SpinBox
->
hide
();
}
qDebug
()
<<
"DONE READING SETTINGS"
;
}
src/ui/designer/QGCCommandButton.ui
View file @
e9035f5b
...
...
@@ -6,55 +6,39 @@
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
400
</width>
<height>
1
11
</height>
<width>
688
</width>
<height>
1
90
</height>
</rect>
</property>
<property
name=
"windowTitle"
>
<string>
Form
</string>
</property>
<layout
class=
"QGridLayout"
name=
"gridLayout"
columnstretch=
"100,100,50"
>
<item
row=
"1"
column=
"0"
colspan=
"2"
>
<widget
class=
"QLabel"
name=
"nameLabel"
>
<property
name=
"minimumSize"
>
<size>
<width>
50
</width>
<height>
0
</height>
</size>
</property>
<property
name=
"text"
>
<string>
Description
</string>
</property>
<property
name=
"alignment"
>
<set>
Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
</set>
</property>
</widget>
</item>
<item
row=
"2"
column=
"0"
colspan=
"2"
>
<layout
class=
"QGridLayout"
name=
"gridLayout"
columnstretch=
"100,0,0,0"
>
<item
row=
"5"
column=
"0"
colspan=
"3"
>
<widget
class=
"QComboBox"
name=
"editCommandComboBox"
/>
</item>
<item
row=
"
2"
column=
"2
"
>
<item
row=
"
5"
column=
"3
"
>
<widget
class=
"QPushButton"
name=
"editFinishButton"
>
<property
name=
"text"
>
<string>
Done
</string>
</property>
</widget>
</item>
<item
row=
"0"
column=
"
2
"
>
<item
row=
"0"
column=
"
3
"
>
<widget
class=
"QLineEdit"
name=
"editButtonName"
>
<property
name=
"text"
>
<string>
Unnamed
</string>
</property>
</widget>
</item>
<item
row=
"0"
column=
"0"
colspan=
"
2
"
>
<item
row=
"0"
column=
"0"
colspan=
"
3
"
>
<widget
class=
"QLineEdit"
name=
"editNameLabel"
>
<property
name=
"text"
>
<string>
Description
</string>
</property>
</widget>
</item>
<item
row=
"
1"
column=
"2
"
>
<item
row=
"
2"
column=
"3
"
>
<widget
class=
"QPushButton"
name=
"commandButton"
>
<property
name=
"minimumSize"
>
<size>
...
...
@@ -67,6 +51,132 @@
</property>
</widget>
</item>
<item
row=
"4"
column=
"0"
>
<widget
class=
"QSpinBox"
name=
"editComponentSpinBox"
>
<property
name=
"prefix"
>
<string>
Component ID:
</string>
</property>
<property
name=
"minimum"
>
<number>
0
</number>
</property>
<property
name=
"maximum"
>
<number>
255
</number>
</property>
</widget>
</item>
<item
row=
"4"
column=
"2"
colspan=
"2"
>
<widget
class=
"QCheckBox"
name=
"editConfirmationCheckBox"
>
<property
name=
"toolTip"
>
<string>
Set the confirm flag for this button. Some commands require that first one command is sent without confirm flag and then a second, equal command with confirm flag. This ensures safety.
</string>
</property>
<property
name=
"text"
>
<string>
Set CONFIRM flag
</string>
</property>
</widget>
</item>
<item
row=
"1"
column=
"0"
colspan=
"4"
>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout"
>
<item>
<widget
class=
"QDoubleSpinBox"
name=
"editParam1SpinBox"
>
<property
name=
"toolTip"
>
<string>
PARAM1 Value as defined in MAV_CMD list
</string>
</property>
<property
name=
"statusTip"
>
<string>
PARAM1 Value as defined in MAV_CMD list
</string>
</property>
<property
name=
"prefix"
>
<string>
P1
</string>
</property>
<property
name=
"minimum"
>
<double>
-2147483647.000000000000000
</double>
</property>
<property
name=
"maximum"
>
<double>
2147483647.000000000000000
</double>
</property>
</widget>
</item>
<item>
<widget
class=
"QDoubleSpinBox"
name=
"editParam2SpinBox"
>
<property
name=
"toolTip"
>
<string>
PARAM2 Value as defined in MAV_CMD list
</string>
</property>
<property
name=
"statusTip"
>
<string>
PARAM2 Value as defined in MAV_CMD list
</string>
</property>
<property
name=
"prefix"
>
<string>
P2:
</string>
</property>
<property
name=
"minimum"
>
<double>
-2147483647.000000000000000
</double>
</property>
<property
name=
"value"
>
<double>
0.000000000000000
</double>
</property>
</widget>
</item>
<item>
<widget
class=
"QDoubleSpinBox"
name=
"editParam3SpinBox"
>
<property
name=
"toolTip"
>
<string>
PARAM3 Value as defined in MAV_CMD list
</string>
</property>
<property
name=
"statusTip"
>
<string>
PARAM3 Value as defined in MAV_CMD list
</string>
</property>
<property
name=
"prefix"
>
<string>
P3:
</string>
</property>
<property
name=
"minimum"
>
<double>
-2147483647.000000000000000
</double>
</property>
<property
name=
"maximum"
>
<double>
2147483647.000000000000000
</double>
</property>
</widget>
</item>
<item>
<widget
class=
"QDoubleSpinBox"
name=
"editParam4SpinBox"
>
<property
name=
"toolTip"
>
<string>
PARAM4 Value as defined in MAV_CMD list
</string>
</property>
<property
name=
"statusTip"
>
<string>
PARAM4 Value as defined in MAV_CMD list
</string>
</property>
<property
name=
"prefix"
>
<string>
P4:
</string>
</property>
<property
name=
"minimum"
>
<double>
-2147483647.000000000000000
</double>
</property>
<property
name=
"maximum"
>
<double>
2147483647.000000000000000
</double>
</property>
</widget>
</item>
</layout>
</item>
<item
row=
"2"
column=
"0"
colspan=
"3"
>
<widget
class=
"QLabel"
name=
"nameLabel"
>
<property
name=
"minimumSize"
>
<size>
<width>
50
</width>
<height>
0
</height>
</size>
</property>
<property
name=
"text"
>
<string>
Description
</string>
</property>
<property
name=
"alignment"
>
<set>
Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
</set>
</property>
</widget>
</item>
<item
row=
"4"
column=
"1"
>
<widget
class=
"QCheckBox"
name=
"editParamsVisibleCheckBox"
>
<property
name=
"text"
>
<string>
Keep parameters visible
</string>
</property>
</widget>
</item>
</layout>
</widget>
<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