Skip to content
Snippets Groups Projects
Commit 6a2f7527 authored by sayanmitracode's avatar sayanmitracode
Browse files

states added for f16

parent ce3385e6
No related branches found
No related tags found
No related merge requests found
...@@ -8,6 +8,7 @@ from typing import Tuple, List ...@@ -8,6 +8,7 @@ from typing import Tuple, List
import numpy as np import numpy as np
from scipy.integrate import ode from scipy.integrate import ode
from enum import Enum, auto
from dryvr_plus_plus.scene_verifier.agents.base_agent import BaseAgent from dryvr_plus_plus.scene_verifier.agents.base_agent import BaseAgent
from dryvr_plus_plus.scene_verifier.map.lane_map import LaneMap from dryvr_plus_plus.scene_verifier.map.lane_map import LaneMap
...@@ -25,6 +26,46 @@ from aerobench.visualize import plot ...@@ -25,6 +26,46 @@ from aerobench.visualize import plot
from waypoint_autopilot import WaypointAutopilot from waypoint_autopilot import WaypointAutopilot
class F16Mode(Enum):
'''Defines the discrete modes of a single agent'''
Normal = auto()
# TODO: The one mode of this automation is called "Normal" and auto assigns it an integer value.
class State:
'''Defines the state variables of the model
Both discrete and continuous variables.
Initial values defined here do not matter.
'''
mode: F16Mode
### Continuous variable initial conditions ###
power = 9 # engine power level (0-10)
# Default alpha & beta
alpha = deg2rad(2.1215) # Trim Angle of Attack (rad)
beta = 0 # Side slip angle (rad)
# Initial Attitude
alt = 3800 # altitude (ft)
vt = 540 # initial velocity (ft/sec)
phi = 0 # Roll angle from wings level (rad)
theta = 0 # Pitch angle from nose level (rad)
psi = math.pi / 8 # Yaw angle from North (rad)
P = 0
Q = 0
R = 0
pn = 0
pe = 0
# Build Initial Condition Vectors
# state = [vt, alpha, beta, phi, theta, psi, P, Q, R, pn, pe, h, pow]
init = [vt, alpha, beta, phi, theta, psi, 0, 0, 0, 0, 0, alt, power]
def __init__(self, vt, alpha, beta, phi, theta, psi, P, Q, R, pn, pe, alt, power, mode:F16Mode):
pass
def main(): def main():
'main function' 'main function'
...@@ -61,6 +102,7 @@ def main(): ...@@ -61,6 +102,7 @@ def main():
step = 1/30 step = 1/30
extended_states = True extended_states = True
'''Main call to simulation'''
res = run_f16_sim(init, tmax, ap, step=step, extended_states=extended_states, integrator_str='rk45') res = run_f16_sim(init, tmax, ap, step=step, extended_states=extended_states, integrator_str='rk45')
print(f"Simulation Completed in {round(res['runtime'], 2)} seconds (extended_states={extended_states})") print(f"Simulation Completed in {round(res['runtime'], 2)} seconds (extended_states={extended_states})")
......
...@@ -20,7 +20,7 @@ class F16Agent(BaseAgent): ...@@ -20,7 +20,7 @@ class F16Agent(BaseAgent):
'''Dynamics of an F16 aircraft '''Dynamics of an F16 aircraft
derived from Stanley Bak's python library''' derived from Stanley Bak's python library'''
def __init__(self, id, code = None, file_name = None): def __init__(self, id, code = None, file_name = None):
'''Contructor for tha agent '''Contructor for one F16 agent
EXACTLY one of the following should be given EXACTLY one of the following should be given
file_name: name of the controller file_name: name of the controller
code: pyhton string ddefning the controller code: pyhton string ddefning the controller
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment