过调处理,PID控制器,瞄准辅助MkIII
- Error和ErrorD足够小时,直接作弊旋转飞机
- Error和ErrorD足够小时,作弊扭枪
- 让玩家自己输入来修正——模仿War Thunder,玩家可以通过输入修正瞄准辅助的目标瞄准位置。向输入方向是累加输入的delta,累加结果作为目标瞄准偏移,就像下图所示
3月31日。通过改为直接使用相差角度(pyMeToPredictor)作为Error,而不是idealInputVector后,强烈的ErrorD抖动已经解决,而且不是特别容易overshoot了
现在有两个问题:
- 接近目标后依然有轻微的ErrorD抖动,需要个Low-pass Filter处理下——Unity 2016-03-31 17-31-20-95_Shake_P0.45_D0.1_I0
- 重战、滚转率低的飞机一直无法击中目标,因为它的滚转能力差,且没有I Term,导致始终无法追上目标——Unity 2016-03-31 17-44-32-41_Me410_P0.45_D0.1_I0
Low-pass Filter
- 一种叫做Set Point Filters的过滤方式
- 对PV(Error)进行过滤会引发Overshoot(因为过滤意味着数据延迟)
3月31日加入了低通滤波后成功减弱了抖动
The P-Only Algorithm
The P-Only controller computes a CO action every loop sample time T as:
CO = CObias + Kc∙e(t)
Where:
CObias = controller bias or null value
Kc = controller gain, a tuning parameter
e(t) = controller error = SP – PV
SP = set point
PV = measured process variable
Understanding Controller Bias
Let’s suppose the P-Only control algorithm shown above is used for cruise control in an automobile and CO is the throttle signal adjusting the flow of fuel to the engine.
Let’s also suppose that the speed SP is 70 and the measured PV is also 70 (units can be mph or kph depending on where you live in the world). Since PV = SP, then e(t) = 0 and the algorithm reduces to:
CO = CObias + Kc∙(0) = CObias
If CObias is zero, then when set point equals measurement, the above equation says that the throttle signal, CO, is also zero. This makes no sense. Clearly if the car is traveling 70 kph, then some baseline flow of fuel is going to the engine.
This baseline value of the CO is called the bias or null value. In this example, CObias is the flow of fuel that, in manual mode, causes the car to travel the design speed of 70 kph when on flat ground on a calm day.
Definition: CObias is the value of the CO that, in manual mode, causes the PV to steady at the DLO while the major disturbances are quiet and at their normal or expected values.
A P-Only controller bias (sometimes called null value) is assigned a value as part of the controller design and remains fixed once the controller is put in automatic.
- OError(未经低通滤波的错误)始终维持在0.1以下,多数时间在0.01以下
发现了新问题:虽然error已经很低,但是机头依然没有对准HitBoxPredictor(可以看到上图计数中的FireAt仅为38)
- FixedUpdate
- 场景中的所有飞机更新位移,自机以外的所有飞机更新旋转
- osPlayer._FixedUpdateAfterOSPlane——更新osPlaneController_Player._AimAssist的状态
- LateUpdate
- osPlaneController_Player.UpdateInput
- osPlane.SetAimAssist
- 读取自己和敌人飞机的空间信息,计算Error等Feedback数据
- PID控制器根据Feedback数据计算Output
- 自己的飞机根据Output更新旋转
- osMachineGun
- 子弹射出
- 按照原本的设计,即使飞机每帧在射击时机头都对准了目标,Error也不应该为0。这是因为计算Error是发生在修正逻辑的前面
- 但是PID控制器的特点是消除错误,所以就持续overshoot了。。。
- FixedUpdate
- 场景中的所有飞机更新位移,自机以外的所有飞机更新旋转
- osPlayer._FixedUpdateAfterOSPlane——更新osPlaneController_Player._AimAssist的状态
- LateUpdate
- osPlaneController_Player.UpdateInput
- osPlane.SetAimAssist
- PID控制器根据Feedback数据计算Output
- 自己的飞机根据Output更新旋转
- 读取自己和敌人飞机的空间信息,计算Error等Feedback数据
- osMachineGun
- 子弹射出
4月6日,失速引起抖动,视频:Unity 2016-04-06 17-18-17-09_失速引起抖动
- 瞄准辅助启动时多旋转:revision 36967,修改osPlaneController_Player.UpdateAimAssist方法,只有前一帧瞄准辅助是起效的,才执行瞄准辅助的物理模拟。
- 瞄准辅助关闭时少旋转:revision 36991,在osPlaneController_Player.LateUpdate改成如果上帧苗猪辅助是启动状态,那么本帧依然执行UpdateAimAssist方法,以便让瞄准辅助的物理模拟起效
4月13日,加入延迟射击后,第一枪总是会先开出一枪
- FixedUpdate
- 场景中的所有飞机更新位移,自机以外的所有飞机更新旋转
- osPlayer._FixedUpdateAfterOSPlane——更新osPlaneController_Player._AimAssist的状态
- Update
- osPlane.Update——将osPlaneController的开枪状态更新给osMachineGun
- LateUpdate
- osPlaneController.LateUpdate->osPlaneController_Player.UpdateInput
- osPlane.SetAimAssist
- PID控制器根据Feedback数据计算Output
- 自己的飞机根据Output更新旋转
- 读取自己和敌人飞机的空间信息,计算Error等Feedback数据
- osMachineGun.LateUpdate
- 子弹射出
- FixedUpdate
- 场景中的所有飞机更新位移,自机以外的所有飞机更新旋转
- Update
- osPlane.Update——将osPlaneController的开枪状态更新给osMachineGun
- LateUpdate
- osPlayer.LateUpdate——更新osPlaneController_Player._AimAssist的状态
- osPlaneController.LateUpdate->osPlaneController_Player.UpdateInput
- osPlane.SetAimAssist
- PID控制器根据Feedback数据计算Output
- 自己的飞机根据Output更新旋转
- 读取自己和敌人飞机的空间信息,计算Error等Feedback数据
- osMachineGun.LateUpdate
- 子弹射出
附件列表
posted on 2016-12-17 16:23 MobileFish 阅读(901) 评论(0) 编辑 收藏 举报