Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
I-MAV
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
PASTOR Philippe
I-MAV
Commits
1f3e75cf
Commit
1f3e75cf
authored
3 weeks ago
by
CANTINI Lorenzo
Browse files
Options
Downloads
Patches
Plain Diff
Initial commit for drone 2D drone2D_model
parent
e3f90ea5
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
drone2D/drone2D_model.py
+56
-0
56 additions, 0 deletions
drone2D/drone2D_model.py
with
56 additions
and
0 deletions
drone2D/drone2D_model.py
0 → 100644
+
56
−
0
View file @
1f3e75cf
import
yaml
from
scipy.integrate
import
solve_ivp
class
Drone2D
:
def
__init__
(
self
,
file
=
"
drone2D.yaml
"
):
with
open
(
file
,
'
r
'
)
as
stream
:
drone_data
=
yaml
.
load
(
stream
)
self
.
G
=
9.81
self
.
MASS
=
drone_data
[
"
MASS
"
]
self
.
INERTIA
=
drone_data
[
"
INERTIA
"
]
self
.
LENGTH
=
drone_data
[
"
LENGTH
"
]
self
.
HEIGHT
=
drone_data
[
"
HEIGHT
"
]
def
dynamics
(
self
,
state
:
list
,
inp
:
list
):
"""
ODE system for the 2D drone.
Parameters:
state = [x, y, theta, vx, vy, vtheta]
input = [thrust1, thrust2]
Returns:
list of derivatives
"""
x
,
y
,
theta
,
vx
,
vy
,
vtheta
=
state
T1
,
T2
=
inp
ax
=
-
(
T1
+
T2
)
*
theta
/
self
.
MASS
ay
=
(
(
T1
+
T2
)
/
self
.
MASS
)
-
self
.
G
atheta
=
(
T2
-
T1
)
*
self
.
LENGTH
/
self
.
INERTIA
return
[
vx
,
vy
,
vtheta
,
ax
,
ay
,
atheta
]
def
step
(
self
,
state
,
inp
,
dt
):
"""
Step the time for the 2D drone.
Parameters:
initial state = [x, y, theta, vx, vy, vtheta]
input = [thrust1, thrust2]
time step (scalar)
Returns:
final state
"""
func
=
lambda
t
,
s
:
self
.
dynamics
(
s
,
inp
)
solution
=
solve_ivp
(
func
,
[
0
,
dt
],
state
)
return
solution
.
y
[
-
1
]
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