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
1bb5779d
Commit
1bb5779d
authored
Jul 17, 2014
by
Thomas Gubler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
i joystick: mavlink message depending on mode
parent
fccdc662
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
53 deletions
+59
-53
JoystickInput.cc
src/input/JoystickInput.cc
+3
-3
JoystickInput.h
src/input/JoystickInput.h
+2
-1
UAS.cc
src/uas/UAS.cc
+52
-48
UAS.h
src/uas/UAS.h
+2
-1
No files found.
src/input/JoystickInput.cc
View file @
1bb5779d
...
...
@@ -323,7 +323,7 @@ void JoystickInput::setActiveUAS(UASInterface* uas)
tmp
=
dynamic_cast
<
UAS
*>
(
this
->
uas
);
if
(
tmp
)
{
disconnect
(
this
,
SIGNAL
(
joystickChanged
(
float
,
float
,
float
,
float
,
qint8
,
qint8
,
quint16
)),
tmp
,
SLOT
(
setManualControlCommands
(
float
,
float
,
float
,
float
,
qint8
,
qint8
,
quint16
)));
disconnect
(
this
,
SIGNAL
(
joystickChanged
(
float
,
float
,
float
,
float
,
qint8
,
qint8
,
quint16
,
JOYSTICK_MODE
)),
tmp
,
SLOT
(
setExternalControlSetpoint
(
float
,
float
,
float
,
float
,
qint8
,
qint8
,
quint16
,
JOYSTICK_MODE
)));
disconnect
(
this
,
SIGNAL
(
actionTriggered
(
int
)),
tmp
,
SLOT
(
triggerAction
(
int
)));
}
uasCanReverse
=
false
;
...
...
@@ -339,7 +339,7 @@ void JoystickInput::setActiveUAS(UASInterface* uas)
if
(
this
->
uas
&&
(
tmp
=
dynamic_cast
<
UAS
*>
(
this
->
uas
)))
{
connect
(
this
,
SIGNAL
(
joystickChanged
(
float
,
float
,
float
,
float
,
qint8
,
qint8
,
quint16
)),
tmp
,
SLOT
(
setManualControlCommands
(
float
,
float
,
float
,
float
,
qint8
,
qint8
,
quint16
)));
connect
(
this
,
SIGNAL
(
joystickChanged
(
float
,
float
,
float
,
float
,
qint8
,
qint8
,
quint16
,
JOYSTICK_MODE
)),
tmp
,
SLOT
(
setExternalControlSetpoint
(
float
,
float
,
float
,
float
,
qint8
,
qint8
,
quint16
,
JOYSTICK_MODE
)));
connect
(
this
,
SIGNAL
(
actionTriggered
(
int
)),
tmp
,
SLOT
(
triggerAction
(
int
)));
uasCanReverse
=
tmp
->
systemCanReverse
();
...
...
@@ -553,7 +553,7 @@ void JoystickInput::run()
float
pitch
=
pitchAxis
>
-
1
?
joystickAxes
[
pitchAxis
]
:
numeric_limits
<
float
>::
quiet_NaN
();
float
yaw
=
yawAxis
>
-
1
?
joystickAxes
[
yawAxis
]
:
numeric_limits
<
float
>::
quiet_NaN
();
float
throttle
=
throttleAxis
>
-
1
?
joystickAxes
[
throttleAxis
]
:
numeric_limits
<
float
>::
quiet_NaN
();
emit
joystickChanged
(
roll
,
pitch
,
yaw
,
throttle
,
xHat
,
yHat
,
joystickButtons
);
emit
joystickChanged
(
roll
,
pitch
,
yaw
,
throttle
,
xHat
,
yHat
,
joystickButtons
,
mode
);
}
// Sleep, update rate of joystick is approx. 25 Hz (1000 ms / 25 = 40 ms)
...
...
src/input/JoystickInput.h
View file @
1bb5779d
...
...
@@ -251,8 +251,9 @@ signals:
* @param throttle Throttle, -100%:-1.0, 0%: 0.0, 100%: 1.0. If the roll axis isn't defined, NaN is transmit instead.
* @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
* @param mode (setpoint type) see JOYSTICK_MODE enum
*/
void
joystickChanged
(
float
roll
,
float
pitch
,
float
yaw
,
float
throttle
,
qint8
xHat
,
qint8
yHat
,
quint16
buttons
);
void
joystickChanged
(
float
roll
,
float
pitch
,
float
yaw
,
float
throttle
,
qint8
xHat
,
qint8
yHat
,
quint16
buttons
,
JOYSTICK_MODE
mode
);
/**
* @brief Emit a new value for an axis
...
...
src/uas/UAS.cc
View file @
1bb5779d
...
...
@@ -2933,7 +2933,7 @@ void UAS::toggleAutonomy()
* Set the manual control commands.
* This can only be done if the system has manual inputs enabled and is armed.
*/
void
UAS
::
set
ManualControlCommands
(
float
roll
,
float
pitch
,
float
yaw
,
float
thrust
,
qint8
xHat
,
qint8
yHat
,
quint16
buttons
)
void
UAS
::
set
ExternalControlSetpoint
(
float
roll
,
float
pitch
,
float
yaw
,
float
thrust
,
qint8
xHat
,
qint8
yHat
,
quint16
buttons
,
JoystickInput
::
JOYSTICK_MODE
joystickMode
)
{
Q_UNUSED
(
xHat
);
Q_UNUSED
(
yHat
);
...
...
@@ -2979,53 +2979,57 @@ void UAS::setManualControlCommands(float roll, float pitch, float yaw, float thr
mavlink_message_t
message
;
// send an external attitude setpoint command (rate control disabled)
float
attitudeQuaternion
[
4
];
mavlink_euler_to_quaternion
(
roll
,
pitch
,
yaw
,
attitudeQuaternion
);
uint8_t
typeMask
=
0
b111
;
// disable rate control
mavlink_msg_attitude_setpoint_external_pack
(
mavlink
->
getSystemId
(),
mavlink
->
getComponentId
(),
&
message
,
QGC
::
groundTimeUsecs
(),
this
->
uasId
,
0
,
typeMask
,
attitudeQuaternion
,
0
,
0
,
0
,
thrust
);
// TODO: This is a prototype to be used depending on the joystick mode
// // Send the the force setpoint (local pos sp external message)
// //mavlink_msg_manual_control_pack(mavlink->getSystemId(), mavlink->getComponentId(), &message, this->uasId, newPitchCommand, newRollCommand, newThrustCommand, newYawCommand, buttons);
// // send an external attitude setpoint command (rate control disabled)
// float dcm[3][3];
// mavlink_euler_to_dcm(roll, pitch, yaw, dcm);
// const float fx = -dcm[0][2];
// const float fy = -dcm[1][2];
// const float fz = -dcm[2][2];
// uint16_t typeMask = 0b0000001000111111; // disable rate control
// mavlink_msg_local_ned_position_setpoint_external_pack(mavlink->getSystemId(),
// mavlink->getComponentId(),
// &message,
// QGC::groundTimeUsecs(),
// this->uasId,
// 0,
// MAV_FRAME_LOCAL_NED,
// typeMask,
// 0,
// 0,
// 0,
// 0,
// 0,
// 0,
// fx,
// fy,
// fz
// );
if
(
joystickMode
==
JoystickInput
::
JOYSTICK_MODE_ATTITUDE
)
{
// send an external attitude setpoint command (rate control disabled)
float
attitudeQuaternion
[
4
];
mavlink_euler_to_quaternion
(
roll
,
pitch
,
yaw
,
attitudeQuaternion
);
uint8_t
typeMask
=
0
b111
;
// disable rate control
mavlink_msg_attitude_setpoint_external_pack
(
mavlink
->
getSystemId
(),
mavlink
->
getComponentId
(),
&
message
,
QGC
::
groundTimeUsecs
(),
this
->
uasId
,
0
,
typeMask
,
attitudeQuaternion
,
0
,
0
,
0
,
thrust
);
}
else
if
(
joystickMode
==
JoystickInput
::
JOYSTICK_MODE_FORCE
)
{
// Send the the force setpoint (local pos sp external message)
float
dcm
[
3
][
3
];
mavlink_euler_to_dcm
(
roll
,
pitch
,
yaw
,
dcm
);
const
float
fx
=
-
dcm
[
0
][
2
];
const
float
fy
=
-
dcm
[
1
][
2
];
const
float
fz
=
-
dcm
[
2
][
2
];
uint16_t
typeMask
=
0
b0000001000111111
;
// select only force control (disable everything else)
mavlink_msg_local_ned_position_setpoint_external_pack
(
mavlink
->
getSystemId
(),
mavlink
->
getComponentId
(),
&
message
,
QGC
::
groundTimeUsecs
(),
this
->
uasId
,
0
,
MAV_FRAME_LOCAL_NED
,
typeMask
,
0
,
0
,
0
,
0
,
0
,
0
,
fx
,
fy
,
fz
);
}
else
{
return
;
}
sendMessage
(
message
);
...
...
src/uas/UAS.h
View file @
1bb5779d
...
...
@@ -42,6 +42,7 @@ This file is part of the QGROUNDCONTROL project
#include "QGCJSBSimLink.h"
#include "QGCXPlaneLink.h"
#include "QGCUASParamManager.h"
#include "JoystickInput.h"
/**
...
...
@@ -838,7 +839,7 @@ public slots:
void
toggleAutonomy
();
/** @brief Set the values for the manual control of the vehicle */
void
set
ManualControlCommands
(
float
roll
,
float
pitch
,
float
yaw
,
float
thrust
,
qint8
xHat
,
qint8
yHat
,
quint16
buttons
);
void
set
ExternalControlSetpoint
(
float
roll
,
float
pitch
,
float
yaw
,
float
thrust
,
qint8
xHat
,
qint8
yHat
,
quint16
buttons
,
JoystickInput
::
JOYSTICK_MODE
joystickMode
);
/** @brief Set the values for the 6dof manual control of the vehicle */
void
setManual6DOFControlCommands
(
double
x
,
double
y
,
double
z
,
double
roll
,
double
pitch
,
double
yaw
);
...
...
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