Skip to content
GitLab
Explore
Sign in
Commits on Source (2)
Fixed new relative path of basestations.txt
· 644724e8
Sigurd M. Albrektsen
authored
Dec 11, 2017
644724e8
Added warning and error messages
· 51706799
Sigurd M. Albrektsen
authored
Dec 11, 2017
51706799
Show whitespace changes
Inline
Side-by-side
autortk.sh
View file @
51706799
...
...
@@ -10,18 +10,23 @@ UAV_FILE=${UAV}.ubx
EUREF_URL
=
'ftp://igs.bkg.bund.de/EUREF/obs'
# Programs:
RNX2RTKP
=
./bin/rnx2rtkp
CONVBIN
=
./bin/convbin
CRX2RNX
=
./bin/CRX2RNX
SCRIPT_DIR
=
`
dirname
$0
`
RNX2RTKP
=
${
SCRIPT_DIR
}
/bin/rnx2rtkp
CONVBIN
=
${
SCRIPT_DIR
}
/bin/convbin
CRX2RNX
=
${
SCRIPT_DIR
}
/bin/CRX2RNX
RTKLIB2AVG
=
.
/scripts/rtklib2avg.py
CLOSEST_BS
=
.
/scripts/get_closest_basestation.py
EUREF_URL_GENERATOR
=
.
/scripts/get_euref_urls.py
RTKLIB2AVG
=
${
SCRIPT_DIR
}
/scripts/rtklib2avg.py
CLOSEST_BS
=
${
SCRIPT_DIR
}
/scripts/get_closest_basestation.py
EUREF_URL_GENERATOR
=
${
SCRIPT_DIR
}
/scripts/get_euref_urls.py
# Define colors:
YELLOW
=
"
\e
[33m"
RED
=
"
\e
[31m"
DEFAULT
=
"
\e
[39m"
# Fail if any part of a pipe fails
set
-o
pipefail
# Check if we have a local base
if
[
-e
"
${
BASE
}
"
]
;
then
HAS_BASE
=
true
...
...
@@ -34,8 +39,20 @@ fi
# Convert observations to RINEX
${
CONVBIN
}
${
UAV_FILE
}
-ts
2000/01/01 00:00:00
if
[
!
$?
-eq
0
]
;
then
echo
echo
-e
"
${
RED
}
Error:
${
DEFAULT
}
Could not convert
${
UAV_FILE
}
."
;
exit
-1
;
fi
if
$HAS_BASE
;
then
${
CONVBIN
}
${
BASE_FILE
}
-ts
2000/01/01 00:00:00
if
[
!
$?
-eq
0
]
;
then
echo
echo
-e
"
${
YELLOW
}
Warning:
${
DEFAULT
}
Could not convert
${
UAV_FILE
}
."
;
echo
HAS_BASE
=
false
fi
fi
...
...
@@ -50,15 +67,31 @@ fi
# Get single position from observations
${
RNX2RTKP
}
-p
$MODE
-o
single.pos
$INPUT_FILES
if
[
!
$?
-eq
0
]
;
then
echo
echo
-e
"
${
RED
}
Error:
${
DEFAULT
}
could not analyze
${
INPUT_FILES
}
."
;
exit
-1
;
fi
# Get average single position from pos-file
llh
=
$(
${
RTKLIB2AVG
}
single.pos 5 6 |
tail
-n1
)
if
[
!
$?
-eq
0
]
;
then
echo
echo
"
${
RED
}
Error:
${
DEFAULT
}
Could not find single position."
;
exit
-1
;
fi
echo
echo
"Average single pos lat long: "
${
llh
}
echo
# Find the closest base station ID
BS
=
$(
${
CLOSEST_BS
}
${
llh
}
|
tail
-n2
)
if
[
!
$?
-eq
0
]
;
then
echo
echo
-e
"
${
RED
}
Error:
${
DEFAULT
}
Could not find basestation ID."
;
exit
-1
;
fi
echo
"Closest base station: "
${
BS
}
BSID
=
$(
echo
$BS
| rev |
cut
-f
1
-d
' '
| rev
)
echo
"ID:"
$BSID
...
...
@@ -77,6 +110,11 @@ echo "Last observation: " ${LAST_OBS}
echo
# Generate the proper URL
BS_URL
=
$(
${
EUREF_URL_GENERATOR
}
${
EUREF_URL
}
${
BSID
}
${
FIRST_OBS
}
${
LAST_OBS
}
)
if
[
!
$?
-eq
0
]
;
then
echo
echo
-e
"
${
RED
}
Error:
${
DEFAULT
}
Could not generate url."
;
exit
-1
;
fi
BS_ZIPPEDNAME
=
$(
echo
$BS_URL
|
awk
-F
'/'
'{ print $(NF) }'
)
BS_BASENAME
=
${
BS_ZIPPEDNAME
%.crx.gz
}
BS_FILENAME
=
${
BS_BASENAME
}
.rnx
...
...
@@ -88,10 +126,22 @@ if [ ! -e "$cache_dir/$BS_FILENAME" ]; then
if
[
!
-e
"
$cache_dir
/
$BS_BASENAME
.crx"
]
;
then
if
[
!
-e
"
$cache_dir
/
$BS_ZIPPEDNAME
"
]
;
then
wget
$BS_URL
-P
$cache_dir
if
[
!
$?
-eq
0
]
;
then
echo
-e
"
${
RED
}
Error:
${
DEFAULT
}
Could not download '
$BS_URL
' to '
$cache_dir
'."
;
exit
-1
;
fi
fi
gunzip
-f
$cache_dir
/
$BS_ZIPPEDNAME
if
[
!
$?
-eq
0
]
;
then
echo
-e
"
${
YELLOW
}
Warning:
${
DEFAULT
}
Could not unzip '
$cache_dir
/
$BS_ZIPPEDNAME
'."
;
fi
fi
${
CRX2RNX
}
$cache_dir
/
$BS_BASENAME
.crx
if
[
!
$?
-eq
0
]
;
then
echo
-e
"
${
RED
}
Error:
${
DEFAULT
}
Could not convert '
$cache_dir
/
$BS_BASENAME
.crx'."
;
exit
-1
;
fi
fi
# Calculate UAV position from basestation if we do not have local base
...
...
@@ -101,6 +151,10 @@ if [ $HAS_BASE == false ]; then
BASE_STATION_FILES
=
"
$cache_dir
/
$BS_FILENAME
"
OPTIONS
=
"-c -s | -d 5"
${
RNX2RTKP
}
-o
$UAV
.pos
-p
${
MODE
}
$OPTIONS
$INPUT_FILES
$BASE_STATION_FILES
if
[
!
$?
-eq
0
]
;
then
echo
-e
"
${
RED
}
Error:
${
DEFAULT
}
RTK analysis failed"
;
exit
-1
;
fi
echo
echo
"Done."
exit
0
...
...
scripts/get_closest_basestation.py
View file @
51706799
...
...
@@ -82,7 +82,8 @@ if __name__ == '__main__':
print
(
'
%s lat lon [alt [basestations.txt]]
'
%
sys
.
argv
[
0
])
sys
.
exit
(
-
1
)
basestations_fname
=
'
basestations.txt
'
SCRIPT_DIR
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
basestations_fname
=
os
.
path
.
join
(
SCRIPT_DIR
,
'
../basestations.txt
'
)
if
len
(
sys
.
argv
)
>
4
:
basestations_fname
=
sys
.
argv
[
4
]
...
...