Type: | Package |
Title: | UAV Mission Planner |
Version: | 0.7 |
Date: | 2024-06-07 |
Encoding: | UTF-8 |
Maintainer: | Chris Reudenbach <reudenbach@uni-marburg.de> |
Description: | The Unmanned Aerial Vehicle Mission Planner provides an easy to use work flow for planning autonomous obstacle avoiding surveys of ready to fly unmanned aerial vehicles to retrieve aerial or spot related data. It creates either intermediate flight control files for the DJI-Litchi supported series or ready to upload control files for the pixhawk-based flight controller. Additionally it contains some useful tools for digitizing and data manipulation. |
URL: | https://github.com/gisma/uavRmp |
BugReports: | https://github.com/gisma/uavRmp/issues |
License: | GPL (≥ 3) | file LICENSE |
Depends: | R (≥ 3.1.0) |
Imports: | sp, sf, geosphere, tools, log4r, zoo, methods, brew, exifr, link2GI, data.table, jsonlite, rlist, xfun, terra, concaveman, dplyr, spatialEco |
RoxygenNote: | 7.3.1 |
SystemRequirements: | GNU make |
Suggests: | knitr, rmarkdown, markdown, mapview, grDevices, stringr, htmltools, htmlwidgets, |
VignetteBuilder: | knitr |
NeedsCompilation: | no |
Packaged: | 2024-06-07 08:47:10 UTC; creu |
Author: | Chris Reudenbach [cre, aut], Marvin Ludwig [ctb], Sebastian Richter [ctb], Florian Detsch [ctb], Hanna Meyer [ctb] |
Repository: | CRAN |
Date/Publication: | 2024-06-07 09:10:02 UTC |
UAV Mission Planner
Description
The package provides some mission planning functionality for dealing with Unmanned Aerial Vehicles. The focus is set on an easy to use workflow for planning autonomous obstacle avoiding surveys of rtf-UAVs to retrieve aerial or spot related data. It provides either intermediate flight control files for the DJI Litchi compatible UAVs or ready to upload control files for the pixhawk based flightcontroller as used in the Yuneec H520 or the outdated 3DR Solo. Additionally it contains some useful tools for digitizing and data manipulation.
Details
The package provides some mission planning functionality for dealing with Unmanned Aerial Vehicles
Note
It is important to keep in mind that all auxilliary external binaries like GDAL or SAGA need to be installed properly. correctly on your system.
Author(s)
Chris Reudenbach Lars Opgenoorth Sebastian Richter Florian Detsch Hanna Meyer Marvin Ludwig
Maintainer: Chris Reudenbach reudenbach@uni-marburg.de
See Also
Useful links:
copyDir
Description
copyDir copy all image data to the corresponding folder
Usage
copyDir(fromDir, toProjDir, pattern = "*")
Arguments
fromDir |
|
toProjDir |
|
pattern |
|
Select UAV Images Information
Description
extract all and returns specific exif information from a list of images
Usage
extractExifr(path)
Arguments
path |
path to the images files |
Value
data.frame of image positions and travel distance
fixGPSAlt
Description
fixes broken GPS altitudes in the exif data of DJI images with the given differen value
Usage
fixGPSAlt(path, diff, camType = "YUN")
Arguments
path |
|
diff |
|
camType |
|
Examples
## Not run:
picFN <- system.file("extdata", "dji.jpg", package = "uavRmp")
## End(Not run)
getGPSAltDiff
Description
extract the difference of the exif GPS aLtitude tag and a given DEM altitude at this point
Usage
getGPSAltDiff(picPath, demPath)
Arguments
picPath |
|
demPath |
|
Examples
## Not run:
demFN <- system.file("extdata", "mrbiko.tif", package = "uavRmp")
picFN <- system.file("extdata", "dji.jpg", package = "uavRmp")
## End(Not run)
Defines and creates folders and variables
Description
Defines and creates (if necessary) all folders variables set the SAGA path variables and other system variables exports all variables to the global environment
Usage
initProj(
projRootDir = getwd(),
projFolders = c("log/", "control/", "run/", "data/")
)
Arguments
projRootDir |
project github root directory (your github name) |
projFolders |
list of subfolders in project |
UAV Mission Planning tool for autonomous monitoring flight tasks with respect to DSM/DEM, orthophoto data retrieval.
Description
The basic idea is to provide an easy to use workflow for controlling rtf-UAVs for planning autonomous surveys to retrieve aerial data sets.
Usage
makeAP(
projectDir = tempdir(),
locationName = "flightArea",
surveyArea = NULL,
flightAltitude = 100,
launchAltitude = NULL,
followSurface = FALSE,
followSurfaceRes = 25,
demFn = NULL,
noFiles = 1,
altFilter = 1,
horizonFilter = 30,
flightPlanMode = "track",
useMP = FALSE,
presetFlightTask = "remote",
overlap = 0.8,
maxSpeed = 20,
maxFlightTime = 10,
picRate = 2,
windCondition = 0,
uavType = "pixhawk",
cameraType = "MAPIR2",
buf_mult = 1.5,
cmd = 16,
uavViewDir = 0,
maxwaypoints = 9999,
above_ground = FALSE,
djiBasic = c(0, 0, 0, -90, 0),
dA = FALSE,
picFootprint = FALSE,
rcRange = NULL,
copy = FALSE,
runDir = tempdir(),
gdalLink = NULL
)
Arguments
projectDir |
|
locationName |
|
surveyArea |
you may provide either the coordinates by c(lon1,lat1,lon2,lat2,lon3,lat3,launchLat,launchLon) or an OGR compatible file (prefunable to find an inherited method for function ‘makeAP’ for signature ‘"missing"’erably geoJSON or KML) with at least 4 coordinates that describe the flight area. The fourth coordinate is the launch position. You will find further explanation under seealso. |
flightAltitude |
set the default flight altitude of the mission. It is assumed that the UAV is started at the highest point of the surveyArea otherwise you have to defined the position of launching. |
launchAltitude |
absolute altitude of launching position. It will overwrite the DEM based estimation if any other value than -9999 |
followSurface |
|
followSurfaceRes |
horizontal step distance for analyzing the DEM altitudes |
demFn |
filename of the corresponding DEM data file. |
noFiles |
manual split number of files |
altFilter |
if |
horizonFilter |
integer filter size of the rolling filter kernel for the flight track. Must be multiplied by the |
flightPlanMode |
type of flight plan. Available are: |
useMP |
default is FALSE switches to use a missionplanner/Qgroundcontrolplanner survey as planning base |
presetFlightTask |
(DJI only) strongly recommended to use "remote"
|
overlap |
overlapping of the pictures in percent (1.0 = 100) |
maxSpeed |
cruising speed |
maxFlightTime |
user defined estimation of the lipo lifetime (20 min default) |
picRate |
fastest stable interval (s) for shooting pictures |
windCondition |
1= calm 2= light air 1-5km/h, 3= light breeze 6-11km/h, 4=gentle breeze 12-19km/h 5= moderate breeze 20-28km/h |
uavType |
type of UAV. currently "dji_csv" for Litchi CSV export and "pixhawk" for MAVlink compatible flightplans are supported |
cameraType |
depending on the UAV Platform and integrated camera choose for DJI Mini 1/2/3, Phantom 3/Phantom 4 , Inspire 1) the |
buf_mult |
multiplier for defining the zone in which the waypoints are assumed to be turning waypoints according to buf_mult * |
cmd |
mavlink command |
uavViewDir |
view direction of uav |
maxwaypoints |
maximal number of waypoints for Litchi default is 90 |
above_ground |
Litchi setting if the waypoint altitudes are interpreted as AGL default = FALSE |
djiBasic |
c(0,0,0,-90)
|
dA |
if TRUE the real extent of the used DEM is returned helpful for low altitudes flight planning |
picFootprint |
switch for calculating the footprint at all way points |
rcRange |
range of estimated range of remote control |
copy |
copy switch |
runDir |
|
gdalLink |
link to GDAL binaries |
Details
makeAP (make aerial plan) creates either intermediate flight control files for the
DJI phantom x UAVs or ready to upload control files for the 3DR Solo/PixHawk flight controller. The
DJI control files are designed for using with the proprietary litchi flight
control app exchange format, while the 3DR Solo/PixHawk flight controller files are using the MAVLINK
common message set, that is used by the PixHawk flight controller family.
Both are implemented very rudimentary.
DJI:
The reason using DJI
is their absolute straightforward usage. Everybody can fly with a DJI but
the price is a more or less closed system at least in the low budget segment. There are workarounds like the litchi app that provides
additionally to a cloud based mission planner an offline/standalone
interface to upload a CSV formatted way point file for autonomous flights to
the Phantom.
PixHawk flight controller/3DR Solo:
The open UAV community is focused
on the PixHawk autopilot unit and the Mission Planner software. It is well
documented and several APIs are provided. Nevertheless a high resolution
terrain following flight planning tool for autonomous obstacle avoiding flight missions
is not available. makeAP
creates a straightforward version of MAV format flight control
rules that are ready to be uploaded directly on the Pixhawk controller using the solo_upload
function.
Warning
Take care! There are still a lot of construction zones around. This script is far beyond to be in a mature state. Please control and backup all controls again while planning and performing autonomous flight plans and missions. You will have a lot of chances to make a small mistake what may yield in a damage of your UAV or even worse in involving people, animals or non-cash assets. Check your risk, use parachute systems and even if it is running like a charm, keep alert!
See Also
The underlying concept, a tutorial and a field guide can be found in the package vignettes. See browseVignettes("uavRmp")
or vignette(package = "uavRmp")
or
at Github uavRmp manual).
Examples
## Not run:
# Depending on the arguments, the following spatial data sets can be returned:
# lp the planned launching position of the UAV.
# wp waypoints inclusive all information
# oDEM the original (input) digital surface model (DSM)
# rDEM the resampled (used) DSM
# fp optimized footprints of the camera
# fA flight area with at least 2 overlaps
# rcA area covered by the RC according to the range and line of sight
## for visualisation and vecDraw load mapview
require(mapview)
## (1) get example DEM data
demFn <- system.file("extdata", "mrbiko.tif", package = "uavRmp")
tutorial_flightArea <- system.file("extdata", "flightarea.kml", package = "uavRmp")
## (2) simple flight, 100 meters above ground
## assuming a flat topography,
fp <- makeAP(surveyArea = tutorial_flightArea,
demFn = demFn)
## (3) typical real case scenario (1)
## A flight altitudes BELOW 50 m is ambitious and risky
## You have to use a high quality high resulution DSM
## (here simulated with a standard DEM)
fp <- makeAP(surveyArea=tutorial_flightArea,
followSurface = TRUE,
flightAltitude = 45,
demFn = demFn,
windCondition = 1,
uavType = "dji_csv",cameraType = "dji32",
followSurfaceRes = 5,
altFilter = .75)
## (4) typical real case scenario (2)
## A flight altitudes BELOW 50 m is ambitious and risky
## You have to use a high quality high resolution DSM
## (here simulated with a standard DEM)
## NOTE All settings are taken from QGroundcontrol so adapt the survey settings according
## to "calc above terain" and use the "YUN90" camera tag for camera flight speed etc.
## NOTE EXPERIMENTAL
demFn <- system.file("extdata", "mrbiko.tif", package = "uavRmp")
tutorial_flightArea <- system.file("extdata", "tutdata_qgc_survey.plan", package = "uavRmp")
fp <- makeAP(surveyArea=tutorial_flightArea,
useMP = TRUE,
followSurface = TRUE,
demFn = demFn,
windCondition = 1,
uavType = "pixhawk",
cameraType = "YUN90",
followSurfaceRes = 5,
altFilter = .75)
## (5) typical real case scenario (3)
## This examples uses a flight planning from the QGroundcotrol Survey planning tool
## It also used the all calculations for camera flight speed etc.
## The flight plan is modyfied by splitting up the task according to 99 Waypoints
## and flight time and saved as litchi csv format
## NOTE EXPERIMENTAL tested with DJI mavic mini 2
demFn <- system.file("extdata", "mrbiko.tif", package = "uavRmp")
tutorial_flightArea <- system.file("extdata", "tutdata_qgc_survey.plan", package = "uavRmp")
fp <- makeAP(surveyArea=tutorial_flightArea,
useMP = TRUE,
demFn = demFn,
maxFlightTime = 25,
cameraType = "dji32",
uavType = "dji_csv")
## call a simple shiny interface
shiny::runApp(system.file("shiny/plan2litchi/", "app.R", package = "uavRmp"))
## (6) view results
mapview::mapview(fp$wp,cex=4, lwd=0.5)+
mapview::mapview(fp$lp,color = "red", lwd=1,cex=4)+
mapview::mapview(fp$fA,color="blue", alpha.regions = 0.1,lwd=0.5)+
mapview::mapview(fp$oDEM,col=terrain.colors(256))
## (6) digitize flight area using the small "onboard" tool vecDraw()
## save vectors as "kml" or "json" files
## provide full filename + extension!
vecDraw(preset="uav")
## End(Not run)
Generates a variable with a certain value in the R environment
Description
Generates a variable with a certain value in the R environment
Usage
makeGlobalVar(name, value)
Arguments
name |
character string name of the variable |
value |
character string value of the variable |
Examples
## Not run:
# creates the global var `pathToData` with the value `~/home/data`
makeGlobalVar("pathToData","~/home/data")
## End(Not run)
Flight Track Planning tool
Description
makeTP generates a flight track chaining up point objects with respect to a heterogenous surface and known obstacles as documented by an DSM for taking top down pictures. It creates a single control file for autonomous picture retrieval flights.
Usage
makeTP(
projectDir = tempdir(),
locationName = "treePos",
missionTrackList = NULL,
launchPos = c(8.772055, 50.814689),
demFn = NULL,
flightAltitude = 100,
climbDist = 7.5,
aboveTreeAlt = 15,
circleRadius = 1,
takeOffAlt = 50,
presetFlightTask = "remote",
maxSpeed = 25,
followSurfaceRes = 5,
altFilter = 0.5,
windCondition = 1,
launchAltitude = -9999,
uavType = "pixhawk",
cameraType = "MAPIR2",
copy = FALSE,
runDir = ""
)
Arguments
projectDir |
|
locationName |
|
missionTrackList |
|
launchPos |
|
demFn |
|
flightAltitude |
|
climbDist |
|
aboveTreeAlt |
|
circleRadius |
|
takeOffAlt |
altitude |
presetFlightTask |
|
maxSpeed |
|
followSurfaceRes |
|
altFilter |
|
windCondition |
|
launchAltitude |
|
uavType |
|
cameraType |
|
copy |
|
runDir |
|
Examples
## Not run:
## (1) get example DEM data
dsmFn <- system.file("extdata", "mrbiko.tif", package = "uavRmp")
## (2) make position flight plan
makeTP <- makeTP(missionTrackList= tutorial_flightArea,
demFn = dsmFn,
uavType = "pixhawk",
launchPos = c(8.679,50.856))
## End(Not run)
applies a line to a raster and returns the position of the maximum value
Description
applies a line to a raster and returns the position of the maximum value
Usage
maxpos_on_line(dem, line)
Arguments
dem |
raster object |
line |
sp object |
Examples
## Not run:
## load DEM/DSM
dem <- terra::rast(system.file("extdata", "mrbiko.tif", package = "uavRmp"))
## generate extraction line object
line <- sp_line(c(8.66821,8.68212),c(50.83939,50.83267),ID="Highest Position",runDir=runDir)
## extract highest position
maxpos_on_line(dem,line)
## End(Not run)
Rectangle flight area around points
Description
Creates optimal rectangle area around points
Usage
minBB(points, buffer = 0, epsg = 25832)
Arguments
points |
a sf object, points you want to fly over |
buffer |
buffer distance between the points and the rectangle; defaults 0 |
epsg |
reference system |
Details
The code is based on a Rotating Caliper Algorithm and mostly copy and pasted (see reference)
Value
SpatialPoints: Corners of the flight area
Author(s)
Marvin Ludwig
References
http://dwoll.de/rexrepos/posts/diagBounding.html
Download, reorganize and export the binary log files from 3DR Solo Pixhawk controller or the telemetry log files from the Solo radio control unit
Description
Wraps the mavtogpx.py converter as provided by the dronkit library). It downloads and optionally converts the most important 3DR Solo logfiles. Optionally you may import the geometries and data as sp
object.
Usage
soloLog(
logFileSample = "recent",
logSource = "rc",
logDest = tempdir(),
downloadOnly = FALSE,
netWarn = FALSE,
renameFiles = TRUE,
makeSP = FALSE
)
Arguments
logFileSample |
|
logSource |
|
logDest |
|
downloadOnly |
|
netWarn |
|
renameFiles |
|
makeSP |
|
Note
for using the Solo stuff is tested only for Linux and the bash shell under Windows 10. You need to install the following python libs:
sudo pip install pymavlink
sudo pip install dronekit-sitl
sudo pip install dronekit
Additionally you need sshpass
:
sudo apt-get install sshpass
And please rememeber - you need to be connected at least to a running 3DR Solo radio control and if you want to donload data from the Pixhawk to a Solo UAV
Examples
## Not run:
## download recent telemetry log file from controller and convert it to gpx
soloLog(logFiles = "solo.tlog")
## download the last available logfile from the radio control
soloLog()
## download ALL logfiles from the radio control
soloLog(logFiles = "all")
## download ALL telemetry logfiles from the flight controller
soloLog(logSource = "pixhawk",logFiles = "all")
## download telementry logfile number 5 from the remote control
soloLog(logSource = "rc",logFiles = "5")
## End(Not run)
Upload MAV compliant mission File to a 3DR Solo
Description
solo_upload provides a crude interface to upload the Solo mission file to the 3dr SOLO
Usage
solo_upload(
missionFile = NULL,
connection = "udp:10.1.1.166:14550",
prearm = "-1"
)
Arguments
missionFile |
mission file to upload |
connection |
a valid connection string to the Solo default is "udp:10.1.1.166:14550" |
prearm |
|
Note
Becareful with fooling around with the prearm stuff. It is kind of VERY sensitive for the later autonomous flights!
For using the Solo stuff you need to install:
sudo pip install pymavlink;
sudo pip install dronekit-sitl;
sudo pip install dronekit;
sudo apt-get install sshpass
Additionally you need to be connected to a running 3DR Solo uav
Examples
wp <- system.file("extdata", "MAVLINK_waypoints.txt", package = "uavRmp")
## Not run:
solo_upload( missionFile = wp)
## End(Not run)
create an spatiallineobject from 2 points
Description
create an spatiallineobject from 2 points, optional export as shapefile
Usage
sp_line(
Y_coords,
X_coords,
ID = "ID",
proj4 = "+proj=longlat +datum=WGS84 +no_defs",
export = FALSE,
runDir
)
Arguments
Y_coords |
Y/lat coordinates |
X_coords |
X/lon coordinates |
ID |
id of line |
proj4 |
projection |
export |
write shafefile default = F |
runDir |
|
Examples
## Not run:
## creating sp spatial point object
line <- sp_line(c(8.770367,8.771161,8.771536),
c(50.815172,50.814743,50.814875),
runDir=tempdir())
## plot it
plot(line)
## End(Not run)
create an spatialpointobject from 1 point
Description
create an spatial point object from 1 point and optionally export it as a shapefile
Usage
sp_point(
lon,
lat,
ID = "point",
proj4 = "+proj=longlat +datum=WGS84 +no_defs",
export = FALSE,
runDir = runDir
)
Arguments
lon |
lon |
lat |
lat |
ID |
name of point |
proj4 |
projection |
export |
write shafefile default = F |
runDir |
|
Examples
## creating sp spatial point object
point <- sp_point(8.770362,50.815240,ID="Faculty of Geographie Marburg")
DEM data set of Marburg-Biedenkopf
Description
DEM data set resampled to 20 m resolution
Format
"terra::rast"
Details
DEM data set of Marburg-Biedenkopf
Source
Faculty of Geography UAV derived data from Marburg University Forest first campaign
DJI image of a survey flight
Description
DJI image of a survey flight
Format
"terra::rast"
Details
DJI image of a survey flight
Source
Faculty of Geography UAV derived data from Marburg University Forest first campaign
Flight area planning example data
Description
Flight area planning example data as typically needed for planning an autonomous survey flight task
Details
Flight area planning example data
Source
Faculty of Geography Marburg
GPX example data
Description
GPX example data as derived by a 3DR Solo flight
Details
GPX example data
Source
Faculty of Geography UAV derived data from Marburg University Forest first campaign
position example data
Description
position data for planning a single flight task with focus on known objects
Details
Virtual object position coordinates example data
Source
Faculty of Geography UAV derived data from Marburg University Forest first campaign
Flight area planning Qgroundcontrol planning file for a 100m relative to launch survey flight using a GoPro Hero4
Description
Flight area planning example data as typically needed for planning an autonomous survey flight task. The task is planned with the QGroundcontrol survey tool.
Details
Flight area planning Qgroundcontrol survey data 100 m AGL
Source
Faculty of Geography Marburg
Flight area planning Qgroundcontrol planning file for a 30m follow terrain survey flight with the DJI Air 2S
Description
Flight area planning example data as typically needed for planning an autonomous survey flight task. The task is planned with the QGroundcontrol survey tool.
Details
Flight area planning Qgroundcontrol survey data 30 m AGL
Source
Faculty of Geography Marburg
MAVLINK waypoint example data
Description
Waypoint file
Details
MAVLINK waypoint example data
Source
Faculty of Geography UAV derived data from Marburg University Forest first campaign
digitizing vector features using a simple leaflet base map
Description
vecDraw is designed for straightforward digitizing of simple geometries without adding attributes. It provides a bunch of leaflet base maps and optionally a sf* object can be loaded for orientation.
Usage
vecDraw(
mapCenter = NULL,
zoom = 15,
line = TRUE,
rectangle = TRUE,
poly = TRUE,
circle = TRUE,
point = TRUE,
remove = TRUE,
position = "topright",
maplayer = c("CartoDB.Positron", "OpenStreetMap", "Esri.WorldImagery",
"Thunderforest.Landscape", "OpenTopoMap"),
overlay = NULL,
preset = "all",
locPreset = "muf",
cex = 10,
lwd = 2,
opacity = 0.7
)
Arguments
mapCenter |
center of the leaflet map |
zoom |
set initial zoom level of leaflet map |
line |
enable/disable line tool |
rectangle |
enable/disable polygon tool |
poly |
enable/disable polygon tool |
circle |
enable/disable circle tool |
point |
enable/disable point tool |
remove |
enable/disable the remove feature of the draw tool |
position |
toolbar layout (topright, topleft, bottomright, bottomleft) |
maplayer |
string as provided by leaflet-provider |
overlay |
optional sp* object may used for orientation |
preset |
character default is "uav" for line based mission digitizing, "ext" for rectangles, NULL for all drawing items |
locPreset |
character location preset, default is "muf" for Marburg University Forest, "tra" Traddelstein, "hag" Hagenstein, "baw" Bayerwald. |
cex |
size of item |
lwd |
line width of item |
opacity |
opacity of item |
Note
Yu can either save the digitized object to a json (JS) or kml (KML) file.
Examples
## Not run:
# fully featured without overlay
require(mapview)
# preset for digitizing uav flight areas using Meuse data set as overlay
require(sp)
data(meuse)
sp::coordinates(meuse) <- ~x+y
sp::proj4string(meuse) <-CRS("+init=epsg:28992")
m <- sp::spTransform(meuse,CRSobj = sp::CRS("+init=epsg:4326"))
vecDraw(overlay = m, preset = "uav")
# preset for digitizing simple rectangles extents
vecDraw(preset="ext",overlay = m)
## End(Not run)