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
9b98f66f
Unverified
Commit
9b98f66f
authored
Jun 01, 2018
by
Don Gagne
Committed by
GitHub
Jun 01, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6537 from DonLakeFlyer/MavlinkAttitude
Put back support for ATTITUDE since ArduPilot needs it
parents
9fad53c6
dbc65cc6
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
13 deletions
+41
-13
QGC.cc
src/QGC.cc
+1
-1
QGC.h
src/QGC.h
+1
-1
Vehicle.cc
src/Vehicle/Vehicle.cc
+36
-11
Vehicle.h
src/Vehicle/Vehicle.h
+3
-0
No files found.
src/QGC.cc
View file @
9b98f66f
...
...
@@ -30,7 +30,7 @@ qreal groundTimeSeconds()
return
static_cast
<
qreal
>
(
groundTimeMilliseconds
())
/
1000.0
f
;
}
float
limitAngleToPMPIf
(
float
angle
)
float
limitAngleToPMPIf
(
double
angle
)
{
if
(
angle
>
-
20
*
M_PI
&&
angle
<
20
*
M_PI
)
{
...
...
src/QGC.h
View file @
9b98f66f
...
...
@@ -33,7 +33,7 @@ quint64 groundTimeMilliseconds();
*/
qreal
groundTimeSeconds
();
/** @brief Returns the angle limited to -pi - pi */
float
limitAngleToPMPIf
(
float
angle
);
float
limitAngleToPMPIf
(
double
angle
);
/** @brief Returns the angle limited to -pi - pi */
double
limitAngleToPMPId
(
double
angle
);
...
...
src/Vehicle/Vehicle.cc
View file @
9b98f66f
...
...
@@ -134,6 +134,7 @@ Vehicle::Vehicle(LinkInterface* link,
,
_vehicleCapabilitiesKnown
(
false
)
,
_capabilityBits
(
0
)
,
_highLatencyLink
(
false
)
,
_receivingAttitudeQuaternion
(
false
)
,
_cameras
(
NULL
)
,
_connectionLost
(
false
)
,
_connectionLostEnabled
(
true
)
...
...
@@ -318,6 +319,7 @@ Vehicle::Vehicle(MAV_AUTOPILOT firmwareType,
,
_vehicleCapabilitiesKnown
(
true
)
,
_capabilityBits
(
_firmwareType
==
MAV_AUTOPILOT_ARDUPILOTMEGA
?
0
:
MAV_PROTOCOL_CAPABILITY_MISSION_FENCE
|
MAV_PROTOCOL_CAPABILITY_MISSION_RALLY
)
,
_highLatencyLink
(
false
)
,
_receivingAttitudeQuaternion
(
false
)
,
_cameras
(
NULL
)
,
_connectionLost
(
false
)
,
_connectionLostEnabled
(
true
)
...
...
@@ -706,6 +708,9 @@ void Vehicle::_mavlinkMessageReceived(LinkInterface* link, mavlink_message_t mes
case
MAVLINK_MSG_ID_HIGH_LATENCY2
:
_handleHighLatency2
(
message
);
break
;
case
MAVLINK_MSG_ID_ATTITUDE
:
_handleAttitude
(
message
);
break
;
case
MAVLINK_MSG_ID_ATTITUDE_QUATERNION
:
_handleAttitudeQuaternion
(
message
);
break
;
...
...
@@ -843,19 +848,13 @@ void Vehicle::_handleAttitudeTarget(mavlink_message_t& message)
_setpointFactGroup
.
yawRate
()
->
setRawValue
(
qRadiansToDegrees
(
attitudeTarget
.
body_yaw_rate
));
}
void
Vehicle
::
_handleAttitude
Quaternion
(
mavlink_message_t
&
message
)
void
Vehicle
::
_handleAttitude
Worker
(
double
rollRadians
,
double
pitchRadians
,
double
yawRadians
)
{
mavlink_attitude_quaternion_t
attitudeQuaternion
;
mavlink_msg_attitude_quaternion_decode
(
&
message
,
&
attitudeQuaternion
);
float
roll
,
pitch
,
yaw
;
float
q
[]
=
{
attitudeQuaternion
.
q1
,
attitudeQuaternion
.
q2
,
attitudeQuaternion
.
q3
,
attitudeQuaternion
.
q4
};
mavlink_quaternion_to_euler
(
q
,
&
roll
,
&
pitch
,
&
yaw
);
double
roll
,
pitch
,
yaw
;
roll
=
QGC
::
limitAngleToPMPIf
(
roll
);
pitch
=
QGC
::
limitAngleToPMPIf
(
pitch
);
yaw
=
QGC
::
limitAngleToPMPIf
(
yaw
);
roll
=
QGC
::
limitAngleToPMPIf
(
roll
Radians
);
pitch
=
QGC
::
limitAngleToPMPIf
(
pitch
Radians
);
yaw
=
QGC
::
limitAngleToPMPIf
(
yaw
Radians
);
roll
=
qRadiansToDegrees
(
roll
);
pitch
=
qRadiansToDegrees
(
pitch
);
...
...
@@ -870,6 +869,32 @@ void Vehicle::_handleAttitudeQuaternion(mavlink_message_t& message)
_rollFact
.
setRawValue
(
roll
);
_pitchFact
.
setRawValue
(
pitch
);
_headingFact
.
setRawValue
(
yaw
);
}
void
Vehicle
::
_handleAttitude
(
mavlink_message_t
&
message
)
{
if
(
_receivingAttitudeQuaternion
)
{
return
;
}
mavlink_attitude_t
attitude
;
mavlink_msg_attitude_decode
(
&
message
,
&
attitude
);
_handleAttitudeWorker
(
attitude
.
roll
,
attitude
.
pitch
,
attitude
.
yaw
);
}
void
Vehicle
::
_handleAttitudeQuaternion
(
mavlink_message_t
&
message
)
{
_receivingAttitudeQuaternion
=
true
;
mavlink_attitude_quaternion_t
attitudeQuaternion
;
mavlink_msg_attitude_quaternion_decode
(
&
message
,
&
attitudeQuaternion
);
float
roll
,
pitch
,
yaw
;
float
q
[]
=
{
attitudeQuaternion
.
q1
,
attitudeQuaternion
.
q2
,
attitudeQuaternion
.
q3
,
attitudeQuaternion
.
q4
};
mavlink_quaternion_to_euler
(
q
,
&
roll
,
&
pitch
,
&
yaw
);
_handleAttitudeWorker
(
roll
,
pitch
,
yaw
);
rollRate
()
->
setRawValue
(
qRadiansToDegrees
(
attitudeQuaternion
.
rollspeed
));
pitchRate
()
->
setRawValue
(
qRadiansToDegrees
(
attitudeQuaternion
.
pitchspeed
));
...
...
src/Vehicle/Vehicle.h
View file @
9b98f66f
...
...
@@ -1083,6 +1083,8 @@ private:
void
_handleScaledPressure2
(
mavlink_message_t
&
message
);
void
_handleScaledPressure3
(
mavlink_message_t
&
message
);
void
_handleHighLatency2
(
mavlink_message_t
&
message
);
void
_handleAttitudeWorker
(
double
rollRadians
,
double
pitchRadians
,
double
yawRadians
);
void
_handleAttitude
(
mavlink_message_t
&
message
);
void
_handleAttitudeQuaternion
(
mavlink_message_t
&
message
);
void
_handleAttitudeTarget
(
mavlink_message_t
&
message
);
void
_handleDistanceSensor
(
mavlink_message_t
&
message
);
...
...
@@ -1173,6 +1175,7 @@ private:
bool
_vehicleCapabilitiesKnown
;
uint64_t
_capabilityBits
;
bool
_highLatencyLink
;
bool
_receivingAttitudeQuaternion
;
QGCCameraManager
*
_cameras
;
...
...
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