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
aa51998b
Commit
aa51998b
authored
Oct 26, 2015
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disconnect Vehicle after 30 seconds of lost communication
parent
60a46a22
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
0 deletions
+26
-0
Vehicle.cc
src/Vehicle/Vehicle.cc
+20
-0
Vehicle.h
src/Vehicle/Vehicle.h
+6
-0
No files found.
src/Vehicle/Vehicle.cc
View file @
aa51998b
...
...
@@ -42,6 +42,7 @@ QGC_LOGGING_CATEGORY(VehicleLog, "VehicleLog")
const
char
*
Vehicle
::
_settingsGroup
=
"Vehicle%1"
;
// %1 replaced with mavlink system id
const
char
*
Vehicle
::
_joystickModeSettingsKey
=
"JoystickMode"
;
const
char
*
Vehicle
::
_joystickEnabledSettingsKey
=
"JoystickEnabled"
;
const
char
*
Vehicle
::
_communicationInactivityKey
=
"CommunicationInactivity"
;
Vehicle
::
Vehicle
(
LinkInterface
*
link
,
int
vehicleId
,
MAV_AUTOPILOT
firmwareType
,
MAV_TYPE
vehicleType
)
:
_id
(
vehicleId
)
...
...
@@ -92,6 +93,7 @@ Vehicle::Vehicle(LinkInterface* link, int vehicleId, MAV_AUTOPILOT firmwareType,
,
_base_mode
(
0
)
,
_custom_mode
(
0
)
,
_nextSendMessageMultipleIndex
(
0
)
,
_communicationInactivityTimeoutMSecs
(
_communicationInactivityTimeoutMSecsDefault
)
{
_addLink
(
link
);
...
...
@@ -162,6 +164,10 @@ Vehicle::Vehicle(LinkInterface* link, int vehicleId, MAV_AUTOPILOT firmwareType,
_mapTrajectoryTimer
.
setInterval
(
_mapTrajectoryMsecsBetweenPoints
);
connect
(
&
_mapTrajectoryTimer
,
&
QTimer
::
timeout
,
this
,
&
Vehicle
::
_addNewMapTrajectoryPoint
);
_communicationInactivityTimer
.
setInterval
(
_communicationInactivityTimeoutMSecs
);
connect
(
&
_communicationInactivityTimer
,
&
QTimer
::
timeout
,
this
,
&
Vehicle
::
_communicationInactivityTimedOut
);
_communicationInactivityTimer
.
start
();
}
Vehicle
::~
Vehicle
()
...
...
@@ -178,6 +184,8 @@ void Vehicle::_mavlinkMessageReceived(LinkInterface* link, mavlink_message_t mes
if
(
message
.
sysid
!=
_id
&&
message
.
sysid
!=
0
)
{
return
;
}
_communicationInactivityTimer
.
start
();
if
(
!
_containsLink
(
link
))
{
_addLink
(
link
);
...
...
@@ -848,6 +856,7 @@ void Vehicle::_loadSettings(void)
}
_joystickEnabled
=
settings
.
value
(
_joystickEnabledSettingsKey
,
false
).
toBool
();
_communicationInactivityTimeoutMSecs
=
settings
.
value
(
_communicationInactivityKey
,
_communicationInactivityTimeoutMSecsDefault
).
toInt
();
}
void
Vehicle
::
_saveSettings
(
void
)
...
...
@@ -858,6 +867,7 @@ void Vehicle::_saveSettings(void)
settings
.
setValue
(
_joystickModeSettingsKey
,
_joystickMode
);
settings
.
setValue
(
_joystickEnabledSettingsKey
,
_joystickEnabled
);
settings
.
setValue
(
_communicationInactivityKey
,
_communicationInactivityTimeoutMSecs
);
}
int
Vehicle
::
joystickMode
(
void
)
...
...
@@ -1113,3 +1123,13 @@ void Vehicle::_parametersReady(bool parametersReady)
_missionManager
->
requestMissionItems
();
}
}
void
Vehicle
::
_communicationInactivityTimedOut
(
void
)
{
// Vechile is no longer communicating with us, disconnect all links
LinkManager
*
linkMgr
=
LinkManager
::
instance
();
for
(
int
i
=
0
;
i
<
_links
.
count
();
i
++
)
{
linkMgr
->
disconnectLink
(
_links
[
i
].
data
());
}
}
src/Vehicle/Vehicle.h
View file @
aa51998b
...
...
@@ -305,6 +305,7 @@ private slots:
void
_sendMessageMultipleNext
(
void
);
void
_addNewMapTrajectoryPoint
(
void
);
void
_parametersReady
(
bool
parametersReady
);
void
_communicationInactivityTimedOut
(
void
);
void
_handleTextMessage
(
int
newCount
);
/** @brief Attitude from main autopilot / system state */
...
...
@@ -434,10 +435,15 @@ private:
QGeoCoordinate
_mapTrajectoryLastCoordinate
;
bool
_mapTrajectoryHaveFirstCoordinate
;
static
const
int
_mapTrajectoryMsecsBetweenPoints
=
1000
;
QTimer
_communicationInactivityTimer
;
int
_communicationInactivityTimeoutMSecs
;
static
const
int
_communicationInactivityTimeoutMSecsDefault
=
30
*
1000
;
// Settings keys
static
const
char
*
_settingsGroup
;
static
const
char
*
_joystickModeSettingsKey
;
static
const
char
*
_joystickEnabledSettingsKey
;
static
const
char
*
_communicationInactivityKey
;
};
#endif
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