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
1
Merge Requests
1
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
f28b4e9b
Commit
f28b4e9b
authored
Apr 25, 2024
by
Léo-Paul Géneau
👾
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Provide check and landing points through operator
parent
e6a4e807
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
69 deletions
+66
-69
multicopter_swarm.js
multicopter_swarm.js
+23
-68
operator.js
operator.js
+43
-1
No files found.
multicopter_swarm.js
View file @
f28b4e9b
...
...
@@ -14,52 +14,8 @@
var
ALTITUDE_DIFF
=
5
,
BASE_ALTITUDE
=
25
,
CHECKPOINT_LIST
=
[
{
latitude
:
45.310770
,
longitude
:
5.950148
},
{
latitude
:
45.311229
,
longitude
:
5.949820
},
{
latitude
:
45.311246
,
longitude
:
5.950584
},
{
latitude
:
45.310785
,
longitude
:
5.950877
}
],
EPSILON
=
4
,
PARACHUTE_POINT_ARRAY
=
[
{
latitude
:
45.310479
,
longitude
:
5.950495
},
{
latitude
:
45.310393
,
longitude
:
5.950677
},
{
latitude
:
45.310376
,
longitude
:
5.950295
},
{
latitude
:
45.310304
,
longitude
:
5.950459
},
{
latitude
:
45.310235
,
longitude
:
5.950608
}
],
TARGETED_DISTANCE
=
10
,
TAKE_OFF_POINT
=
{
latitude
:
45.310479
,
longitude
:
5.950495
},
MIN_CMD_INTERVAL
=
500
,
MIN_SPEED
=
4
,
DEFAULT_SPEED
=
5
,
...
...
@@ -126,7 +82,6 @@
me
.
going_to_parachute
=
false
;
me
.
id_list
=
[
me
.
id
];
me
.
timestamp_list
=
[
0
];
me
.
id_list
.
sort
();
me
.
landing
=
false
;
me
.
last_cmd_timestamp
=
0
;
me
.
next_checkpoint
=
0
;
...
...
@@ -151,7 +106,7 @@
neighbor_position
=
me
.
getDroneDict
()[
neighbor_id
];
}
if
(
!
me
.
path_planning
){
if
(
!
me
.
checkpoint_list
){
if
(
leader_id
!==
me
.
id
)
{
console
.
log
(
"
timestamp difference
"
,
...
...
@@ -159,13 +114,13 @@
);
}
return
me
.
sendMsg
(
JSON
.
stringify
(
{
id
:
me
.
id
,
okState
:
true
,
state
:
"
Ready
"
}
{
id
:
me
.
id
,
okState
:
true
,
state
:
"
Ready
"
,
timestamp
:
Date
.
now
()
}
));
}
if
(
me
.
landing
&&
me
.
isLanding
())
{
return
me
.
sendMsg
(
JSON
.
stringify
(
{
id
:
dron
e
.
id
,
okState
:
false
,
state
:
"
Landing
"
}
{
id
:
m
e
.
id
,
okState
:
false
,
state
:
"
Landing
"
}
));
}
...
...
@@ -215,8 +170,8 @@
distanceToTakeOffPoint
=
distance
(
neighbor_position
.
latitude
,
neighbor_position
.
longitude
,
TAKE_OFF_POINT
.
latitude
,
TAKE_OFF_POINT
.
longitude
me
.
landing_point_list
[
0
]
.
latitude
,
me
.
landing_point_list
[
0
]
.
longitude
);
console
.
log
(
"
Distance from neighbor to takeoff point
"
,
...
...
@@ -251,22 +206,22 @@
}
checkpointIndex
=
(
!
me
.
reverse
)
?
me
.
next_checkpoint
:
CHECKPOINT_LIST
.
length
-
me
.
next_checkpoint
-
1
;
:
me
.
checkpoint_list
.
length
-
me
.
next_checkpoint
-
1
;
if
(
!
me
.
direction_set
)
{
console
.
log
(
"
Going to Checkpoint
"
,
checkpointIndex
);
me
.
next_point
=
{
"
latitude
"
:
CHECKPOINT_LIST
[
checkpointIndex
].
latitude
,
"
longitude
"
:
CHECKPOINT_LIST
[
checkpointIndex
].
longitude
"
latitude
"
:
me
.
checkpoint_list
[
checkpointIndex
].
latitude
,
"
longitude
"
:
me
.
checkpoint_list
[
checkpointIndex
].
longitude
};
me
.
direction_set
=
true
;
}
if
(
pointReached
(
me
,
CHECKPOINT_LIST
[
checkpointIndex
],
EPSILON
)
pointReached
(
me
,
me
.
checkpoint_list
[
checkpointIndex
],
EPSILON
)
)
{
console
.
log
(
"
Reached Checkpoint
"
,
checkpointIndex
);
me
.
next_checkpoint
+=
1
;
me
.
next_checkpoint
%=
CHECKPOINT_LIST
.
length
;
me
.
next_checkpoint
%=
me
.
checkpoint_list
.
length
;
me
.
direction_set
=
false
;
return
me
.
sendMsg
(
JSON
.
stringify
({
id
:
me
.
id
,
...
...
@@ -279,9 +234,9 @@
}
if
(
me
.
going_to_parachute
&&
pointReached
(
me
,
PARACHUTE_POINT_ARRAY
[
me
.
id
],
EPSILON
))
{
pointReached
(
me
,
me
.
landing_point_list
[
me
.
id
],
EPSILON
))
{
me
.
going_to_parachute
=
false
;
return
exitOnFail
(
dron
e
.
land
(),
"
Failed to land
"
);
return
exitOnFail
(
m
e
.
land
(),
"
Failed to land
"
);
}
if
(
!
me
.
landing
||
me
.
going_to_parachute
)
{
...
...
@@ -299,10 +254,10 @@
};
me
.
onGetMsg
=
function
(
msg
)
{
if
(
msg
.
hasOwnProperty
(
"
path_planning
"
))
{
me
.
path_planning
=
true
;
if
(
msg
.
hasOwnProperty
(
"
checkpoint_list
"
))
{
me
.
checkpoint_list
=
msg
.
checkpoint_list
;
me
.
landing_point_list
=
msg
.
landing_point_list
;
console
.
log
(
"
running
"
);
me
.
timestamp_list
=
Array
.
apply
(
null
,
Array
(
me
.
id_list
.
length
)).
map
(
function
()
{
return
Date
.
now
()
});
return
me
.
takeOff
();
}
...
...
@@ -317,8 +272,8 @@
me
.
landing
=
true
;
me
.
going_to_parachute
=
true
;
me
.
next_point
=
{
"
latitude
"
:
PARACHUTE_POINT_ARRAY
[
me
.
id
].
latitude
,
"
longitude
"
:
PARACHUTE_POINT_ARRAY
[
me
.
id
].
longitude
"
latitude
"
:
me
.
landing_point_list
[
me
.
id
].
latitude
,
"
longitude
"
:
me
.
landing_point_list
[
me
.
id
].
longitude
};
console
.
log
(
"
Going to rally
"
);
}
...
...
@@ -346,15 +301,15 @@
break
;
case
"
Landing
"
:
if
(
me
.
id_list
.
includes
(
msgDict
.
id
))
{
if
(
m
sgDict
.
id
!==
me
.
id
&&
m
e
.
id_list
.
includes
(
msgDict
.
id
))
{
me
.
id_list
.
splice
(
me
.
id_list
.
indexOf
(
msgDict
.
id
),
1
);
me
.
timestamp_list
.
splice
(
me
.
id_list
.
indexOf
(
id
),
1
);
me
.
timestamp_list
.
splice
(
me
.
id_list
.
indexOf
(
msgDict
.
id
),
1
);
if
(
me
.
stopped
&&
me
.
id
===
(
!
me
.
reverse
?
me
.
id_list
[
me
.
id_list
.
length
-
1
]
:
me
.
id_list
[
0
]))
{
me
.
landing
=
true
;
me
.
going_to_parachute
=
true
;
me
.
next_point
=
{
"
latitude
"
:
PARACHUTE_POINT_ARRAY
[
me
.
id
].
latitude
,
"
longitude
"
:
PARACHUTE_POINT_ARRAY
[
me
.
id
].
longitude
"
latitude
"
:
me
.
landing_point_list
[
me
.
id
].
latitude
,
"
longitude
"
:
me
.
landing_point_list
[
me
.
id
].
longitude
};
}
}
...
...
@@ -365,8 +320,8 @@
}
}
if
(
msgDict
.
hasOwnProperty
(
"
timestamp
"
))
{
me
.
timestamp_list
[
m
sgDict
.
id
]
=
msgDict
.
timestamp
;
if
(
m
e
.
id_list
.
includes
(
msgDict
.
id
)
&&
m
sgDict
.
hasOwnProperty
(
"
timestamp
"
))
{
me
.
timestamp_list
[
m
e
.
id_list
.
indexOf
(
msgDict
.
id
)
]
=
msgDict
.
timestamp
;
}
if
(
msgDict
.
hasOwnProperty
(
"
next_checkpoint
"
))
{
...
...
operator.js
View file @
f28b4e9b
...
...
@@ -4,4 +4,46 @@
*/
var
map
=
operator
.
getMapJSON
();
operator
.
sendMsg
({
flag_positions
:
map
.
flag_list
,
path_planning
:
""
});
operator
.
sendMsg
({
checkpoint_list
:
[
{
latitude
:
45.310770
,
longitude
:
5.950148
},
{
latitude
:
45.311229
,
longitude
:
5.949820
},
{
latitude
:
45.311246
,
longitude
:
5.950584
},
{
latitude
:
45.310785
,
longitude
:
5.950877
}
],
flag_positions
:
map
.
flag_list
,
landing_point_list
:
[
{
latitude
:
45.310479
,
longitude
:
5.950495
},
{
latitude
:
45.310393
,
longitude
:
5.950677
},
{
latitude
:
45.310376
,
longitude
:
5.950295
},
{
latitude
:
45.310304
,
longitude
:
5.950459
},
{
latitude
:
45.310235
,
longitude
:
5.950608
}
]
});
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