Commit 527a72b0 authored by luroth's avatar luroth
Browse files

waypoint update error fix

parent 300c0123
This diff is collapsed.
This diff is collapsed.
###
# PhenoFly Planning Tool
# Copyright (C) 2018 ETH Zürich, Lukas Roth (lukas.roth@usys.ethz.ch)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
###
library(shiny)
source("./ui.R")
source("./sergver.R")
source("./server.R")
ui <- ui_
......
###
# PhenoFly Planning Tool
# Copyright (C) 2018 ETH Zürich, Lukas Roth (lukas.roth@usys.ethz.ch)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
###
calc_angle_of_view <- function(d_sensor, f) {
angle_of_view <- 2 * atan(d_sensor / (2 * f))
return(angle_of_view)
......@@ -48,9 +67,14 @@ calc_depth_of_field_far <- function(f, aperture, circle_of_confusion, focus_dist
return(ifelse(focus_distance <= hyperfocal_distance, (focus_distance / ( (f - focus_distance) / (hyperfocal_distance - f) + 1)), Inf))
}
#calc_shutter_speed <- function(exposure_value, aperture, iso=100) {
# return(as.numeric(iso)/(25.0 * 2.0^(2.0+as.numeric(exposure_value))/(as.numeric(aperture)^2.0)))
#}
calc_shutter_speed <- function(exposure_value, aperture, iso=100) {
return(as.numeric(iso)/(25.0 * 2.0^(2.0+as.numeric(exposure_value))/(as.numeric(aperture)^2.0)))
return( (25.0 * aperture^2.0 * 2.0^(2-exposure_value) ) / iso )
}
calc_iso <- function(exposure_value, aperture, shutter_speed) {
......
[
{
"name": "Sony Alpha 9 on DJI Matrice 600 Pro",
"sensor_values": {
"d_sensor_x": 35.6,
"d_sensor_y": 23.8,
"n_pix_x": 6000,
"n_pix_y": 4000,
"default_lens_aperture": 8,
"focal_lenght": 55,
"t_max": 32000,
"ISO_max": 6400,
"freq_max": 2,
"flight_max": 15
}
},
{
"name": "Sony RX100 II on Mikrokopter Quadro",
"sensor_values": {
"d_sensor_x": 13.2,
"d_sensor_y": 8.8,
"n_pix_x": 5472,
"n_pix_y": 3648,
"default_lens_aperture": 4,
"focal_lenght": 10.4,
"t_max": 2000,
"ISO_max": 12800,
"freq_max": 0.5,
"flight_max": 8
}
},
{
"name": "DJI Phantom 4 Pro",
"sensor_values": {
"d_sensor_x": 6.2,
"d_sensor_y": 4.65,
"n_pix_x": 4000,
"n_pix_y": 3000,
"default_lens_aperture": 2.8,
"focal_lenght": 3.6125,
"t_max": 8000,
"ISO_max": 3200,
"freq_max": 1,
"flight_max": 25
}
},
{
"name": "Parrot Sequoia monochrome (4 bands) on DJI P4P",
"sensor_values": {
"d_sensor_x": 4.8,
"d_sensor_y": 3.6,
"n_pix_x": 1280,
"n_pix_y": 960,
"default_lens_aperture": 2.2,
"focal_lenght": 3.98,
"t_max": 5000,
"ISO_max": 800,
"freq_max": 1,
"flight_max": 25
}
},
{
"name": "Parrot Sequoia RGB on DJI P4P",
"sensor_values": {
"d_sensor_x": 6.17472,
"d_sensor_y": 4.63104,
"n_pix_x": 4608,
"n_pix_y": 3456,
"default_lens_aperture": 2.2,
"focal_lenght": 4.88,
"t_max": 5000,
"ISO_max": 800,
"freq_max": 1,
"flight_max": 25
}
}
]
\ No newline at end of file
###
# PhenoFly Planning Tool
# Copyright (C) 2018 ETH Zürich, Lukas Roth (lukas.roth@usys.ethz.ch)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
###
library(ggplot2)
library(gridExtra)
library(RJSONIO)
......@@ -84,7 +103,7 @@ validate_inputs <- function(input) {
}
#Allowed shutter speeds
shutter_speed_values <- list("1/250"=250, "1/500"=500, "1/640" = 640, "1/800" = 800, "1/1000" = 1000, "1/1600" = 1600, "1/2000" = 2000, "1/2500" = 2500, "1/4000" = 4000, "1/6400" = 6400, "1/8000" = 8000, "1/12000" = 12000, "1/16000" = 16000, "1/32000" = 32000, "1/64000" = 64000)
shutter_speed_values <- list("1"=1, "1/10"=10, "1/50"=50, "1/125"=125, "1/250"=250, "1/500"=500, "1/640" = 640, "1/800" = 800, "1/1000" = 1000, "1/1600" = 1600, "1/2000" = 2000, "1/2500" = 2500, "1/4000" = 4000, "1/6400" = 6400, "1/8000" = 8000, "1/12000" = 12000, "1/16000" = 16000, "1/32000" = 32000, "1/64000" = 64000)
# Debouncing factor
default_debounce <- 500
......@@ -114,7 +133,7 @@ server_ <- function(input, output, session) {
# Shutter speed max (update select input max value)
observe({
req(isTruthy(input$t_max))
updateSelectInput(session, "shutter_speed", choices = shutter_speed_values[as.numeric(shutter_speed_values)<=input$t_max], selected = 8000 )
updateSelectizeInput(session, "shutter_speed", choices = shutter_speed_values[as.numeric(shutter_speed_values)<=input$t_max], selected=1000)
})
# Focal lenght (debounced)
......@@ -226,16 +245,17 @@ server_ <- function(input, output, session) {
# calc ISO
iso <- signif(calc_iso(input$exposure_value, derived_values$aperture, shutter_speed), 4)
if(iso >= input$ISO_max) {
showNotification(paste0("The calculated ISO value (", iso, ") is higher than the maximum allowed ISO value (", input$ISO_max, "). The shutter speed was recalculated."))
iso <- input$ISO_max
shutter_speed <- calc_shutter_speed(input$exposure_value, derived_values$aperture, input$ISO_max)
shutter_speed_real <- as.numeric(shutter_speed_values[which.min(abs(1/as.numeric(shutter_speed_values) - 1/shutter_speed))])
if(shutter_speed_real > shutter_speed) {
shutter_speed_real <- as.numeric(shutter_speed_values[which.min(abs(1/as.numeric(shutter_speed_values) - 1/shutter_speed)) - 1])
shutter_speed_real <- as.numeric(shutter_speed_values[which.min(abs(1.0/as.numeric(shutter_speed_values) - shutter_speed))])
if((1.0/shutter_speed_real) > shutter_speed) {
shutter_speed_real <- as.numeric(shutter_speed_values[which.min(abs(1.0/as.numeric(shutter_speed_values) - shutter_speed)) - 1])
}
updateTextInput(session, "shutter_speed", value = shutter_speed_real)
showNotification(paste0("The calculated ISO value (", iso, ") is higher than the maximum allowed ISO value (", input$ISO_max, "). The shutter speed was reset to ", shutter_speed_real))
updateSelectizeInput(session, "shutter_speed", selected = shutter_speed_real)
updateTextInput(session, "iso", value = iso)
derived_values$shutter_speed <- shutter_speed
derived_values$shutter_speed <- shutter_speed_real
} else {
derived_values$iso <- iso
derived_values$shutter_speed <- shutter_speed
......@@ -624,7 +644,7 @@ server_ <- function(input, output, session) {
waypoints <- reactive({
req(input$position_edge1_long, input$position_edge1_lat, input$position_edge2_long, input$position_edge2_lat,
derived_values$field_of_view_x>0, derived_values$field_of_view_y>0, derived_values$side_lap>0, derived_values$spacing_between_flight_lines>0,
input$position_start_lat, input$position_start_long, input$mapping_area_x>0, input$mapping_area_y>0, derived_values$flight_speed>0)
input$position_start_lat, input$position_start_long, input$mapping_area_x>0, input$mapping_area_y>0, derived_values$flight_speed>0, input$max_number_of_wp>0)
# Convert to cartesian system
UTM_zone <- long2UTM(input$position_edge1_long)
......@@ -651,7 +671,14 @@ server_ <- function(input, output, session) {
overlap_meters = derived_values$field_of_view_y / 2.0
number_of_lines = ceiling(input$mapping_area_x / derived_values$spacing_between_flight_lines) + 2 * overlap_lines + 1
intermediate_points <- floor((98 - (number_of_lines*2)) / number_of_lines)
if(number_of_lines > floor(input$max_number_of_wp / 2.0)) {
showNotification(id="error_lines", paste0("Number of flight lines x2 exceeds maximum number of waypoints. No waypoint generation possible."), closeButton = TRUE, type = "error", duration = NULL)
} else {
removeNotification(id="error_lines")
}
intermediate_points <- floor((input$max_number_of_wp - 1 - (number_of_lines*2)) / number_of_lines)
# Lists for waypoint coordinates
waypoints = data.frame(Y=input$position_start_lat, X=input$position_start_long)
......@@ -1069,6 +1096,12 @@ server_ <- function(input, output, session) {
session$sendInputMessage(name, list(value=value))
}
}
shutter_speed <- as.numeric(shutter_speed_values[which.min(abs(1.0/as.numeric(shutter_speed_values) - 1.0/settings$derived[['shutter_speed']]))])
print(shutter_speed)
updateSelectizeInput(session, "shutter_speed", choices = shutter_speed_values[as.numeric(shutter_speed_values)<=input$t_max], selected=shutter_speed)
derived_values$shutter_speed <- shutter_speed
showNotification("New settings loaded", type="warning")
})
......
###
# PhenoFly Planning Tool
# Copyright (C) 2018 ETH Zürich, Lukas Roth (lukas.roth@usys.ethz.ch)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
###
library(shinycssloaders)
library(leaflet)
......@@ -28,6 +47,7 @@ default_t_max<- 32000
default_ISO_max<- 6400
default_freq_max<- 2
default_flight_max<- 15
default_max_number_of_wp <- 99
default_position_edge1_lat <- 47.450812627526901
default_position_edge1_long <- 8.682496912397921
......@@ -55,20 +75,20 @@ ui_ <- fluidPage(
column(12, textInput("sensor_and_lens_select", label=NA, value= default_sensor_name))
),
fluidRow(
column(6, numericInput("d_sensor_x", "Sensor size, width (mm)", width = "100%", value=default_d_sensor_x, step=0.1)),
column(6, numericInput("d_sensor_y", "Sensor size, height (mm)", width = "100%", value=default_d_sensor_y, step=0.1))
column(6, numericInput("d_sensor_x", "Sensor size, x (mm)", width = "100%", value=default_d_sensor_x, step=0.1)),
column(6, numericInput("d_sensor_y", "Sensor size, y (mm)", width = "100%", value=default_d_sensor_y, step=0.1))
),
fluidRow(
column(6, numericInput("n_pix_x", "Number of recorded pixels in x (px)", width = "100%", value=default_n_pix_x, step=1)),
column(6, numericInput("n_pix_y", "Number of recorded pixels in y (px)", width = "100%", value=default_n_pix_y, step=1))
column(6, numericInput("n_pix_x", "Number of recorded pixels, x (px)", width = "100%", value=default_n_pix_x, step=1)),
column(6, numericInput("n_pix_y", "Number of recorded pixels, y (px)", width = "100%", value=default_n_pix_y, step=1))
),
fluidRow(
column(6, numericInput("t_max", "Max. shutter speed (1/s)", width = "100%", value=default_t_max, step=1000)),
column(6, numericInput("ISO_max", "Max. film speed (ISO)", width = "100%", value=default_ISO_max, step=1000))
),
fluidRow(
column(6, numericInput("freq_max", "Max. recording freqency (1/s)", width = "100%", value=default_freq_max)),
column(6, numericInput("flight_max", "Max. flight time (min)", width = "100%", value=default_flight_max))
column(6, numericInput("freq_max", "Max. image trigger frequency (1/s)", width = "100%", value=default_freq_max)),
column(6, numericInput("flight_max", "Max. flight duration (min)", width = "100%", value=default_flight_max))
),
htmlOutput("d_pix_output"),
hr(),
......@@ -83,7 +103,7 @@ ui_ <- fluidPage(
h4("Resolution"),
sliderInput("flight_height", "Flight height (m)", width = "100%", value = default_flight_height, min=2, max=150),
fluidRow(
column(9, numericInput("ground_sampling_distance", "Ground sampling distance nadir (mm)", width = "100%", value=NA, step=0.1)),
column(9, numericInput("ground_sampling_distance", "Ground sampling distance (mm)", width = "100%", value=NA, step=0.1)),
column(3, checkboxInput("edit_ground_sampling_distance", "Edit"), style = "margin-top: 25px;")
),
hr(),
......@@ -91,7 +111,7 @@ ui_ <- fluidPage(
sliderInput("exposure_value", "Exposure value (EV)", min = 1, max = 21, step = 1, value = default_exposure_value),
hr(),
fluidRow(
column(6, selectInput("shutter_speed", "Shutter speed (s)", selected = default_shutter_speed, choices = default_shutter_speed, width = "100%")),
column(6, selectizeInput("shutter_speed", "Shutter speed (s)", selected = default_shutter_speed, choices = default_shutter_speed, width = "100%")),
column(6, numericInput("iso", "Film speed (ISO)", width = "100%", value = default_iso))
)
......@@ -100,12 +120,12 @@ ui_ <- fluidPage(
tabPanel("Mapping",
h4("Mapping area"),
fluidRow(
column(6, numericInput("mapping_area_x", "Mapping area width (m)", width = "100%", value = default_mapping_area_x, step=1)),
column(6, numericInput("mapping_area_y","Mapping area depth (m)", width = "100%", value = default_mapping_area_y, step=1))
column(6, numericInput("mapping_area_x", "Mapping area, width (m)", width = "100%", value = default_mapping_area_x, step=1)),
column(6, numericInput("mapping_area_y","Mapping area, depth (m)", width = "100%", value = default_mapping_area_y, step=1))
),
fluidRow(
column(6, numericInput("plot_size_x", "Plot size width (m)", width = "100%", value = default_plot_size_x, step=0.1)),
column(6, numericInput("plot_size_y","Plot size depth (m)", width = "100%", value = default_plot_size_y, step=0.1))
column(6, numericInput("plot_size_x", "Plot size, width (m)", width = "100%", value = default_plot_size_x, step=0.1)),
column(6, numericInput("plot_size_y","Plot size, depth (m)", width = "100%", value = default_plot_size_y, step=0.1))
),
hr(),
h4("Flight path"),
......@@ -122,14 +142,14 @@ ui_ <- fluidPage(
column(6,radioButtons("flip_camera", "Camera heading", choiceNames=c("Narrow side in flight direction", "Wide side in flight direction"), choiceValues = c(FALSE, TRUE), selected = default_flip_camera)),
column(6, numericInput("positioning_precision", "Positioning precision (m)", width = "100%", value = default_position_precision))
),
sliderInput("motion_blur", "Maximal motion blur (px)", min = 0.01, max = 5, step = 0.01, value = default_max_motion_blur, width = "100%")
sliderInput("motion_blur", "Max. motion blur (px)", min = 0.01, max = 5, step = 0.01, value = default_max_motion_blur, width = "100%")
),
tabPanel("GCPs",
h4("Arrangement"),
fluidRow(
column(6, numericInput("gcp_n_in_x", "Number of GCP along mapping area width", width = "100%", value = default_no_gcp_x, step=1)),
column(6, numericInput("gcp_n_in_y", "Number of GCP along mapping area depth", width = "100%", value = default_no_gcp_y, step=1))
column(6, numericInput("gcp_n_in_x", "Number of GCPs, width", width = "100%", value = default_no_gcp_x, step=1)),
column(6, numericInput("gcp_n_in_y", "Number of GCPs, depth", width = "100%", value = default_no_gcp_y, step=1))
),
radioButtons(inline=TRUE, "gcp_arrangement_pattern", "Arrangement pattern",
choiceNames = list(
......@@ -147,27 +167,32 @@ ui_ <- fluidPage(
tabPanel("Location",
h4("Mapping area"),
fluidRow(
column(6,numericInput("position_edge1_lat", "Field edge (Latitude)", width = "100%", value = default_position_edge1_lat)),
column(6, numericInput("position_edge1_long","Field edge (Longitude)", width = "100%", value = default_position_edge1_long))
column(6,numericInput("position_edge1_lat", "Mapping area edge (Latitude)", width = "100%", value = default_position_edge1_lat)),
column(6, numericInput("position_edge1_long","Mapping area edge (Longitude)", width = "100%", value = default_position_edge1_long))
),
fluidRow(
column(6,numericInput("position_edge2_lat", "Flight direction (Latitude)", width = "100%", value = default_position_edge2_lat)),
column(6, numericInput("position_edge2_long","Flight direction (Longitude)", width = "100%", value = default_position_edge2_long))
),
hr(),
fluidRow(
column(6,numericInput("position_start_lat", "Starting point (Latitude)", width = "100%", value = default_starting_point_lat)),
column(6, numericInput("position_start_long","Starting point (Longitude)", width = "100%", value = default_starting_point_long))
)
column(6,numericInput("position_start_lat", "Start location (Latitude)", width = "100%", value = default_starting_point_lat)),
column(6, numericInput("position_start_long","Start location (Longitude)", width = "100%", value = default_starting_point_long))
),
hr(),
numericInput("max_number_of_wp", "Maximum number of waypoints", width = "100%", value = default_max_number_of_wp)
)
),
hr(),
img(src="ETHLogo_black_20.png"),
div(HTML("<br />Group of crop science<br />Lukas Roth (lukas.roth@usys.ethz.ch)<br />(c) 2018"))
),
div(
HTML("<br />Group of crop science ("),
tags$a("http://www.kp.ethz.ch", href="http://www.kp.ethz.ch/infrastructure/uav-phenofly.html", target="_blank"),
HTML(")"),
HTML("<br />Lukas Roth ( lukas.roth@usys.ethz.ch )<br />"),
HTML("(c) 2018 - "), tags$a("GPL-3.0", href="https://www.gnu.org/licenses", target="_blank")
)),
mainPanel(
tabsetPanel(id="results",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment