How to set the waypoints with using "geoTrajectory"

11 visualizaciones (últimos 30 días)
Tadashi Okoba
Tadashi Okoba el 8 de Oct. de 2024
Comentada: Umar el 10 de Oct. de 2024
Im trying to create a trajectory of aircraft with waypoints using geoTrajectory function.
Id like to set the following conditions:
  • Meandering trajectory with 3D spline
  • Varying speed of aircrafts center of gravity
  • Varying the start/end points for each simulation
Ive read the documentation for geoTrajectory but I couldnt create the trajectory as I planned. Please give me advice on writing scripts for above conditions.
  1 comentario
Umar
Umar el 8 de Oct. de 2024
Hi @ Tadashi Okoba,
Please let me know if the code provided below solves your problem. If you need further assistance, I will be more happy to help you out.

Iniciar sesión para comentar.

Respuestas (1)

Umar
Umar el 8 de Oct. de 2024

Hi @Tadashi Okoba ,

After reading the documentation provided at the link below,

https://www.mathworks.com/help/fusion/ref/geotrajectory-system-object.html?searchHighlight=geoTrajectory&s_tid=srchtitle_support_results_1_geoTrajectory

Note: geoTrajectory function requires one of the following:

Aerospace Toolbox
Sensor Fusion and Tracking Toolbox
Radar Toolbox
Satellite Communications Toolbox

So, to create a meandering trajectory for an aircraft using the geoTrajectory function in MATLAB, while allowing for variable speed and flexible start/end points, you can follow the structured approach below. The goal is to set up a trajectory with waypoints that meet your specific conditions. You are looking to implement a trajectory for an aircraft using the geoTrajectoryfunction, which requires waypoints in geodetic coordinates. You want to achieve:

1. A meandering trajectory with a 3D spline.

2. Variable speeds at different waypoints.

3. Flexibility in specifying start and end points for each simulation.

Below is a MATLAB script that meets your requirements:

% Clear workspace and command window
clear; clc;
% Define waypoints in geodetic coordinates [latitude, longitude, altitude]
waypoints = [
  37.0, -122.0, 1000;  % Start Point
  37.1, -122.1, 1100;  % First waypoint
  37.2, -122.05, 1200; % Second waypoint
  37.15, -122.02, 1300; % Third waypoint
  37.1, -122.0, 1000    % End Point
];
% Define times of arrival at each waypoint (in seconds)
timeOfArrival = [0, 600, 1200, 1800, 2400]; % Example: every waypoint is   
spaced by 10 minutes
% Define velocities at each waypoint (in m/s)
velocities = [
  50, 0, 0;   % Velocity at Start Point
  60, 10, 0;  % Velocity at First waypoint
  55, -5, 0;  % Velocity at Second waypoint
  65, -10, 0; % Velocity at Third waypoint
  50, 0, 0    % Velocity at End Point
];
% Create geoTrajectory object with specified properties
trajectory = geoTrajectory(waypoints', timeOfArrival', ...
                         'Velocities', velocities');
% Sample rate for the trajectory (Hz)
trajectory.SampleRate = 1; 
% Initialize storage for position data
positionsLLA = [];
% Retrieve positions along the trajectory until completion
while ~isDone(trajectory)
  positionsLLA = [positionsLLA; trajectory()];  
end
% Display the resulting positions
disp('Generated Positions (Latitude, Longitude, Altitude):');
disp(positionsLLA);
% Optional: Visualize the trajectory in a simple plot (2D)
figure;
plot3(positionsLLA(:,2), positionsLLA(:,1), positionsLLA(:,3), 'b-o');
xlabel('Longitude');
ylabel('Latitude');
zlabel('Altitude (m)');
title('Aircraft Trajectory');
grid on;
axis equal;

Waypoints Definition: define an array of waypoints in geodetic coordinates (latitude, longitude, altitude). Adjust these values to fit your desired trajectory.

Time of Arrival: An array specifies when the aircraft should arrive at each waypoint. This can be adjusted based on your simulation needs.

Velocity Specification: An N-by-3 matrix defines the velocity vector (x, y, z) at each waypoint. Modify these values to reflect varying speeds.

Creating geoTrajectory Object: The geoTrajectory object is created with waypoints and time of arrival and includes specified velocities.

Sampling Trajectory Data: A loop retrieves position data from the trajectory until all waypoints are reached.

Visualization: Finally, a simple plot visualizes the generated trajectory in a three-dimensional space.

To enhance the meandering effect further (like curves or turns), consider adjusting the waypoints to be closer together or implementing additional intermediate waypoints. Ensure that your velocity definitions are realistic based on aircraft performance characteristics for smooth transitions between waypoints.

Hope this helps.

Please let me know if you have any further questions.

  2 comentarios
Tadashi Okoba
Tadashi Okoba el 9 de Oct. de 2024
Thanks.
Worked gerat.
Umar
Umar el 10 de Oct. de 2024
Hi @ Tadashi Okoba,
Thank you for your feedback. I am pleased to hear that everything worked great for you. If you have any further questions or need assistance in the future, please do not hesitate to reach out.

Iniciar sesión para comentar.

Etiquetas

Productos


Versión

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by