Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
flight-scripts
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
flight-scripts
Commits
08d37fad
Commit
08d37fad
authored
Mar 02, 2023
by
Léo-Paul Géneau
👾
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add simulator default script
parent
7568df53
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
111 additions
and
0 deletions
+111
-0
simulator-script.js
simulator-script.js
+111
-0
No files found.
simulator-script.js
0 → 100644
View file @
08d37fad
/*jslint nomen: true, indent: 2, maxerr: 3, maxlen: 80 */
/*global console, me*/
(
function
(
console
,
me
)
{
"
use strict
"
;
var
ALTITUDE
=
100
,
EPSILON
=
9
,
CHECKPOINT_LIST
=
[
{
altitude
:
585.1806861589965
,
latitude
:
45.64492790560583
,
longitude
:
14.25334942966329
},
{
altitude
:
589.8802607573035
,
latitude
:
45.64316335436476
,
longitude
:
14.26332880184475
},
{
altitude
:
608.6648153348965
,
latitude
:
45.64911917196595
,
longitude
:
14.26214792790128
},
{
altitude
:
606.1448368129072
,
latitude
:
45.64122685351364
,
longitude
:
14.26590493128597
},
{
altitude
:
630.0829598206344
,
latitude
:
45.64543355564817
,
longitude
:
14.27242391207985
},
{
altitude
:
616.1839898415284
,
latitude
:
45.6372792927328
,
longitude
:
14.27533492411138
},
{
altitude
:
598.0603137354178
,
latitude
:
45.64061299543953
,
longitude
:
14.26161958465814
},
{
altitude
:
607.1243119862851
,
latitude
:
45.64032340702919
,
longitude
:
14.2682896662383
}
];
function
distance
(
lat1
,
lon1
,
lat2
,
lon2
)
{
var
R
=
6371
e3
,
// meters
la1
=
lat1
*
Math
.
PI
/
180
,
// lat, lon in radians
la2
=
lat2
*
Math
.
PI
/
180
,
lo1
=
lon1
*
Math
.
PI
/
180
,
lo2
=
lon2
*
Math
.
PI
/
180
,
haversine_phi
=
Math
.
pow
(
Math
.
sin
((
la2
-
la1
)
/
2
),
2
),
sin_lon
=
Math
.
sin
((
lo2
-
lo1
)
/
2
),
h
=
haversine_phi
+
Math
.
cos
(
la1
)
*
Math
.
cos
(
la2
)
*
sin_lon
*
sin_lon
;
return
2
*
R
*
Math
.
asin
(
Math
.
sqrt
(
h
));
}
me
.
onStart
=
function
()
{
me
.
direction_set
=
false
;
me
.
next_checkpoint
=
0
;
me
.
parachute_triggered
=
false
;
};
me
.
onUpdate
=
function
(
timestamp
)
{
if
(
!
me
.
direction_set
)
{
if
(
me
.
next_checkpoint
<
CHECKPOINT_LIST
.
length
)
{
me
.
setTargetCoordinates
(
CHECKPOINT_LIST
[
me
.
next_checkpoint
].
latitude
,
CHECKPOINT_LIST
[
me
.
next_checkpoint
].
longitude
,
CHECKPOINT_LIST
[
me
.
next_checkpoint
].
altitude
+
ALTITUDE
+
ALTITUDE
*
me
.
id
);
console
.
log
(
"
[DEMO] Going to Checkpoint %d
"
,
me
.
next_checkpoint
);
}
me
.
direction_set
=
true
;
return
;
}
if
(
me
.
next_checkpoint
<
CHECKPOINT_LIST
.
length
)
{
me
.
current_position
=
me
.
getCurrentPosition
();
me
.
distance
=
distance
(
me
.
current_position
.
x
,
me
.
current_position
.
y
,
CHECKPOINT_LIST
[
me
.
next_checkpoint
].
latitude
,
CHECKPOINT_LIST
[
me
.
next_checkpoint
].
longitude
);
if
(
me
.
distance
<=
EPSILON
)
{
console
.
log
(
"
[DEMO] Reached Checkpoint %d
"
,
me
.
next_checkpoint
);
me
.
next_checkpoint
+=
1
;
me
.
direction_set
=
false
;
}
return
;
}
if
(
!
me
.
parachute_triggered
)
{
console
.
log
(
"
[DEMO] Deploying parachute...
"
);
me
.
triggerParachute
();
me
.
parachute_triggered
=
true
;
}
if
(
me
.
landed
())
{
me
.
exit
(
0
);
}
};
}(
console
,
me
));
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment