waypointTrajectory generator : TOA vs SPEED

21 views (last 30 days)
Using Waypoint trajectory generator in Navigation toolbox, a "travel" can be defined using WAYPOINTs and TOAs.
Its also possible to define a SPEED parameter for each of the WAYPOINTs.
For me it seems that defining TOA and SPEED for a waypoint can be "contradictory" or "unconsistant" because TOA is the result of a distance/speed.
I guess, I missed something in the documentation.
is there an example with speed parameter used or an explaination ?

Accepted Answer

Ryan Salvo
Ryan Salvo on 29 Sep 2021
Hi Juliette,
There is an example in the help for waypointTrajectory, but it is not on the documentation page. I have created a request to add this example to the documentation page. For now, you can access this example by executing the following command on the Command Window:
help waypointTrajectory
The example is:
% EXAMPLE 2: Generate a racetrack trajectory by specifying the velocity
% and orientation at each waypoint.
Fs = 100;
wps = [0 0 0;
20 0 0;
20 5 0;
0 5 0;
0 0 0];
t = cumsum([0 10 1.25*pi 10 1.25*pi]).';
vels = [2 0 0;
2 0 0;
-2 0 0;
-2 0 0;
2 0 0];
eulerAngs = [0 0 0;
0 0 0;
180 0 0;
180 0 0;
0 0 0];
q = quaternion(eulerAngs, 'eulerd', 'ZYX', 'frame');
traj = waypointTrajectory(wps, 'SampleRate', Fs, ...
'TimeOfArrival', t, 'Velocities', vels, 'Orientation', q);
% fetch pose information one buffer frame at a time
[pos, orient, vel, acc, angvel] = traj();
i = 1;
spf = traj.SamplesPerFrame;
while ~isDone(traj)
idx = (i+1):(i+spf);
[pos(idx,:), orient(idx,:), ...
vel(idx,:), acc(idx,:), angvel(idx,:)] = traj();
i = i+spf;
% Plot generated positions and specified waypoints.
plot(pos(:,1),pos(:,2), wps(:,1),wps(:,2), '--o')
xlabel('X (m)')
ylabel('Y (m)')
zlabel('Z (m)')
legend({'Position', 'Waypoints'})
axis equal
The Velocities property is the velocity of the object at the time is passes the corresponding waypoint, not the velocity as the object travels from waypoint to waypoint. These Velocities values, along with the Waypoints and TimeOfArrival values, determine the object's speed from waypoint to waypoint.
The Algorithms section of the documentation page also has some more details on how the trajectory is generated.
juliette soula
juliette soula on 2 Oct 2021
Hi Ryan,
thanls for the code above which is very helpful.
In order to improve my understanding I've experimented settings combinations.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!