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
3b9de374
Commit
3b9de374
authored
9 years ago
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replicate APM Mission quirks
parent
f0d99039
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
11 deletions
+38
-11
MockLink.cc
src/comm/MockLink.cc
+7
-6
MockLink.h
src/comm/MockLink.h
+11
-3
MockLinkMissionItemHandler.cc
src/comm/MockLinkMissionItemHandler.cc
+17
-2
MockLinkMissionItemHandler.h
src/comm/MockLinkMissionItemHandler.h
+3
-0
No files found.
src/comm/MockLink.cc
View file @
3b9de374
...
@@ -84,13 +84,14 @@ MockLink::MockLink(MockConfiguration* config)
...
@@ -84,13 +84,14 @@ MockLink::MockLink(MockConfiguration* config)
,
_mavlinkStarted
(
false
)
,
_mavlinkStarted
(
false
)
,
_mavBaseMode
(
MAV_MODE_FLAG_MANUAL_INPUT_ENABLED
|
MAV_MODE_FLAG_CUSTOM_MODE_ENABLED
)
,
_mavBaseMode
(
MAV_MODE_FLAG_MANUAL_INPUT_ENABLED
|
MAV_MODE_FLAG_CUSTOM_MODE_ENABLED
)
,
_mavState
(
MAV_STATE_STANDBY
)
,
_mavState
(
MAV_STATE_STANDBY
)
,
_
autopilot
Type
(
MAV_AUTOPILOT_PX4
)
,
_
firmware
Type
(
MAV_AUTOPILOT_PX4
)
,
_fileServer
(
NULL
)
,
_fileServer
(
NULL
)
,
_sendStatusText
(
false
)
,
_sendStatusText
(
false
)
,
_apmSendHomePositionOnEmptyList
(
false
)
{
{
_config
=
config
;
_config
=
config
;
if
(
_config
)
{
if
(
_config
)
{
_
autopilot
Type
=
config
->
firmwareType
();
_
firmware
Type
=
config
->
firmwareType
();
_sendStatusText
=
config
->
sendStatusText
();
_sendStatusText
=
config
->
sendStatusText
();
}
}
...
@@ -250,7 +251,7 @@ void MockLink::_sendHeartBeat(void)
...
@@ -250,7 +251,7 @@ void MockLink::_sendHeartBeat(void)
_vehicleComponentId
,
_vehicleComponentId
,
&
msg
,
&
msg
,
MAV_TYPE_QUADROTOR
,
// MAV_TYPE
MAV_TYPE_QUADROTOR
,
// MAV_TYPE
_
autopilot
Type
,
// MAV_AUTOPILOT
_
firmware
Type
,
// MAV_AUTOPILOT
_mavBaseMode
,
// MAV_MODE
_mavBaseMode
,
// MAV_MODE
_mavCustomMode
,
// custom mode
_mavCustomMode
,
// custom mode
_mavState
);
// MAV_STATE
_mavState
);
// MAV_STATE
...
@@ -436,7 +437,7 @@ float MockLink::_floatUnionForParam(int componentId, const QString& paramName)
...
@@ -436,7 +437,7 @@ float MockLink::_floatUnionForParam(int componentId, const QString& paramName)
switch
(
paramType
)
{
switch
(
paramType
)
{
case
MAV_PARAM_TYPE_INT8
:
case
MAV_PARAM_TYPE_INT8
:
if
(
_
autopilot
Type
==
MAV_AUTOPILOT_ARDUPILOTMEGA
)
{
if
(
_
firmware
Type
==
MAV_AUTOPILOT_ARDUPILOTMEGA
)
{
valueUnion
.
param_float
=
(
unsigned
char
)
paramVar
.
toChar
().
toLatin1
();
valueUnion
.
param_float
=
(
unsigned
char
)
paramVar
.
toChar
().
toLatin1
();
}
else
{
}
else
{
valueUnion
.
param_int8
=
(
unsigned
char
)
paramVar
.
toChar
().
toLatin1
();
valueUnion
.
param_int8
=
(
unsigned
char
)
paramVar
.
toChar
().
toLatin1
();
...
@@ -444,7 +445,7 @@ float MockLink::_floatUnionForParam(int componentId, const QString& paramName)
...
@@ -444,7 +445,7 @@ float MockLink::_floatUnionForParam(int componentId, const QString& paramName)
break
;
break
;
case
MAV_PARAM_TYPE_INT32
:
case
MAV_PARAM_TYPE_INT32
:
if
(
_
autopilot
Type
==
MAV_AUTOPILOT_ARDUPILOTMEGA
)
{
if
(
_
firmware
Type
==
MAV_AUTOPILOT_ARDUPILOTMEGA
)
{
valueUnion
.
param_float
=
paramVar
.
toInt
();
valueUnion
.
param_float
=
paramVar
.
toInt
();
}
else
{
}
else
{
valueUnion
.
param_int32
=
paramVar
.
toInt
();
valueUnion
.
param_int32
=
paramVar
.
toInt
();
...
@@ -452,7 +453,7 @@ float MockLink::_floatUnionForParam(int componentId, const QString& paramName)
...
@@ -452,7 +453,7 @@ float MockLink::_floatUnionForParam(int componentId, const QString& paramName)
break
;
break
;
case
MAV_PARAM_TYPE_UINT32
:
case
MAV_PARAM_TYPE_UINT32
:
if
(
_
autopilot
Type
==
MAV_AUTOPILOT_ARDUPILOTMEGA
)
{
if
(
_
firmware
Type
==
MAV_AUTOPILOT_ARDUPILOTMEGA
)
{
valueUnion
.
param_float
=
paramVar
.
toUInt
();
valueUnion
.
param_float
=
paramVar
.
toUInt
();
}
else
{
}
else
{
valueUnion
.
param_uint32
=
paramVar
.
toUInt
();
valueUnion
.
param_uint32
=
paramVar
.
toUInt
();
...
...
This diff is collapsed.
Click to expand it.
src/comm/MockLink.h
View file @
3b9de374
...
@@ -74,9 +74,16 @@ public:
...
@@ -74,9 +74,16 @@ public:
// MockLink methods
// MockLink methods
int
vehicleId
(
void
)
{
return
_vehicleSystemId
;
}
int
vehicleId
(
void
)
{
return
_vehicleSystemId
;
}
MAV_AUTOPILOT
get
AutopilotType
(
void
)
{
return
_autopilot
Type
;
}
MAV_AUTOPILOT
get
FirmwareType
(
void
)
{
return
_firmware
Type
;
}
void
set
AutopilotType
(
MAV_AUTOPILOT
autopilot
)
{
_autopilot
Type
=
autopilot
;
}
void
set
FirmwareType
(
MAV_AUTOPILOT
autopilot
)
{
_firmware
Type
=
autopilot
;
}
void
setSendStatusText
(
bool
sendStatusText
)
{
_sendStatusText
=
sendStatusText
;
}
void
setSendStatusText
(
bool
sendStatusText
)
{
_sendStatusText
=
sendStatusText
;
}
/// APM stack has strange handling of the first item of the mission list. If it has no
/// onboard mission items, sometimes it sends back a home position in position 0 and
/// sometimes it doesn't. Don't ask. This option allows you to configure that behavior
/// for unit testing.
void
setAPMMissionResponseMode
(
bool
sendHomePositionOnEmptyList
)
{
_apmSendHomePositionOnEmptyList
=
sendHomePositionOnEmptyList
;
}
void
emitRemoteControlChannelRawChanged
(
int
channel
,
uint16_t
raw
);
void
emitRemoteControlChannelRawChanged
(
int
channel
,
uint16_t
raw
);
/// Sends the specified mavlink message to QGC
/// Sends the specified mavlink message to QGC
...
@@ -177,11 +184,12 @@ private:
...
@@ -177,11 +184,12 @@ private:
uint8_t
_mavState
;
uint8_t
_mavState
;
MockConfiguration
*
_config
;
MockConfiguration
*
_config
;
MAV_AUTOPILOT
_
autopilot
Type
;
MAV_AUTOPILOT
_
firmware
Type
;
MockLinkFileServer
*
_fileServer
;
MockLinkFileServer
*
_fileServer
;
bool
_sendStatusText
;
bool
_sendStatusText
;
bool
_apmSendHomePositionOnEmptyList
;
static
float
_vehicleLatitude
;
static
float
_vehicleLatitude
;
static
float
_vehicleLongitude
;
static
float
_vehicleLongitude
;
...
...
This diff is collapsed.
Click to expand it.
src/comm/MockLinkMissionItemHandler.cc
View file @
3b9de374
...
@@ -32,6 +32,7 @@ MockLinkMissionItemHandler::MockLinkMissionItemHandler(MockLink* mockLink)
...
@@ -32,6 +32,7 @@ MockLinkMissionItemHandler::MockLinkMissionItemHandler(MockLink* mockLink)
:
_mockLink
(
mockLink
)
:
_mockLink
(
mockLink
)
,
_missionItemResponseTimer
(
NULL
)
,
_missionItemResponseTimer
(
NULL
)
,
_failureMode
(
FailNone
)
,
_failureMode
(
FailNone
)
,
_sendHomePositionOnEmptyList
(
false
)
{
{
Q_ASSERT
(
mockLink
);
Q_ASSERT
(
mockLink
);
}
}
...
@@ -99,6 +100,11 @@ void MockLinkMissionItemHandler::_handleMissionRequestList(const mavlink_message
...
@@ -99,6 +100,11 @@ void MockLinkMissionItemHandler::_handleMissionRequestList(const mavlink_message
mavlink_msg_mission_request_list_decode
(
&
msg
,
&
request
);
mavlink_msg_mission_request_list_decode
(
&
msg
,
&
request
);
Q_ASSERT
(
request
.
target_system
==
_mockLink
->
vehicleId
());
Q_ASSERT
(
request
.
target_system
==
_mockLink
->
vehicleId
());
int
itemCount
=
_missionItems
.
count
();
if
(
itemCount
==
0
&&
_sendHomePositionOnEmptyList
)
{
itemCount
=
1
;
}
mavlink_message_t
responseMsg
;
mavlink_message_t
responseMsg
;
...
@@ -107,7 +113,7 @@ void MockLinkMissionItemHandler::_handleMissionRequestList(const mavlink_message
...
@@ -107,7 +113,7 @@ void MockLinkMissionItemHandler::_handleMissionRequestList(const mavlink_message
&
responseMsg
,
// Outgoing message
&
responseMsg
,
// Outgoing message
msg
.
sysid
,
// Target is original sender
msg
.
sysid
,
// Target is original sender
msg
.
compid
,
// Target is original sender
msg
.
compid
,
// Target is original sender
_missionItems
.
count
());
// Number of mission items
itemCount
);
// Number of mission items
_mockLink
->
respondWithMavlinkMessage
(
responseMsg
);
_mockLink
->
respondWithMavlinkMessage
(
responseMsg
);
}
else
{
}
else
{
qCDebug
(
MockLinkMissionItemHandlerLog
)
<<
"_handleMissionRequestList not responding due to failure mode"
;
qCDebug
(
MockLinkMissionItemHandlerLog
)
<<
"_handleMissionRequestList not responding due to failure mode"
;
...
@@ -148,7 +154,16 @@ void MockLinkMissionItemHandler::_handleMissionRequest(const mavlink_message_t&
...
@@ -148,7 +154,16 @@ void MockLinkMissionItemHandler::_handleMissionRequest(const mavlink_message_t&
}
else
{
}
else
{
mavlink_message_t
responseMsg
;
mavlink_message_t
responseMsg
;
mavlink_mission_item_t
item
=
_missionItems
[
request
.
seq
];
mavlink_mission_item_t
item
;
if
(
_missionItems
.
count
()
==
0
&&
_sendHomePositionOnEmptyList
)
{
item
.
frame
=
MAV_FRAME_GLOBAL_RELATIVE_ALT
;
item
.
command
=
MAV_CMD_NAV_WAYPOINT
;
item
.
current
=
false
;
item
.
autocontinue
=
true
;
item
.
param1
=
item
.
param2
=
item
.
param3
=
item
.
param4
=
item
.
x
=
item
.
y
=
item
.
z
=
0
;
}
else
{
item
=
_missionItems
[
request
.
seq
];
}
mavlink_msg_mission_item_pack
(
_mockLink
->
vehicleId
(),
mavlink_msg_mission_item_pack
(
_mockLink
->
vehicleId
(),
MAV_COMP_ID_MISSIONPLANNER
,
MAV_COMP_ID_MISSIONPLANNER
,
...
...
This diff is collapsed.
Click to expand it.
src/comm/MockLinkMissionItemHandler.h
View file @
3b9de374
...
@@ -88,6 +88,8 @@ public:
...
@@ -88,6 +88,8 @@ public:
/// Reset the state of the MissionItemHandler to no items, no transactions in progress.
/// Reset the state of the MissionItemHandler to no items, no transactions in progress.
void
reset
(
void
)
{
_missionItems
.
clear
();
}
void
reset
(
void
)
{
_missionItems
.
clear
();
}
void
setSendHomePositionOnEmptyList
(
bool
sendHomePositionOnEmptyList
)
{
_sendHomePositionOnEmptyList
=
sendHomePositionOnEmptyList
;
}
private
slots
:
private
slots
:
void
_missionItemResponseTimeout
(
void
);
void
_missionItemResponseTimeout
(
void
);
...
@@ -112,6 +114,7 @@ private:
...
@@ -112,6 +114,7 @@ private:
QTimer
*
_missionItemResponseTimer
;
QTimer
*
_missionItemResponseTimer
;
FailureMode_t
_failureMode
;
FailureMode_t
_failureMode
;
bool
_failureFirstTimeOnly
;
bool
_failureFirstTimeOnly
;
bool
_sendHomePositionOnEmptyList
;
};
};
#endif
#endif
This diff is collapsed.
Click to expand it.
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