python实现飞行控制仿真(二) 您所在的位置:网站首页 python仿真实验 python实现飞行控制仿真(二)

python实现飞行控制仿真(二)

2022-05-17 22:34| 来源: 网络整理| 查看: 265

一、问题:利用python实现三自由度

【总结不对的地方请评论或私信我,谢谢!】

三自由度中简化的几个问题

1、3个控制量,(相比较6自由度中会使用4个控制量),三自由度中一般使用推力、升力和滚转角来控制,或使用其变形模式

2、三自由度中不考虑攻角和侧滑角,假设其为0,

3、速度方向和机体方向近似重合

 

二、求解过程

三自由度模型中主要包含速度、角度及其变化的模型,不包含力学和力矩关系方程。

上图方程中的x,y,z为惯性坐标系下的位置坐标,v为飞行器的速度,为飞行器轨迹的航迹角,(相对于惯性坐标系下的角度)

上图方程中主要涉及到速度以及角度的变化率及其与该方向的加速度的关系。

上图第一个式子代表推力和速度的关系,可以看成推力和阻力的合力对速度产生的影响,其方向为速度的方向,其中重力的一个分力也是阻力的作用,减掉重力加速度的一个分量

上图的第二个式子代表航迹倾角(俯仰角)的变化率与加速度的关系,为飞行器的过载,其方向为机顶的方向,如最上面的示意图所示,其作用可以理解为控制飞行器的俯仰角。

上图第三个式子中包含第三个控制量,即滚转角,控制飞行器转弯的角度。

三、代码实现 # -*- coding: UTF-8 -*- # 版本: # 开发时间:2020/8/3 23:14 # 用户:HDY # Function: import numpy as np from scipy.integrate import odeint from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt from matplotlib import rcParams rcParams['axes.unicode_minus']=False rcParams['font.family'] = 'simhei' time = 10 #秒 n=100 t = np.linspace(0, time, n) position = np.zeros((n,6)) dt = t[1]-t[0] velocity, gamma, fai_v = 260., 3.14/10., 0. x,y,z = 0,0,0 # 初始位置 #todo 三个控制量 control1 = 3.0 control2 = 2. control3 = 3.14/12 position[0,0] = x ; position[0,1] = y; position[0,2] = z position[0, 3] = velocity position[0, 4] = gamma position[0, 5] = fai_v for k in range(1, n): tspan = [t[k - 1], t[k]] po = odeint(dmove2, (velocity, gamma, fai_v), tspan, args=([control1,control2,control3],)) velocity, gamma, fai_v = po[1,:] dx = velocity * np.cos(gamma) * np.sin(fai_v) * dt dy = velocity * np.cos(gamma) * np.cos(fai_v) * dt dz = velocity * np.sin(gamma) * dt x = x + dx ; position[k,0] = x y = y + dy; position[k,1] = y z = z + dz; position[k,2] = z position[k, 3] = velocity position[k, 4] = gamma position[k, 5] = fai_v fig = plt.figure() ax = Axes3D(fig) plt.title('trajectory') ax.plot(position[:, 0], position[:, 1], position[:, 2]) plt.xlabel("X") plt.ylabel("Y") plt.figure(3) plt.title(r'velocity 速度') plt.plot(position[:, 3]) plt.figure(4) plt.title(r'theta 航迹倾角') plt.plot(position[:, 4]) plt.figure(5) plt.title(r'fai_v 航向角') plt.plot(position[:, 5]) plt.show()

各参数变化

def dmove2( x_input, t, control): g = 9.81 # 重力加速度 velocity, gamma, fai = x_input nx, nz, gunzhuan = control velocity_ = g * (nx - np.sin(gamma)) # # 米每秒 gamma_ = (g / velocity) * (nz * np.cos(gunzhuan) - np.cos(gamma)) # 米每秒 fai_ = g*nz*np.sin(gunzhuan) / (velocity * np.cos(gamma)) return np.array([velocity_, gamma_, fai_])

 



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有