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
561f5e95
Commit
561f5e95
authored
Oct 17, 2012
by
Lorenz Meier
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #175 from jonathanFR/master
Add of joystick buttons values for manual control
parents
61264568
9923c3e6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
8 deletions
+8
-8
JoystickInput.cc
src/input/JoystickInput.cc
+5
-5
JoystickInput.h
src/input/JoystickInput.h
+1
-1
UAS.cc
src/uas/UAS.cc
+1
-1
UAS.h
src/uas/UAS.h
+1
-1
No files found.
src/input/JoystickInput.cc
View file @
561f5e95
...
...
@@ -101,7 +101,7 @@ void JoystickInput::setActiveUAS(UASInterface* uas)
tmp
=
dynamic_cast
<
UAS
*>
(
this
->
uas
);
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
,
int
)),
tmp
,
SLOT
(
setManualControlCommands
(
double
,
double
,
double
,
double
,
int
,
int
,
int
)));
disconnect
(
this
,
SIGNAL
(
buttonPressed
(
int
)),
tmp
,
SLOT
(
receiveButton
(
int
)));
}
}
...
...
@@ -110,7 +110,7 @@ void JoystickInput::setActiveUAS(UASInterface* uas)
tmp
=
dynamic_cast
<
UAS
*>
(
this
->
uas
);
if
(
tmp
)
{
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
,
int
)),
tmp
,
SLOT
(
setManualControlCommands
(
double
,
double
,
double
,
double
,
int
,
int
,
int
)));
connect
(
this
,
SIGNAL
(
buttonPressed
(
int
)),
tmp
,
SLOT
(
receiveButton
(
int
)));
}
if
(
!
isRunning
())
...
...
@@ -163,7 +163,6 @@ void JoystickInput::init()
*/
void
JoystickInput
::
run
()
{
init
();
forever
...
...
@@ -284,16 +283,16 @@ void JoystickInput::run()
// Send new values to rest of groundstation
emit
hatDirectionChanged
(
xHat
,
yHat
);
emit
joystickChanged
(
y
,
x
,
yaw
,
thrust
,
xHat
,
yHat
);
// Display all buttons
int
buttons
=
0
;
for
(
int
i
=
0
;
i
<
SDL_JoystickNumButtons
(
joystick
);
i
++
)
{
//qDebug() << "BUTTON" << i << "is: " << SDL_JoystickGetAxis(joystick, i);
if
(
SDL_JoystickGetButton
(
joystick
,
i
))
{
emit
buttonPressed
(
i
);
buttons
|=
1
<<
i
;
// Check if button is a UAS select button
if
(
uasButtonList
.
contains
(
i
))
...
...
@@ -307,6 +306,7 @@ void JoystickInput::run()
}
}
emit
joystickChanged
(
y
,
x
,
yaw
,
thrust
,
xHat
,
yHat
,
buttons
);
// Sleep, update rate of joystick is approx. 50 Hz (1000 ms / 50 = 20 ms)
QGC
::
SLEEP
::
msleep
(
20
);
...
...
src/input/JoystickInput.h
View file @
561f5e95
...
...
@@ -141,7 +141,7 @@ signals:
* @param xHat hat vector in forward-backward direction, +1 forward, 0 center, -1 backward
* @param yHat hat vector in left-right direction, -1 left, 0 center, +1 right
*/
void
joystickChanged
(
double
roll
,
double
pitch
,
double
yaw
,
double
thrust
,
int
xHat
,
int
yHat
);
void
joystickChanged
(
double
roll
,
double
pitch
,
double
yaw
,
double
thrust
,
int
xHat
,
int
yHat
,
int
buttons
);
/**
* @brief Thrust lever of the joystick has changed
...
...
src/uas/UAS.cc
View file @
561f5e95
...
...
@@ -2435,7 +2435,7 @@ void UAS::disarmSystem()
* Set the manual control commands.
* This can only be done if the system has manual inputs enabled and is armed.
*/
void
UAS
::
setManualControlCommands
(
double
roll
,
double
pitch
,
double
yaw
,
double
thrust
)
void
UAS
::
setManualControlCommands
(
double
roll
,
double
pitch
,
double
yaw
,
double
thrust
,
int
xHat
,
int
yHat
,
int
buttons
)
{
// Scale values
double
rollPitchScaling
=
1.0
f
*
1000.0
f
;
...
...
src/uas/UAS.h
View file @
561f5e95
...
...
@@ -566,7 +566,7 @@ public slots:
void
disarmSystem
();
/** @brief Set the values for the manual control of the vehicle */
void
setManualControlCommands
(
double
roll
,
double
pitch
,
double
yaw
,
double
thrust
);
void
setManualControlCommands
(
double
roll
,
double
pitch
,
double
yaw
,
double
thrust
,
int
xHat
,
int
yHat
,
int
buttons
);
/** @brief Receive a button pressed event from an input device, e.g. joystick */
void
receiveButton
(
int
buttonIndex
);
...
...
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