Clear Filters
Clear Filters

Why are the final values for velocity and acceleration from bsplinepolytraj() always equal to zero?

20 views (last 30 days)
When creating splines using bsplinepolytraj() the last values for the x and y component of velocity and acceleration are always zero. Here's an example from the documentation:
% Interpolate with B-Spline
% Create waypoints to interpolate with a B-Spline.
wpts1 = [0 1 2.1 8 4 3];
wpts2 = [0 1 1.3 .8 .3 .3];
wpts = [wpts1; wpts2];
L = length(wpts) - 1;
% Form matrices used to compute interior points of control polygon
r = zeros(L+1, size(wpts,1));
A = eye(L+1);
for i= 1:(L-1)
A(i+1,(i):(i+2)) = [1 4 1];
r(i+1,:) = 6*wpts(:,i+1)';
end
% Override end points and choose r0 and rL.
A(2,1:3) = [3/2 7/2 1];
A(L,(L-1):(L+1)) = [1 7/2 3/2];
r(1,:) = (wpts(:,1) + (wpts(:,2) - wpts(:,1))/2)';
r(end,:) = (wpts(:,end-1) + (wpts(:,end) - wpts(:,end-1))/2)';
dInterior = (A\r)';
% Construct a complete control polygon and use bsplinepolytraj to compute a polynomial with the new control points
cpts = [wpts(:,1) dInterior wpts(:,end)];
t = 0:0.01:1;
[q, dq, ddq, ~] = bsplinepolytraj(cpts, [0 1], t);
The values for
disp(dq(:,end))
0 0
and
disp(ddq(:, end))
0 0
I feel like this is wrong. Why are these values zero and how can I get a non-zero answer?

Answers (1)

Abhaya
Abhaya on 12 Aug 2024 at 10:54
Edited: Abhaya on 12 Aug 2024 at 12:12
Hi Everett,
I understand that you want to know why the last values for the x and y components of velocity and acceleration are always zero when creating splines using MATLAB  ‘bsplinepolytraj()’ function. I came across the same query earlier and upon examining thedq’ and ‘ddq’ vectors, I can see that the lengths of ‘dq’ and ‘ddq’ vectors match the length of time vector ‘t’.
By design MATLAB  ‘bsplinepolytraj()’ function provides ‘0’ as last value of velocity and acceleration for both the axes. This is because the function generates a piecewise cubic B-spline trajectory that naturally ends with the velocity and acceleration reaching zero at the final point. This can also be observed on other MATLAB functions like ‘trapveltraj()’.
If you are looking to ensure that the last velocity is not zero, you might need to adjust the control points or the end conditions of your B-spline trajectory.
For further explanation on MATLAB  ‘bsplinepolytraj()’ function, please follow the below documentation,
Hope this helps.

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!