- What is the intent of the Guidance function?
- How is its behavior different than intended?
- Are you able to provide some typical input to the Guidance function, or a typical Simulink model that uses it, so that someone can attempt to reproduce the problem (after answering #1 and #2 describing what the problem is)?
- What is the paper you referred to?
- How was that plot created?
I want to know why this code doesn't work well..?
    조회 수: 3 (최근 30일)
  
       이전 댓글 표시
    
The formula was found in the paper, and the rest was designed to help this guidance work well, so I don't know why I can't follow the path well.. It's really frustrating and I want to know why and how to solve it.
function [rollCmd, velCmd] = Guidance(state)
d2r = pi/180;
east = state(1);     % n_Xav
north = state(2);    % n_Yav
psi = state(3) * d2r * 1000   % n_psi_av
velCmd = 50;
Kint = 0.5;
% 항로점
wp = [0,     0;
    2817, -2724;
    5130, -4213;
    4697, -4807;
    3539, -4337;
    2817, -2724];
persistent nw
if isempty(nw)
    nw = 1;
end
% 새로운 웨이포인트 갱신
Xi = wp(nw, 1);
Yi = wp(nw, 2);
Xf = wp(nw+1, 1);  
Yf = wp(nw+1, 2); 
N = size(wp, 1);
n_LOS = sqrt((Xf - east)^2 + (Yf - north)^2)  
n_psi_leg = atan2(Xf - Xi, Yf - Yi);  
n_psi_LOS = atan2(Xf - east, Yf - north);  
zeta = atan2(Yf - Yi, Xf - Xi);  
eta = n_psi_LOS - n_psi_leg; 
Op = n_LOS * (1 - Kint);
Lp = Op * cos(eta);
Xvir = Xf - Lp * cos(zeta)
Yvir = Yf - Lp * sin(zeta)
n_psi_vLOS = atan2(Xvir - east, Yvir - north);  
n_vLOS = sqrt((Xvir - east)^2 + (Yvir - north)^2);  
n_psi_CMD = n_psi_vLOS - psi
n_XTRK = abs(n_vLOS * sin(n_psi_LOS - n_psi_leg)) * sign(n_psi_vLOS - psi);
if n_LOS < 3
    if nw < 5
        nw = nw + 1;      
    end
end
rollCmd = (n_psi_CMD - psi)*0.5*d2r;

댓글 수: 1
  Voss
      
      
 2025년 5월 8일
				답변 (0개)
참고 항목
카테고리
				Help Center 및 File Exchange에서 String에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

