The observation vector consists of 4 normalized states representing the longitudinal dynamics:
The normalized action is scaled to physical elevator deflection in degrees by the environment.
1import numpy as np
2import torch
3from tensoraerospace.agent.ppo.model import PPO
4from tensoraerospace.envs.b747 import ImprovedB747Env
5from tensoraerospace.signals.standart import unit_step
6from tensoraerospace.utils import generate_time_period, convert_tp_to_sec_tp
7
8# Load pretrained agent
9agent = PPO.from_pretrained("TensorAeroSpace/ppo-b747-pitch-control")
10
11# Setup environment
12dt = 0.1
13tp = generate_time_period(tn=20, dt=dt)
14tps = convert_tp_to_sec_tp(tp, dt=dt)
15
16# Create step reference signal (1 degree step at t=5s)
17reference = unit_step(tp=tps, degree=1.0, time_step=5.0, output_rad=True).reshape(1, -1)
18
19env = ImprovedB747Env(
20 initial_state=np.array([0.0, 0.0, 0.0, 0.0], dtype=np.float32),
21 reference_signal=reference,
22 number_time_steps=len(tp),
23 dt=dt,
24)
25
26# Run evaluation
27obs, _ = env.reset()
28done = False
29
30while not done:
31 action, mean_action, _ = agent.act(obs, deterministic=True)
32 action_scalar = float(np.asarray(mean_action).flatten()[0])
33 obs, reward, terminated, truncated, info = env.step(action_scalar)
34 done = terminated or truncated
1from tensoraerospace.agent.ppo.model import PPO
2
3# Load from local directory
4agent = PPO.from_pretrained("./path/to/checkpoint")
1@software{tensoraerospace2024,
2 title = {TensorAeroSpace: Advanced Aerospace Control Systems \& Reinforcement Learning Framework},
3 author = {TensorAeroSpace Team},
4 year = {2024},
5 url = {https://github.com/TensorAeroSpace/TensorAeroSpace},
6 license = {MIT}
7}