Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
inference
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
optima
inference
Commits
954fea9a
Commit
954fea9a
authored
4 years ago
by
Daalen, Tim van
Browse files
Options
Downloads
Patches
Plain Diff
gps moving test
parent
fda87b6b
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
GPS_receiver.py
+5
-3
5 additions, 3 deletions
GPS_receiver.py
camera.py
+2
-1
2 additions, 1 deletion
camera.py
cfg/detection.yaml
+1
-1
1 addition, 1 deletion
cfg/detection.yaml
data_types.py
+30
-14
30 additions, 14 deletions
data_types.py
with
38 additions
and
19 deletions
GPS_receiver.py
+
5
−
3
View file @
954fea9a
...
...
@@ -38,14 +38,16 @@ class TCPReceiver(socketserver.StreamRequestHandler):
#start TCP server which receives the messages from the RUTX11
def
start_GPSthread
(
CONFIG
):
global
TCPServerInstance
,
GPS_Ringbuffer
GPS_ringbuf
.
set_min_frame_movement
(
CONFIG
[
'
min-movement-
fram
e
'
])
GPS_ringbuf
.
set_min_frame_movement
(
CONFIG
[
'
min-movement-
puls
e
'
])
GPS_poort
=
8500
#port to which the TCP nmea string is send
for
_
in
range
(
0
,
5
):
ip_address
=
get_ip_address
()
if
ip_address
!=
None
:
break
if
ip_address
!=
None
:
break
sleep
(
1
)
if
ip_address
==
None
:
raise
Exception
(
"
Router not connected, shutting down!
"
)
sleep
(
1
)
ServerAddress
=
(
ip_address
,
GPS_poort
)
TCPServerInstance
=
socketserver
.
ThreadingTCPServer
(
ServerAddress
,
TCPReceiver
)
threading
.
Thread
(
target
=
TCPServerInstance
.
serve_forever
).
start
()
...
...
This diff is collapsed.
Click to expand it.
camera.py
+
2
−
1
View file @
954fea9a
...
...
@@ -5,6 +5,7 @@ from threading import Thread
from
pypylon
import
pylon
#camera
from
itertools
import
cycle
from
glob
import
glob
from
sys
import
maxsize
from
global_vars
import
*
from
usb_Filestorage
import
*
...
...
@@ -50,7 +51,7 @@ class take_img(Thread):
#only process images when we are moving & the GPS buffer is filled
if
(
self
.
GPS_check
==
False
)
or
(
is_moving
==
True
):
if
(
self
.
GPS_check
==
False
)
or
((
data_obj
.
lat
>=
0
)
and
(
data_obj
.
lng
>=
0
)):
if
(
self
.
GPS_check
==
False
)
or
((
data_obj
.
lat
<
maxsize
)
and
(
data_obj
.
lng
<
maxsize
)):
#send image to neural network
to_process_deque
.
append
({
'
file_name
'
:
filename
,
'
img
'
:
img
,
'
data
'
:
data_obj
})
if
self
.
save_IMGS
==
True
:
...
...
This diff is collapsed.
Click to expand it.
cfg/detection.yaml
+
1
−
1
View file @
954fea9a
...
...
@@ -18,7 +18,7 @@ AGENSO: True
save-GPS
:
True
save-IMGS
:
True
save-every-x
:
10
#dont save all imgs & GPS coordinates, its simply to much
min-movement-
fram
e
:
0.
1
#M between GPS pulses (1 puls/2
min
)
min-movement-
puls
e
:
0.
6
#M between GPS pulses (1 puls/2
seconds, 0.6 = 0.3 m/s and 1 km/h
)
GPS-checks
:
True
#enable/disable GPS moving checks to facilitate desk debugging
#AGENSO
...
...
This diff is collapsed.
Click to expand it.
data_types.py
+
30
−
14
View file @
954fea9a
import
json
from
datetime
import
datetime
from
types
import
SimpleNamespace
as
Namespace
from
sys
import
maxsize
#https://medium.com/@yzhong.cs/serialize-and-deserialize-complex-json-in-python-205ecc636caa
...
...
@@ -19,8 +19,8 @@ class data_class():#lat, lng, hdop, satnum, gps_quality, timestamp
def
__init__
(
self
):
self
.
timestamp
=
"
0-0-0T0:0:0
"
self
.
gps_quality
=
"
Not valid
"
#values: Not valid, Fixed, Diff fix, RTK, RTK F
self
.
lat
=
-
1
self
.
lng
=
-
1
self
.
lat
=
maxsize
self
.
lng
=
maxsize
self
.
hdop
=
0
self
.
satnum
=
0
self
.
diseases
=
[]
...
...
@@ -99,8 +99,8 @@ class GPS_Ringbuffer:
self
.
min_movement
=
0
#minimal movement over the entire buffer.
self
.
decdegr_to_m
=
0.00001
#very rough conversion from DD to M
self
.
size
=
size
self
.
prevlat
=
0
self
.
prevlng
=
0
self
.
prevlat
=
maxsize
self
.
prevlng
=
maxsize
self
.
prevtimestamp
=
datetime
.
utcnow
()
#.strftime("%y-%m-%dT%H:%M:%S.%f")
self
.
data
=
[]
self
.
f_pnt
=
0
#inital poisition
...
...
@@ -113,9 +113,9 @@ class GPS_Ringbuffer:
def
update_pointer
(
self
,
pointer
):
return
(
pointer
+
1
)
%
self
.
size
def
set_min_frame_movement
(
self
,
min_movement_
fram
e
):
self
.
min_movement
=
min_movement_
fram
e
*
self
.
decdegr_to_m
*
self
.
size
self
.
min_movement_frame
=
min_movement_
fram
e
*
self
.
decdegr_to_m
def
set_min_frame_movement
(
self
,
min_movement_
puls
e
):
self
.
min_movement
=
min_movement_
puls
e
*
self
.
decdegr_to_m
*
self
.
size
self
.
min_movement_frame
=
min_movement_
puls
e
*
self
.
decdegr_to_m
#put new value in the rinngbuffer en update the values
def
put
(
self
,
nmea_GGA_msg
,
timestamp
):
...
...
@@ -136,7 +136,7 @@ class GPS_Ringbuffer:
self
.
data
[
self
.
f_pnt
].
gpsquality
=
nmea_GGA_msg
.
gps_qual
self
.
data
[
self
.
f_pnt
].
gpstime
=
nmea_GGA_msg
.
timestamp
.
strftime
(
"
%y-%m-%dT%H:%M:%S.%f
"
)
self
.
data
[
self
.
f_pnt
].
rectime
=
timestamp
.
strftime
(
"
%y-%m-%dT%H:%M:%S.%f
"
)
self
.
data
[
self
.
f_pnt
].
moving
=
self
.
determine_hasmoved
()
self
.
data
[
self
.
f_pnt
].
moving
=
self
.
determine_hasmoved
_fast
()
#print('prev_lat: %f, lat: %f, diff: %f' %(self.prevlat, lat, self.data[self.f_pnt].latdif))
#print('prev_lng: %f, lng: %f, diff: %f' %(self.prevlng, lng, self.data[self.f_pnt].lngdif))
self
.
prevtimestamp
=
timestamp
...
...
@@ -174,7 +174,7 @@ class GPS_Ringbuffer:
for
pos
in
self
.
data
:
total_latdiff
+=
pos
.
latdif
total_lngdiff
+=
pos
.
lngdif
total_movement
=
total_latdiff
+
total_lngdiff
total_movement
=
abs
(
total_latdiff
+
total_lngdiff
)
if
(
total_movement
>
self
.
min_movement
):
return
True
else
:
...
...
@@ -187,7 +187,7 @@ class GPS_Ringbuffer:
lat_movement
=
abs
(
itemone
.
lat
-
itemtwo
.
lat
)
lng_movement
=
abs
(
itemone
.
lng
-
itemtwo
.
lng
)
total_movement
=
lat_movement
+
lng_movement
total_movement
=
abs
(
lat_movement
+
lng_movement
)
if
(
total_movement
>
self
.
min_movement
):
return
True
else
:
...
...
@@ -220,9 +220,25 @@ class GPS_Ringbuffer:
#fake nmea class, used to initialise the RING buffer
class
fake_nmea_class
:
def
__init__
(
self
,
prevtimestamp
):
self
.
latitude
=
-
1
self
.
longitude
=
-
1
self
.
latitude
=
maxsize
self
.
longitude
=
maxsize
self
.
horizontal_dil
=
0
self
.
num_sats
=
0
self
.
gps_qual
=
0
self
.
timestamp
=
prevtimestamp
\ No newline at end of file
self
.
timestamp
=
prevtimestamp
if
__name__
==
'
__main__
'
:
fnc
=
fake_nmea_class
(
datetime
.
now
())
gps_test
=
GPS_Ringbuffer
(
5
)
gps_test
.
set_min_frame_movement
(
0.1
)
lat_init
=
52.64538985
lon_init
=
5.667874878
for
i
in
range
(
6
):
fnc
.
latitude
=
lat_init
+
(
i
*
1e-6
)
fnc
.
longitude
=
lon_init
+
(
i
*
1e-6
)
gps_test
.
put
(
fnc
,
datetime
.
now
())
(
obj
,
is_moving
)
=
gps_test
.
get_dataobject
(
datetime
.
now
())
print
(
is_moving
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment