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

조회 수: 68(최근 30일)
David Lago 2021년 1월 3일
댓글: David Lago 2021년 1월 8일
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');

댓글을 달려면 로그인하십시오.

채택된 답변

Ryan Salvo 2021년 1월 5일
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
댓글 수: 1표시숨기기 없음
David Lago 2021년 1월 8일
Regards
David Lago

댓글을 달려면 로그인하십시오.

범주

Find more on Coordinate Transformations and Trajectories in Help Center and File Exchange

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by