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
23399a22
Commit
23399a22
authored
Oct 08, 2015
by
Don Gagne
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1927 from DonLakeFlyer/APMDataStream
Apm Stack data stream request
parents
2cf5a34e
bd304b2c
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
113 additions
and
3 deletions
+113
-3
APMFirmwarePlugin.cc
src/FirmwarePlugin/APM/APMFirmwarePlugin.cc
+12
-0
APMFirmwarePlugin.h
src/FirmwarePlugin/APM/APMFirmwarePlugin.h
+2
-2
FirmwarePlugin.h
src/FirmwarePlugin/FirmwarePlugin.h
+5
-0
GenericFirmwarePlugin.cc
src/FirmwarePlugin/Generic/GenericFirmwarePlugin.cc
+7
-0
GenericFirmwarePlugin.h
src/FirmwarePlugin/Generic/GenericFirmwarePlugin.h
+1
-0
PX4FirmwarePlugin.cc
src/FirmwarePlugin/PX4/PX4FirmwarePlugin.cc
+7
-0
PX4FirmwarePlugin.h
src/FirmwarePlugin/PX4/PX4FirmwarePlugin.h
+1
-0
Vehicle.cc
src/Vehicle/Vehicle.cc
+52
-0
Vehicle.h
src/Vehicle/Vehicle.h
+26
-1
No files found.
src/FirmwarePlugin/APM/APMFirmwarePlugin.cc
View file @
23399a22
...
...
@@ -169,3 +169,15 @@ void APMFirmwarePlugin::adjustMavlinkMessage(mavlink_message_t* message)
// FIXME: Need to implement mavlink message severity adjustment
}
void
APMFirmwarePlugin
::
initializeVehicle
(
Vehicle
*
vehicle
)
{
// Streams are not started automatically on APM stack
vehicle
->
requestDataStream
(
MAV_DATA_STREAM_RAW_SENSORS
,
2
);
vehicle
->
requestDataStream
(
MAV_DATA_STREAM_EXTENDED_STATUS
,
2
);
vehicle
->
requestDataStream
(
MAV_DATA_STREAM_RC_CHANNELS
,
2
);
vehicle
->
requestDataStream
(
MAV_DATA_STREAM_POSITION
,
3
);
vehicle
->
requestDataStream
(
MAV_DATA_STREAM_EXTRA1
,
10
);
vehicle
->
requestDataStream
(
MAV_DATA_STREAM_EXTRA2
,
10
);
vehicle
->
requestDataStream
(
MAV_DATA_STREAM_EXTRA3
,
3
);
}
src/FirmwarePlugin/APM/APMFirmwarePlugin.h
View file @
23399a22
...
...
@@ -37,7 +37,6 @@ class APMFirmwarePlugin : public FirmwarePlugin
public:
// Overrides from FirmwarePlugin
virtual
bool
isCapable
(
FirmwareCapabilities
capabilities
);
virtual
QList
<
VehicleComponent
*>
componentsForVehicle
(
AutoPilotPlugin
*
vehicle
);
virtual
QStringList
flightModes
(
void
);
...
...
@@ -45,7 +44,8 @@ public:
virtual
bool
setFlightMode
(
const
QString
&
flightMode
,
uint8_t
*
base_mode
,
uint32_t
*
custom_mode
);
virtual
int
manualControlReservedButtonCount
(
void
);
virtual
void
adjustMavlinkMessage
(
mavlink_message_t
*
message
);
virtual
void
initializeVehicle
(
Vehicle
*
vehicle
);
private:
/// All access to singleton is through AutoPilotPluginManager::instance
APMFirmwarePlugin
(
QObject
*
parent
=
NULL
);
...
...
src/FirmwarePlugin/FirmwarePlugin.h
View file @
23399a22
...
...
@@ -35,6 +35,8 @@
#include <QList>
#include <QString>
class
Vehicle
;
/// This is the base class for Firmware specific plugins
///
/// The FirmwarePlugin class is the abstract base class which represents the methods and objects
...
...
@@ -92,6 +94,9 @@ public:
/// @param message[in,out] Mavlink message to adjust if needed.
virtual
void
adjustMavlinkMessage
(
mavlink_message_t
*
message
)
=
0
;
/// Called when Vehicle is first created to send any necessary mavlink messages to the firmware.
virtual
void
initializeVehicle
(
Vehicle
*
vehicle
)
=
0
;
protected:
FirmwarePlugin
(
QObject
*
parent
=
NULL
)
:
QGCSingleton
(
parent
)
{
}
};
...
...
src/FirmwarePlugin/Generic/GenericFirmwarePlugin.cc
View file @
23399a22
...
...
@@ -103,3 +103,10 @@ void GenericFirmwarePlugin::adjustMavlinkMessage(mavlink_message_t* message)
// Generic plugin does no message adjustment
}
void
GenericFirmwarePlugin
::
initializeVehicle
(
Vehicle
*
vehicle
)
{
Q_UNUSED
(
vehicle
);
// Generic Flight Stack is by definition "generic", so no extra work
}
src/FirmwarePlugin/Generic/GenericFirmwarePlugin.h
View file @
23399a22
...
...
@@ -45,6 +45,7 @@ public:
virtual
bool
setFlightMode
(
const
QString
&
flightMode
,
uint8_t
*
base_mode
,
uint32_t
*
custom_mode
);
virtual
int
manualControlReservedButtonCount
(
void
);
virtual
void
adjustMavlinkMessage
(
mavlink_message_t
*
message
);
virtual
void
initializeVehicle
(
Vehicle
*
vehicle
);
private:
/// All access to singleton is through AutoPilotPluginManager::instance
...
...
src/FirmwarePlugin/PX4/PX4FirmwarePlugin.cc
View file @
23399a22
...
...
@@ -193,3 +193,10 @@ bool PX4FirmwarePlugin::isCapable(FirmwareCapabilities capabilities)
{
return
(
capabilities
&
(
MavCmdPreflightStorageCapability
|
SetFlightModeCapability
))
==
capabilities
;
}
void
PX4FirmwarePlugin
::
initializeVehicle
(
Vehicle
*
vehicle
)
{
Q_UNUSED
(
vehicle
);
// PX4 Flight Stack doesn't need to do any extra work
}
src/FirmwarePlugin/PX4/PX4FirmwarePlugin.h
View file @
23399a22
...
...
@@ -45,6 +45,7 @@ public:
virtual
bool
setFlightMode
(
const
QString
&
flightMode
,
uint8_t
*
base_mode
,
uint32_t
*
custom_mode
);
virtual
int
manualControlReservedButtonCount
(
void
);
virtual
void
adjustMavlinkMessage
(
mavlink_message_t
*
message
);
virtual
void
initializeVehicle
(
Vehicle
*
vehicle
);
private:
/// All access to singleton is through AutoPilotPluginManager::instance
...
...
src/Vehicle/Vehicle.cc
View file @
23399a22
...
...
@@ -89,6 +89,7 @@ Vehicle::Vehicle(LinkInterface* link, int vehicleId, MAV_AUTOPILOT firmwareType)
,
_armed
(
false
)
,
_base_mode
(
0
)
,
_custom_mode
(
0
)
,
_nextSendMessageMultipleIndex
(
0
)
{
_addLink
(
link
);
...
...
@@ -161,6 +162,11 @@ Vehicle::Vehicle(LinkInterface* link, int vehicleId, MAV_AUTOPILOT firmwareType)
if
(
qgcApp
()
->
useNewMissionEditor
())
{
_missionManager
=
new
MissionManager
(
this
);
}
_firmwarePlugin
->
initializeVehicle
(
this
);
_sendMultipleTimer
.
start
(
_sendMessageMultipleIntraMessageDelay
);
connect
(
&
_sendMultipleTimer
,
&
QTimer
::
timeout
,
this
,
&
Vehicle
::
_sendMessageMultipleNext
);
}
Vehicle
::~
Vehicle
()
...
...
@@ -1069,3 +1075,49 @@ bool Vehicle::missingParameters(void)
{
return
_autopilotPlugin
->
missingParameters
();
}
void
Vehicle
::
requestDataStream
(
MAV_DATA_STREAM
stream
,
uint16_t
rate
)
{
mavlink_message_t
msg
;
mavlink_request_data_stream_t
dataStream
;
dataStream
.
req_stream_id
=
stream
;
dataStream
.
req_message_rate
=
rate
;
dataStream
.
start_stop
=
1
;
// start
dataStream
.
target_system
=
id
();
dataStream
.
target_component
=
0
;
mavlink_msg_request_data_stream_encode
(
_mavlink
->
getSystemId
(),
_mavlink
->
getComponentId
(),
&
msg
,
&
dataStream
);
// We use sendMessageMultiple since we really want these to make it to the vehicle
sendMessageMultiple
(
msg
);
}
void
Vehicle
::
_sendMessageMultipleNext
(
void
)
{
if
(
_nextSendMessageMultipleIndex
<
_sendMessageMultipleList
.
count
())
{
qCDebug
(
VehicleLog
)
<<
"_sendMessageMultipleNext:"
<<
_sendMessageMultipleList
[
_nextSendMessageMultipleIndex
].
message
.
msgid
;
sendMessage
(
_sendMessageMultipleList
[
_nextSendMessageMultipleIndex
].
message
);
if
(
--
_sendMessageMultipleList
[
_nextSendMessageMultipleIndex
].
retryCount
<=
0
)
{
_sendMessageMultipleList
.
removeAt
(
_nextSendMessageMultipleIndex
);
}
else
{
_nextSendMessageMultipleIndex
++
;
}
}
if
(
_nextSendMessageMultipleIndex
>=
_sendMessageMultipleList
.
count
())
{
_nextSendMessageMultipleIndex
=
0
;
}
}
void
Vehicle
::
sendMessageMultiple
(
mavlink_message_t
message
)
{
SendMessageMultipleInfo_t
info
;
info
.
message
=
message
;
info
.
retryCount
=
_sendMessageMultipleRetries
;
_sendMessageMultipleList
.
append
(
info
);
}
src/Vehicle/Vehicle.h
View file @
23399a22
...
...
@@ -151,6 +151,10 @@ public:
/// Sends this specified message to all links accociated with this vehicle
void
sendMessage
(
mavlink_message_t
message
);
/// Sends the specified messages multiple times to the vehicle in order to attempt to
/// guarantee that it makes it to the vehicle.
void
sendMessageMultiple
(
mavlink_message_t
message
);
/// Provides access to uas from vehicle. Temporary workaround until UAS is fully phased out.
UAS
*
uas
(
void
)
{
return
_uas
;
}
...
...
@@ -180,6 +184,11 @@ public:
bool
hilMode
(
void
);
void
setHilMode
(
bool
hilMode
);
/// Requests the specified data stream from the vehicle
/// @param stream Stream which is being requested
/// @param rate Rate at which to send stream in Hz
void
requestDataStream
(
MAV_DATA_STREAM
stream
,
uint16_t
rate
);
bool
missingParameters
(
void
);
typedef
enum
{
...
...
@@ -289,7 +298,8 @@ private slots:
void
_mavlinkMessageReceived
(
LinkInterface
*
link
,
mavlink_message_t
message
);
void
_linkDisconnected
(
LinkInterface
*
link
);
void
_sendMessage
(
mavlink_message_t
message
);
void
_sendMessageMultipleNext
(
void
);
void
_handleTextMessage
(
int
newCount
);
/** @brief Attitude from main autopilot / system state */
void
_updateAttitude
(
UASInterface
*
uas
,
double
roll
,
double
pitch
,
double
yaw
,
quint64
timestamp
);
...
...
@@ -397,7 +407,22 @@ private:
bool
_armed
;
///< true: vehicle is armed
uint8_t
_base_mode
;
///< base_mode from HEARTBEAT
uint32_t
_custom_mode
;
///< custom_mode from HEARTBEAT
/// Used to store a message being sent by sendMessageMultiple
typedef
struct
{
mavlink_message_t
message
;
///< Message to send multiple times
int
retryCount
;
///< Number of retries left
}
SendMessageMultipleInfo_t
;
QList
<
SendMessageMultipleInfo_t
>
_sendMessageMultipleList
;
///< List of messages being sent multiple times
static
const
int
_sendMessageMultipleRetries
=
5
;
static
const
int
_sendMessageMultipleIntraMessageDelay
=
500
;
QTimer
_sendMultipleTimer
;
int
_nextSendMessageMultipleIndex
;
// Settings keys
static
const
char
*
_settingsGroup
;
static
const
char
*
_joystickModeSettingsKey
;
static
const
char
*
_joystickEnabledSettingsKey
;
...
...
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