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
246bfba0
Commit
246bfba0
authored
Apr 02, 2017
by
Don Gagne
Committed by
GitHub
Apr 02, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4903 from DonLakeFlyer/BatteryCalc
Plan: Support battery calculations
parents
00f02f07
9bac4fbc
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
140 additions
and
135 deletions
+140
-135
FirmwarePlugin.cc
src/FirmwarePlugin/FirmwarePlugin.cc
+8
-0
FirmwarePlugin.h
src/FirmwarePlugin/FirmwarePlugin.h
+6
-0
MissionController.cc
src/MissionManager/MissionController.cc
+81
-107
MissionController.h
src/MissionManager/MissionController.h
+31
-18
PlanToolBar.qml
src/PlanView/PlanToolBar.qml
+14
-10
No files found.
src/FirmwarePlugin/FirmwarePlugin.cc
View file @
246bfba0
...
...
@@ -437,3 +437,11 @@ bool FirmwarePlugin::_armVehicle(Vehicle* vehicle)
}
return
vehicle
->
armed
();
}
void
FirmwarePlugin
::
batteryConsumptionData
(
Vehicle
*
vehicle
,
int
&
mAhBattery
,
int
&
hoverAmps
,
int
&
cruiseAmps
)
const
{
Q_UNUSED
(
vehicle
);
mAhBattery
=
0
;
hoverAmps
=
0
;
cruiseAmps
=
0
;
}
src/FirmwarePlugin/FirmwarePlugin.h
View file @
246bfba0
...
...
@@ -276,6 +276,12 @@ public:
/// @true: When flying a mission the vehicle is always facing towards the next waypoint
virtual
bool
vehicleYawsToNextWaypointInMission
(
const
Vehicle
*
vehicle
)
const
;
/// Returns the data needed to do battery consumption calculations
/// @param[out] mAhBattery Battery milliamp-hours rating (0 for no battery data available)
/// @param[out] hoverAmps Current draw in amps during hover
/// @param[out] cruiseAmps Current draw in amps during cruise
virtual
void
batteryConsumptionData
(
Vehicle
*
vehicle
,
int
&
mAhBattery
,
int
&
hoverAmps
,
int
&
cruiseAmps
)
const
;
// FIXME: Hack workaround for non pluginize FollowMe support
static
const
char
*
px4FollowMeFlightMode
;
...
...
src/MissionManager/MissionController.cc
View file @
246bfba0
This diff is collapsed.
Click to expand it.
src/MissionManager/MissionController.h
View file @
246bfba0
...
...
@@ -38,17 +38,25 @@ public:
~
MissionController
();
typedef
struct
{
double
maxTelemetryDistance
;
double
totalDistance
;
double
totalTime
;
double
hoverDistance
;
double
hoverTime
;
double
cruiseDistance
;
double
cruiseTime
;
double
cruiseSpeed
;
double
hoverSpeed
;
double
vehicleSpeed
;
//</ Either cruise or hover speed based on vehicle type and vtol state
double
gimbalYaw
;
///< NaN signals yaw was never changed
double
maxTelemetryDistance
;
double
totalDistance
;
double
totalTime
;
double
hoverDistance
;
double
hoverTime
;
double
cruiseDistance
;
double
cruiseTime
;
double
cruiseSpeed
;
double
hoverSpeed
;
double
vehicleSpeed
;
///< Either cruise or hover speed based on vehicle type and vtol state
double
gimbalYaw
;
///< NaN signals yaw was never changed
int
mAhBattery
;
///< 0 for not available
int
hoverAmps
;
///< Amp consumption during hover
int
cruiseAmps
;
///< Amp consumption during cruise
double
ampMinutesAvailable
;
///< Amp minutes available from single battery
double
hoverAmpsTotal
;
///< Total hover amps used
double
cruiseAmpsTotal
;
///< Total cruise amps used
int
batteryChangePoint
;
///< -1 for not supported, 0 for not needed
int
batteriesRequired
;
///< -1 for not supported
}
MissionFlightStatus_t
;
Q_PROPERTY
(
QmlObjectListModel
*
visualItems
READ
visualItems
NOTIFY
visualItemsChanged
)
...
...
@@ -65,6 +73,9 @@ public:
Q_PROPERTY
(
double
missionCruiseTime
READ
missionCruiseTime
NOTIFY
missionCruiseTimeChanged
)
Q_PROPERTY
(
double
missionMaxTelemetry
READ
missionMaxTelemetry
NOTIFY
missionMaxTelemetryChanged
)
Q_PROPERTY
(
int
batteryChangePoint
READ
batteryChangePoint
NOTIFY
batteryChangePointChanged
)
Q_PROPERTY
(
int
batteriesRequired
READ
batteriesRequired
NOTIFY
batteriesRequiredChanged
)
Q_INVOKABLE
void
removeMissionItem
(
int
index
);
/// Add a new simple mission item to the list
...
...
@@ -124,6 +135,9 @@ public:
double
missionCruiseTime
(
void
)
const
{
return
_missionFlightStatus
.
cruiseTime
;
}
double
missionMaxTelemetry
(
void
)
const
{
return
_missionFlightStatus
.
maxTelemetryDistance
;
}
int
batteryChangePoint
(
void
)
const
{
return
_missionFlightStatus
.
batteryChangePoint
;
}
///< -1 for not supported, 0 for not needed
int
batteriesRequired
(
void
)
const
{
return
_missionFlightStatus
.
batteriesRequired
;
}
///< -1 for not supported
signals:
void
visualItemsChanged
(
void
);
void
waypointLinesChanged
(
void
);
...
...
@@ -138,6 +152,8 @@ signals:
void
complexMissionItemNamesChanged
(
void
);
void
resumeMissionItemChanged
(
void
);
void
resumeMissionReady
(
void
);
void
batteryChangePointChanged
(
int
batteryChangePoint
);
void
batteriesRequiredChanged
(
int
batteriesRequired
);
private
slots
:
void
_newMissionItemsAvailableFromVehicle
(
bool
removeAllRequested
);
...
...
@@ -171,16 +187,13 @@ private:
static
bool
_loadJsonMissionFileV2
(
Vehicle
*
vehicle
,
const
QJsonObject
&
json
,
QmlObjectListModel
*
visualItems
,
QString
&
errorString
);
static
bool
_loadTextMissionFile
(
Vehicle
*
vehicle
,
QTextStream
&
stream
,
QmlObjectListModel
*
visualItems
,
QString
&
errorString
);
int
_nextSequenceNumber
(
void
);
void
_setMissionDistance
(
double
missionDistance
);
void
_setMissionTime
(
double
missionTime
);
void
_setMissionHoverDistance
(
double
missionHoverDistance
);
void
_setMissionHoverTime
(
double
missionHoverTime
);
void
_setMissionCruiseDistance
(
double
missionCruiseDistance
);
void
_setMissionCruiseTime
(
double
missionCruiseTime
);
void
_setMissionMaxTelemetry
(
double
missionMaxTelemetry
);
static
void
_scanForAdditionalSettings
(
QmlObjectListModel
*
visualItems
,
Vehicle
*
vehicle
);
static
bool
_convertToMissionItems
(
QmlObjectListModel
*
visualMissionItems
,
QList
<
MissionItem
*>&
rgMissionItems
,
QObject
*
missionItemParent
);
void
_setPlannedHomePositionFromFirstCoordinate
(
void
);
void
_resetMissionFlightStatus
(
void
);
void
_addHoverTime
(
double
hoverTime
,
double
hoverDistance
,
int
waypointIndex
);
void
_addCruiseTime
(
double
cruiseTime
,
double
cruiseDistance
,
int
wayPointIndex
);
void
_updateBatteryInfo
(
int
waypointIndex
);
// Overrides from PlanElementController
void
_activeVehicleBeingRemoved
(
void
)
final
;
...
...
src/PlanView/PlanToolBar.qml
View file @
246bfba0
...
...
@@ -51,14 +51,18 @@ Rectangle {
property
real
_missionDistance
:
_missionValid
?
missionDistance
:
NaN
property
real
_missionMaxTelemetry
:
_missionValid
?
missionMaxTelemetry
:
NaN
property
real
_missionTime
:
_missionValid
?
missionTime
:
NaN
property
string
_distanceText
:
isNaN
(
_distance
)
?
"
-.-
"
:
QGroundControl
.
metersToAppSettingsDistanceUnits
(
_distance
).
toFixed
(
1
)
+
"
"
+
QGroundControl
.
appSettingsDistanceUnitsString
property
string
_altDifferenceText
:
isNaN
(
_altDifference
)
?
"
-.-
"
:
QGroundControl
.
metersToAppSettingsDistanceUnits
(
_altDifference
).
toFixed
(
1
)
+
"
"
+
QGroundControl
.
appSettingsDistanceUnitsString
property
string
_gradientText
:
isNaN
(
_gradient
)
?
"
-.-
"
:
_gradientPercent
.
toFixed
(
0
)
+
"
%
"
property
string
_azimuthText
:
isNaN
(
_azimuth
)
?
"
-.-
"
:
Math
.
round
(
_azimuth
)
property
string
_missionDistanceText
:
isNaN
(
_missionDistance
)
?
"
-.-
"
:
QGroundControl
.
metersToAppSettingsDistanceUnits
(
_missionDistance
).
toFixed
(
1
)
+
"
"
+
QGroundControl
.
appSettingsDistanceUnitsString
property
string
_missionTimeText
:
isNaN
(
_missionTime
)
?
"
-.-
"
:
Number
(
_missionTime
/
60
).
toFixed
(
1
)
+
"
min
"
property
string
_missionMaxTelemetryText
:
isNaN
(
_missionMaxTelemetry
)
?
"
-.-
"
:
QGroundControl
.
metersToAppSettingsDistanceUnits
(
_missionMaxTelemetry
).
toFixed
(
1
)
+
"
"
+
QGroundControl
.
appSettingsDistanceUnitsString
property
int
_batteryChangePoint
:
_controllerValid
?
missionController
.
batteryChangePoint
:
-
1
property
int
_batteriesRequired
:
_controllerValid
?
missionController
.
batteriesRequired
:
-
1
property
string
_distanceText
:
isNaN
(
_distance
)
?
"
-.-
"
:
QGroundControl
.
metersToAppSettingsDistanceUnits
(
_distance
).
toFixed
(
1
)
+
"
"
+
QGroundControl
.
appSettingsDistanceUnitsString
property
string
_altDifferenceText
:
isNaN
(
_altDifference
)
?
"
-.-
"
:
QGroundControl
.
metersToAppSettingsDistanceUnits
(
_altDifference
).
toFixed
(
1
)
+
"
"
+
QGroundControl
.
appSettingsDistanceUnitsString
property
string
_gradientText
:
isNaN
(
_gradient
)
?
"
-.-
"
:
_gradientPercent
.
toFixed
(
0
)
+
"
%
"
property
string
_azimuthText
:
isNaN
(
_azimuth
)
?
"
-.-
"
:
Math
.
round
(
_azimuth
)
property
string
_missionDistanceText
:
isNaN
(
_missionDistance
)
?
"
-.-
"
:
QGroundControl
.
metersToAppSettingsDistanceUnits
(
_missionDistance
).
toFixed
(
1
)
+
"
"
+
QGroundControl
.
appSettingsDistanceUnitsString
property
string
_missionTimeText
:
isNaN
(
_missionTime
)
?
"
-.-
"
:
Number
(
_missionTime
/
60
).
toFixed
(
1
)
+
"
min
"
property
string
_missionMaxTelemetryText
:
isNaN
(
_missionMaxTelemetry
)
?
"
-.-
"
:
QGroundControl
.
metersToAppSettingsDistanceUnits
(
_missionMaxTelemetry
).
toFixed
(
1
)
+
"
"
+
QGroundControl
.
appSettingsDistanceUnitsString
property
string
_batteryChangePointText
:
_batteryChangePoint
<
0
?
"
N/A
"
:
_batteryChangePoint
property
string
_batteriesRequiredText
:
_batteriesRequired
<
0
?
"
N/A
"
:
_batteriesRequired
readonly
property
real
_margins
:
ScreenTools
.
defaultFontPixelWidth
...
...
@@ -164,12 +168,12 @@ Rectangle {
}
QGCLabel
{
text
:
qsTr
(
"
Batteries required:
"
)
}
QGCLabel
{
text
:
"
--.--
"
}
QGCLabel
{
text
:
_batteriesRequiredText
}
Item
{
width
:
1
;
height
:
1
}
QGCLabel
{
text
:
qsTr
(
"
Swap waypoint:
"
)
}
QGCLabel
{
text
:
"
--
"
}
QGCLabel
{
text
:
_batteryChangePointText
}
}
}
...
...
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