2D circular trajectory generation - waypointTrajectory interpolation changing depending on the plane (XY or XZ)
15 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
David Lago
am 3 Jan. 2021
Kommentiert: David Lago
am 8 Jan. 2021
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');
0 Kommentare
Akzeptierte Antwort
Ryan Salvo
am 5 Jan. 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
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Tracking and Sensor Fusion finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!