Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
km3mon
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
Container Registry
Model registry
Operate
Environments
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
km3py
km3mon
Commits
45b972f5
Commit
45b972f5
authored
5 years ago
by
Tamas Gal
Browse files
Options
Downloads
Patches
Plain Diff
Calibrate all DUs
parent
f5a6f34a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/ahrs_calibration.py
+46
-42
46 additions, 42 deletions
scripts/ahrs_calibration.py
with
46 additions
and
42 deletions
scripts/ahrs_calibration.py
+
46
−
42
View file @
45b972f5
...
...
@@ -44,7 +44,7 @@ class CalibrateAHRS(kp.Module):
self
.
plots_path
=
self
.
require
(
'
plots_path
'
)
det_id
=
self
.
require
(
'
det_id
'
)
self
.
detector
=
kp
.
hardware
.
Detector
(
det_id
=
det_id
)
self
.
du
=
self
.
g
et
(
'
du
'
,
default
=
1
)
self
.
du
s
=
self
.
d
et
ector
.
dus
self
.
clbmap
=
kp
.
db
.
CLBMap
(
det_oid
=
det_id
)
...
...
@@ -52,10 +52,13 @@ class CalibrateAHRS(kp.Module):
self
.
cuckoo_log
=
kp
.
time
.
Cuckoo
(
10
,
print
)
self
.
data
=
{}
queue_size
=
50000
for
ahrs_param
in
(
'
yaw
'
,
'
pitch
'
,
'
roll
'
):
self
.
data
[
ahrs_param
]
=
defaultdict
(
for
du
in
self
.
dus
:
self
.
data
[
du
]
=
{}
for
ahrs_param
in
(
'
yaw
'
,
'
pitch
'
,
'
roll
'
):
self
.
data
[
du
][
ahrs_param
]
=
defaultdict
(
partial
(
deque
,
maxlen
=
queue_size
))
self
.
data
[
du
][
'
times
'
]
=
defaultdict
(
partial
(
deque
,
maxlen
=
queue_size
))
self
.
times
=
defaultdict
(
partial
(
deque
,
maxlen
=
queue_size
))
self
.
lock
=
threading
.
Lock
()
self
.
index
=
0
...
...
@@ -71,23 +74,22 @@ class CalibrateAHRS(kp.Module):
self
.
log
.
info
(
"
Skipping base CLB
"
)
return
blob
if
clb
.
du
!=
self
.
du
:
return
blob
yaw
=
tmch_data
.
yaw
calib
=
get_latest_ahrs_calibration
(
clb
.
upi
,
max_version
=
4
)
if
calib
is
None
:
self
.
log
.
warning
(
"
No calibration found for CLB UPI
'
%s
'"
,
clb
.
upi
)
return
blob
du
=
clb
.
du
cyaw
,
cpitch
,
croll
=
fit_ahrs
(
tmch_data
.
A
,
tmch_data
.
H
,
*
calib
)
self
.
cuckoo_log
(
"
DU{}-DOM{} (random pick): calibrated yaw={}
"
.
format
(
clb
.
du
,
clb
.
floor
,
cyaw
))
with
self
.
lock
:
self
.
data
[
'
yaw
'
][
clb
.
floor
].
append
(
cyaw
)
self
.
data
[
'
pitch
'
][
clb
.
floor
].
append
(
cpitch
)
self
.
data
[
'
roll
'
][
clb
.
floor
].
append
(
croll
)
self
.
times
[
clb
.
floor
].
append
(
now
)
self
.
data
[
du
][
'
yaw
'
][
clb
.
floor
].
append
(
cyaw
)
self
.
data
[
du
][
'
pitch
'
][
clb
.
floor
].
append
(
cpitch
)
self
.
data
[
du
][
'
roll
'
][
clb
.
floor
].
append
(
croll
)
self
.
data
[
du
][
'
times
'
]
[
clb
.
floor
].
append
(
now
)
self
.
cuckoo
.
msg
()
return
blob
...
...
@@ -96,30 +98,33 @@ class CalibrateAHRS(kp.Module):
print
(
self
.
__class__
.
__name__
+
"
: updating plot.
"
)
# xfmt = md.DateFormatter('%Y-%m-%d %H:%M')
xfmt
=
md
.
DateFormatter
(
'
%H:%M
'
)
for
ahrs_param
in
self
.
data
.
keys
():
fig
,
ax
=
plt
.
subplots
(
figsize
=
(
16
,
6
))
sns
.
set_palette
(
"
husl
"
,
18
)
ax
.
set_title
(
"
AHRS {} Calibration on DU{}
\n
{}
"
.
format
(
ahrs_param
,
self
.
du
,
datetime
.
utcnow
()))
ax
.
set_xlabel
(
"
UTC time
"
)
ax
.
xaxis
.
set_major_formatter
(
xfmt
)
ax
.
set_ylabel
(
ahrs_param
)
with
self
.
lock
:
for
floor
in
sorted
(
self
.
data
[
ahrs_param
].
keys
()):
ax
.
plot
(
self
.
times
[
floor
],
self
.
data
[
ahrs_param
][
floor
],
marker
=
'
.
'
,
linestyle
=
'
none
'
,
label
=
"
Floor {}
"
.
format
(
floor
))
lgd
=
plt
.
legend
(
bbox_to_anchor
=
(
1.005
,
1
),
loc
=
2
,
borderaxespad
=
0.
)
fig
.
tight_layout
()
plt
.
savefig
(
os
.
path
.
join
(
self
.
plots_path
,
ahrs_param
+
'
_calib.png
'
),
bbox_extra_artists
=
(
lgd
,
),
bbox_inches
=
'
tight
'
)
plt
.
close
(
'
all
'
)
for
du
in
self
.
dus
:
data
=
self
.
data
[
du
]
for
ahrs_param
in
data
.
keys
():
fig
,
ax
=
plt
.
subplots
(
figsize
=
(
16
,
6
))
sns
.
set_palette
(
"
husl
"
,
18
)
ax
.
set_title
(
"
AHRS {} Calibration on DU{}
\n
{}
"
.
format
(
ahrs_param
,
du
,
datetime
.
utcnow
()))
ax
.
set_xlabel
(
"
UTC time
"
)
ax
.
xaxis
.
set_major_formatter
(
xfmt
)
ax
.
set_ylabel
(
ahrs_param
)
with
self
.
lock
:
for
floor
in
sorted
(
data
[
ahrs_param
].
keys
()):
ax
.
plot
(
data
[
'
times
'
][
floor
],
data
[
ahrs_param
][
floor
],
marker
=
'
.
'
,
linestyle
=
'
none
'
,
label
=
"
Floor {}
"
.
format
(
floor
))
lgd
=
plt
.
legend
(
bbox_to_anchor
=
(
1.005
,
1
),
loc
=
2
,
borderaxespad
=
0.
)
fig
.
tight_layout
()
plt
.
savefig
(
os
.
path
.
join
(
self
.
plots_path
,
ahrs_param
+
'
_calib_du{}.png
'
.
format
(
du
)),
bbox_extra_artists
=
(
lgd
,
),
bbox_inches
=
'
tight
'
)
plt
.
close
(
'
all
'
)
def
main
():
...
...
@@ -132,13 +137,12 @@ def main():
ligier_port
=
int
(
args
[
'
-p
'
])
pipe
=
kp
.
Pipeline
()
pipe
.
attach
(
kp
.
io
.
ch
.
CHPump
,
host
=
ligier_ip
,
port
=
ligier_port
,
tags
=
'
IO_MONIT
'
,
timeout
=
60
*
60
*
24
*
7
,
max_queue
=
2000
)
pipe
.
attach
(
kp
.
io
.
ch
.
CHPump
,
host
=
ligier_ip
,
port
=
ligier_port
,
tags
=
'
IO_MONIT
'
,
timeout
=
60
*
60
*
24
*
7
,
max_queue
=
2000
)
pipe
.
attach
(
kp
.
io
.
daq
.
DAQProcessor
)
pipe
.
attach
(
CalibrateAHRS
,
det_id
=
det_id
,
plots_path
=
plots_path
)
pipe
.
drain
()
...
...
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