Path Following Algorithm Line-Circle Path Path Switching Problem
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi everyone ,
I'm trying to implement a path following algorithm for UAV (Carrot Chase) with matlab for a line-circle path.
I have already implemented the algorithm for straight line and the loiter separately and this codes are work fine. But, since they are geometrically different shapes, they have different algorithms. So we need to switch algorithms when switching between these two shapes if we want to follow this two shapes together . And i added a algorithm for that but i think it's not working
i have a variable for that named as " guidance index". You can see this variable at the begginning of the code. When i enter this variable 1 the UAV will follow the straight line path firstly. But if i enter this variable 2, the UAV will follow the circle firstly.
You can see this in the files I attached. But the real problem starts here. After the straight line path ends, it does not follow the circular path but goes out of the path. Likewise, when I set the guidance_index variable to 2, it follows the circle path correctly, but this time it does not continue with the straight line path.
How can i fix it ?
Thanks a lot.
Best Regards
2 commentaires
Réponses (1)
Divyanshu
le 1 Août 2024
Modifié(e) : Divyanshu
le 1 Août 2024
A possible reason of the unexpected behavior of the plot in both the case where 'guidance_index' is 1 or 2 can be the following code-snippet where values of 'xt' and 'yt' are calculated incorrectly:
%For guidance_index 1
Ru = sqrt( (XM0-ugv_x)^2 + (YM0 - ugv_y)^2);
theta = atan2(YT0 - YM0, XT0 - XM0);
theta_u = atan2((ugv_y-YM0),(ugv_x - XM0));
beta = theta-theta_u;
R = sqrt(Ru^2 - ((Ru*sin(beta))^2));
xt = XM0 + (R+delta)*cos(theta);
yt = YM0+ (R+delta)*sin(theta);
% For guidance_index 2
xt = center_x + r*tan(delta_theta)*cos(theta+alpha);
yt = center_y + r*tan(delta_theta)*sin(theta+alpha);
So you need to re-look at the above code-snippets corresponding to if blocks of 'guidance_index' 1 and 2 respectively and may need to modify the calculation of 'xt' & 'yt' accordingly.
Hope it helps!
3 commentaires
Divyanshu
le 2 Août 2024
Modifié(e) : Divyanshu
le 2 Août 2024
Sure, I understand the algorithms are working separately for both the paths but when merged they are causing the problem.
I have found the root-cause of the problem that lets say when 'guidance_index' is initially '1' then when 'guidance_index' is modified inside 'if sqrt()' blocks the path still continues to be straight and does not circle around.
The reason is not the switching sequence of 'guidance_index' its rather the scope of 'guidance_index'.
Since 'guidance_index' is passed as an argument whatever value is changed and assigned to this argument inside the function 'carrotchase_ode' it doesn't affect the value declared at the starting of script.
Hence the argument passed locally to next call to 'carrotchase_ode' remains unaffected.
As a workaround, I modified the script and made it global and now when initially 'guidance_index' is 1, it follows the expected path. I am attaching the modified script file you can refer it.
Hope it helps!
Voir également
Catégories
En savoir plus sur Introduction to Installation and Licensing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!