示例#1
0
#!/usr/bin/python

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import pyFlight as flight

flight.loadFromFile(
    "/home/prokop/git/SimpleSimulationEngine/cpp/apps/AeroCombat/data/AeroCraftMainWing1.ini"
)


def getRotXZ(angle):
    ca = np.cos(angle)
    sa = np.sin(angle)
    return np.array([[ca, 0.0, -sa], [0.0, 1.0, 0.0], [sa, 0.0, ca]])


rot = np.array([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]])
flight.setTilt(2, 0.01)
flight.setTilt(0, 0.1)
flight.setTilt(1, -0.1)
#flight.setTilt( 3, 0.1 )

n = 10
poss = np.zeros((n, 3))
vels = np.zeros((n, 3))
rots = np.zeros((n, 3, 3))
'''
plt.figure(figsize=(15,5));
plt.subplot(1,3,1); plt.plot( poss[:,0], poss[:,2] ); plt.title("X-Z")
示例#2
0
    optimizer_yaw.step()
    optimizer_roll.step()
    optimizer_roll.step()
    optimizer_roll.step()


#  optimizer_trhot.step()
#  optimizer_trhot.step()
#  optimizer_trhot.step()
#  optimizer_trhot.step()
#  optimizer_trhot.step()

#-- Start Flight Engine -----------------------------------------------------
# --- set workdir with configuration of aircraft, textures etc.
flight.loadFromFile(
    "/home/aki/Dropbox/SimpleSimulationEngine/cpp/apps/AeroCombat/data/AeroCraftMainWing1.ini"
)

# --- initialize visualization (optional, just for debugging)
#fview = flight.FlightView("/home/aki/Dropbox/SimpleSimulationEngine/")

# --- set initial state of aircraft   setPose( position, velocity, rotMat==[left,up,forward] )
flight.setPose(
    np.array([0.0, random.uniform(0, 200), 0.0]),
    np.array([
        random.uniform(0, 100),
        random.uniform(-100, 100),
        random.uniform(0, 200)
    ]), np.array([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]))
flight.setTilt(2, 0.02)  # set Angle-of-incidence for wing #2 ( = elevator)
#!/usr/bin/python

import numpy as np
#import matplotlib.pyplot as plt
#from mpl_toolkits.mplot3d import Axes3D
import pyFlight as flight
import time

work_dir = "/home/prokop/git/SimpleSimulationEngine/cpp/Build/apps/AeroCombat"
flight.loadFromFile(work_dir + "/data/AeroCraftMainWing1.ini")

fview = flight.FlightView(work_dir)

flight.setPose(np.array([0.0, 200.0, 0.0]), np.array([0.0, 0.0, 100.0]),
               np.array([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]))
flight.setTilt(2, 0.02)
#flight.setTilt( 0,  0.1 )
#flight.setTilt( 1, -0.1 )
#flight.setTilt( 3, 0.1 )

targets = np.random.random((30, 4))
targets[:, :3] += -0.5
targets[:, 0] *= 1000
targets[:, 1] *= 200
targets[:, 2] *= 1000
targets[:, 3] += 2.0
#print targets

flight.setTargets(targets)

n = 10