在雷达仿真过程中,运动仿真的必要性,以及运动仿真可以实现哪些功能,在matlab对应的user guide中已经讲的很清楚了,这里不再赘述。
本文主要介绍phased.Platform的一些“坑”,和典型的用法。
第一坑:系统对象机制
系统对象(system object)在调用的时候,返回当前的状态值,并计算下一状态值存储在系统对象中,直到调用release函数复位。假如仿真的时间步长为T,第一次调用系统对象返回零时刻的状态值。如果我们想要知道nT时刻的返回值,则需要调用系统对象函数n+1次。
第二坑:InitialVelocity属性
在帮助文档是这么描述该属性
红框中说:当MotionModel设置为Velocity且VelocitySource设置为Input port的时候,InitialVelocity起作用。但是问题来了,当VelocitySource设置为Input port的时候,系统对象调用的形式必须满足[Pos,Vel] = platform(T,V)
,那么在调用的时候必须还要输入V参数,可以推断,第一次调用系统对象时,返回的Vel值应该是Initialvelocity,而输入参数V则是为了更新下一次数据使用。更新原则为:Pos = Pos + T*V
和Vel = V
。
验证代码如下:
clear;clc;v0 = [1, 2, 3]';
v1 = [2, 3, 4]';
v2 = [3, 4, 5]';rdPlatform = phased.Platform();
rdPlatform.MotionModel = 'Velocity';
rdPlatform.InitialPosition = [0;0;0];
rdPlatform.VelocitySource = 'Input port';
rdPlatform.InitialVelocity = v0;T = 1;% 输出pos=initialPosition=[0,0,0],vel=[1,2,3],
% 更新vel = [2,3,4]
% 更新pos = initialPosition + T*v1 =[2,3,4]
[pos, vel] = rdPlatform(T, v1)% 输出pos = [2,3,4]和vel=[2,3,4]
% 更新vel = [3,4,5]
% 更新pos=[2,3,4]+[3,4,5]=[5,7,9]
[pos, vel] = rdPlatform(T, v2)% 输出pos = [5,7,9]和vel=[1,2,3]
% 更新vel = [1,2,3]
% 更新pos=[5,7,9]+[1,2,3]=[6,9,12]
[pos, vel] = rdPlatform(T, v0)
第三坑:Velocity属性
每次调用函数的时候,都不需要更新velocity,这是最基本的用法。
由于velocity这个属性tunable,所以在仿真过程中可以更新velocity的值,。
clear;clc;rdPlatform = phased.Platform();
rdPlatform.MotionModel = 'Velocity';
rdPlatform.InitialPosition = [0;0;0];
rdPlatform.VelocitySource = 'Property';
rdPlatform.Velocity = [10;20;-10];T = 1;[pos, vel] = rdPlatform(T)
rdPlatform.Velocity = [10;10;-10];
[pos, vel] = rdPlatform(T)rdPlatform.Velocity = [0;10;-10];
[pos, vel] = rdPlatform(T)
第四坑:旋转模式
旋转模式比较复杂,首先看旋转模式的定义:
这里说,在Circulor模式下,沿着平台方向坐标系中方位指向的顺时针方向旋转,这个说法非常难懂。需要弄懂什么是orientation axes和aizmuth direction。
根据系统对象调用的规则:[Pos,Vel,Laxes] = step(___)
可以返回局部坐标系,而局部坐标系Laxes定义如下:
可以知道Laxes就是platform orientation axes,也叫platform axes,Laxes是绕着运动轨迹的方向进行旋转,这句话也非常难懂。
先说结论:
(1)平台仿真中包含了三个坐标系,第一个是全局坐标系,不用细说;
(2)第二个是平台局部坐标系,该坐标系随着速度矢量的变化而变化;
解释如下
假如每一时刻的速度矢量为 v i v_i vi,由速度矢量确定的坐标系(我自己写一个函数,来确定平台局部坐标系,该函数根据x轴来确定局部坐标系,因此叫xaxes)为 P i P_i Pi,那么 P i P_i Pi可以由 P 1 P_1 P1通过线性变换 T i T_i Ti得到,写作
P i = T i × P 1 P_i=T_i\times P_1 Pi=Ti×P1
由此可以得到线性变换为 T i = P i × P 1 T T_i=P_i\times P_1^T Ti=Pi×P1T,假设平台没有旋转运动,那么平台初始的局部坐标系 L 1 L_1 L1就是单位矩阵 I 3 I_3 I3,第 i i i时刻的局部坐标系 L i L_i Li就是 L i = T i × L 1 = P i × P 1 T L_i=T_i\times L_1=P_i\times P_1^T Li=Ti×L1=Pi×P1T。
clear;clc;
close all;v = [10; -10; 10];
scanrate = 10;
initaxes = azelaxes(-23, 10);rdPlatform = phased.Platform(...'MotionModel','Acceleration', ...'InitialPosition',[10,20,30]',...'InitialVelocity',v, ...'AccelerationSource','Property', ...'Acceleration',[-20,10,-10]');rdPlatform.ScanMode = 'None';
rdPlatform.InitialScanAngle = 0;
rdPlatform.AzimuthScanRate = scanrate;
rdPlatform.InitialOrientationAxes = initaxes;
rdPlatform.OrientationAxesOutputPort = true;T = 0.1
refpos = [0; 0; 0];figure;
ha = axes("Parent", gcf);
hold(ha, 'on');
xlabel('x')
ylabel('y')
zlabel('z')v0 = xaxes(v);
R1 = azelaxes(0, 20);for i = 1:50[pos, vel, lax] = rdPlatform(T);xaxes(vel)*transpose(v0)*initaxeslaxpltax(ha, pos, vel, lax);endaxis(ha, 'equal')
(3)第三个是平台上的旋转坐标系,该坐标系绕着平台局部坐标系的z轴转动。
假设旋转坐标系的初始为 R 1 R_1 R1,旋转角度为 θ \theta θ,那么旋转变换可以表示为 r o t z ( θ ) \rm{rotz}(\theta) rotz(θ),那么加旋转的局部坐标系就是 r o t z ( θ ) × R 1 \rm{rotz}(\theta)\times R_1 rotz(θ)×R1
clear;clc;close all;v = [0; 0; 0];scanrate = 10;rdPlatform = phased.Platform(...
'MotionModel','Acceleration', ...
'InitialPosition',[0,0,0]',...
'InitialVelocity',v, ...
'AccelerationSource','Property', ...
'Acceleration',[0, 0, 0]');rdPlatform.ScanMode = 'Circular';
rdPlatform.InitialScanAngle = 0;
rdPlatform.AzimuthScanRate = scanrate;
rdPlatform.InitialOrientationAxes = azelaxes(0, -20);
rdPlatform.OrientationAxesOutputPort = true;T = 1;refpos = [0; 0; 0];figure;ha = axes("Parent", gcf);
hold(ha, 'on');
xlabel('x')
ylabel('y')
zlabel('z')v0 = xaxes(v);R1 = azelaxes(0, -20);for i = 1:5[pos, vel, lax] = rdPlatform(T);% [~, ang] = rangeangle(lax(:,1))% R = rotz(scanrate*(i-1)*T);rotz(-scanrate*(i-1)*T) * R1laxpltax(ha, pos, vel, lax);
endaxis(ha, 'equal')
(4)包含平动和转动的运动状态,改状态下返回的Laxes值目前机理还不清楚。带讨论
附件
function lax = xaxes(x)x = x / norm(x);
% define vector v in x-y plane of global coordinate system
v = [0; 0; 1];
% compute y;
y = cross(v, x);
y = y / norm(y);
% compute z;
z = cross(x, y);
% construct local axes;
lax = [x, y, z];
end
function pltax(ha, pos, vel, ax)vel = vel / norm(vel);
scatter3(ha, pos(1), pos(2), pos(3), 'k');
quiver3(ha, pos(1), pos(2), pos(3), vel(1), vel(2), vel(3), 'k', 'MaxHeadSize', 2, 'AutoScale', 'off');
quiver3(ha, pos(1), pos(2), pos(3), ax(1, 1), ax(2, 1), ax(3, 1), 'b', 'MaxHeadSize', 2, 'AutoScale', 'off');
quiver3(ha, pos(1), pos(2), pos(3), ax(1, 2), ax(2, 2), ax(3, 2), 'r', 'MaxHeadSize', 2, 'AutoScale', 'off');
quiver3(ha, pos(1), pos(2), pos(3), ax(1, 3), ax(2, 3), ax(3, 3), 'r', 'MaxHeadSize', 2, 'AutoScale', 'off');end