Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
On-Board Software
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
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Avionics
Software Development
On-Board Software
Commits
7e8b1f0b
Commit
7e8b1f0b
authored
3 years ago
by
Luca Conterio
Browse files
Options
Downloads
Patches
Plain Diff
[scripts] airbrakes trajectory script now discards negative altitude points, if present
parent
22e32241
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/airbrakes/trajectories.py
+41
-14
41 additions, 14 deletions
scripts/airbrakes/trajectories.py
with
41 additions
and
14 deletions
scripts/airbrakes/trajectories.py
+
41
−
14
View file @
7e8b1f0b
...
...
@@ -2,35 +2,62 @@ import scipy.io as sio
import
sys
#filename = "Trajectories.mat"
outfilename
=
"
Trajectories
_data
.h
"
outfilename
=
"
Trajectories.h
"
fieldname
=
"
trajectories_saving
"
if
len
(
sys
.
argv
)
<
2
:
print
(
"
\n
Error, missing path to file
"
)
print
(
"
Usage : python3 coeffs.py <path_to_mat_file>
\n
"
)
outfilename
=
sys
.
argv
[
1
].
replace
(
"
.mat
"
,
""
)
+
"
.h
"
# use same name as input file
mat
=
sio
.
loadmat
(
sys
.
argv
[
1
])
trajectories
=
mat
[
fieldname
][
0
]
with
open
(
outfilename
,
"
w
"
)
as
f
:
num_trajectories
=
len
(
trajectories
)
max_trajectory_len
=
0
for
t
in
trajectories
:
# check length of first column for each trajectory
if
len
(
t
[
0
])
>
max_trajectory_len
:
max_trajectory_len
=
len
(
t
[
0
])
f
.
write
(
"
static const unsigned int TOT_TRAJECTORIES =
"
+
str
(
num_trajectories
)
+
"
;
\n
"
)
f
.
write
(
"
static const unsigned int TRAJECTORY_MAX_LENGTH =
"
+
str
(
max_trajectory_len
)
+
"
;
\n\n
"
)
trajectory_index
=
0
output_string
=
""
f
.
write
(
"
const trajectory_t TRAJECTORIES_DATA[TOT_TRAJECTORIES] = {
\n
"
)
for
trajectory
in
trajectories
:
zs
,
vzs
,
xs
,
vxs
,
ys
,
vys
=
trajectory
f
.
write
(
"
\t
{
\n
"
)
f
.
write
(
"
\t\t
%d,
\n\t\t
{
\n
"
%
(
len
(
zs
)))
for
i
in
range
(
0
,
len
(
zs
)):
if
zs
[
i
]
>=
0
:
# find first non negative altitude
break
# exctract only non negative altitude elements
zs
=
zs
[
i
:]
vzs
=
vzs
[
i
:]
if
(
len
(
zs
)
!=
len
(
vzs
)):
print
(
"
ERROR : z and vz don
'
t have the same number of elements in trajectory
"
+
str
(
trajectory_index
))
# check length of first column for each trajectory
if
len
(
zs
)
>
max_trajectory_len
:
max_trajectory_len
=
len
(
zs
)
# output trajectory to file
output_string
+=
"
\t
{
\n
"
output_string
+=
"
\t\t
%d,
\n\t\t
{
\n
"
%
(
len
(
zs
))
for
z
,
vz
in
zip
(
zs
,
vzs
):
f
.
write
(
"
\t\t\t
{%f, %f},
\n
"
%
(
z
,
vz
))
f
.
write
(
"
\t\t
}
\n\t
},
\n
"
)
f
.
write
(
"
};
"
)
output_string
+=
"
\t\t\t
{%f, %f},
\n
"
%
(
z
,
vz
)
output_string
+=
"
\t\t
}
\n\t
},
\n
"
trajectory_index
+=
1
output_string
+=
"
};
"
# after the preprocessing, output max trajectories length
s
=
"
static const unsigned int TOT_TRAJECTORIES =
"
+
str
(
num_trajectories
)
+
"
;
\n
"
s
+=
"
static const unsigned int TRAJECTORY_MAX_LENGTH =
"
+
str
(
max_trajectory_len
)
+
"
;
\n\n
"
s
+=
"
const trajectory_t TRAJECTORIES_DATA[TOT_TRAJECTORIES] = {
\n
"
# final string to be output to file
output_string
=
s
+
output_string
f
.
write
(
output_string
)
print
(
"
\n
File
"
+
outfilename
+
"
written
"
)
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