Borrar filtros
Borrar filtros

2D circular trajectory generation - waypointTrajectory interpolation changing depending on the plane (XY or XZ)

12 visualizaciones (últimos 30 días)
I am having some trouble creating a semicircular 2D trajectory with the waypointTrajectory function.
The function seems to be interpolating differently depending on the plane where the points are located.
I have tried the following two cases:
On case 1 I get the desired output, but on case 2 the function interpolates differently, producing a 3D path (which in this case is not what I want).
I have tried including velocities and orientation values but nothing seems to fix the problem. Please see below the code for both cases:
CASE 1:
Waypoints = [0,0,0;...
1,1,0;...
0,2,0];
% Orientation = [0,0,0;...
% 0,0,90;...
% 0,0,180];
% quatOrientation = quaternion(Orientation,'eulerd','ZYX','frame');
% Velocities = [1,0,0;...
% 0,1,0;...
% -1,0,0];
TimeOfArrival = [0;1;2];
trajectory = waypointTrajectory(Waypoints,TimeOfArrival,'SampleRate',10);
truePosition = zeros(trajectory.SampleRate*trajectory.TimeOfArrival(end)-1,3);
c = 1;
while ~isDone(trajectory)
truePosition(c,:) = trajectory();
c = c + 1;
end
plot3(Waypoints(:,1),Waypoints(:,2),Waypoints(:,3),'LineStyle','none','Marker','o','MarkerEdgeColor','r');
hold on;
plot3(truePosition(:,1),truePosition(:,2),truePosition(:,3),'Color','k');
daspect([1 1 1]);
grid on;
xlabel('x');
ylabel('y');
zlabel('z');
CASE 2:
Waypoints = [0,0,0;...
1,0,1;...
0,0,2];
% Orientation = [0,0,0;...
% 0,-90,0;...
% 0,-180,0];
% quatOrientation = quaternion(Orientation,'eulerd','ZYX','frame');
% Velocities = [1,0,0;...
% 0,0,1;...
% -1,0,0];
TimeOfArrival = [0;1;2];
trajectory = waypointTrajectory(Waypoints,TimeOfArrival,'SampleRate',10);
truePosition = zeros(trajectory.SampleRate*trajectory.TimeOfArrival(end)-1,3);
c = 1;
while ~isDone(trajectory)
truePosition(c,:) = trajectory();
c = c + 1;
end
plot3(Waypoints(:,1),Waypoints(:,2),Waypoints(:,3),'LineStyle','none','Marker','o','MarkerEdgeColor','r');
hold on;
plot3(truePosition(:,1),truePosition(:,2),truePosition(:,3),'Color','k');
daspect([1 1 1]);
grid on;
xlabel('x');
ylabel('y');
zlabel('z');

Respuesta aceptada

Ryan Salvo
Ryan Salvo el 5 de En. de 2021
Hi David,
You are correct that the interpolation happens differently depending on the plane of motion. The waypointTrajectory object connects waypoints through an interpolation intended for vehicles whose primary mode of movement is perpendicular to Earth's gravitational direction.
This is why you are seeing the spiral on the xz-plane rather than the semicircle on the xy-plane. One potential workaround to generate a semicircle in the xz-plane is to rotate your original semicircular trajectory in the xy-plane using the rotateframe command with a quaternion object.
Thanks,
Ryan

Más respuestas (0)

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by