Skip to content

Commit 31c6d5d

Browse files
minimum jerk trajectory generator
1 parent 073b4b5 commit 31c6d5d

24 files changed

+1214
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
function pos = ComputePosition(t, r_x, r_y, r_z)
2+
%COMPUTEPOSITION Summary of this function goes here
3+
% Detailed explanation goes here
4+
5+
6+
% Computing tangent vector T
7+
r_x_ev = polyval(r_x, t);
8+
r_y_ev = polyval(r_y, t);
9+
r_z_ev = polyval(r_z, t);
10+
11+
pos = [r_x_ev; r_y_ev; r_z_ev];
12+
13+
end
14+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
function R = FrenetSerretFrame(t, r_x, r_y, r_z)
2+
%FRENETSERRETFRAME Summary of this function goes here
3+
% Detailed explanation goes here
4+
5+
% Computing tangent vector T
6+
dr_x = polyval(polyder(r_x), t);
7+
dr_y = polyval(polyder(r_y), t);
8+
dr_z = polyval(polyder(r_z), t);
9+
10+
dr = [dr_x; dr_y; dr_z];
11+
T = dr / norm(dr);
12+
13+
% Computing binormal vector B
14+
ddr_x = polyval(polyder(polyder(r_x)), t);
15+
ddr_y = polyval(polyder(polyder(r_y)), t);
16+
ddr_z = polyval(polyder(polyder(r_z)), t);
17+
18+
ddr = [ddr_x; ddr_y; ddr_z];
19+
20+
B = cross(dr,ddr) / norm(cross(dr,ddr));
21+
22+
% Computing normal vector N
23+
24+
N = cross(B,T);
25+
26+
R = [T N B];
27+
28+
29+
end
30+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
function R = GenerateRotMat(phi, theta, psi)
2+
%GENERATEROTMAT Rotation matrix deriving from a 321 rotation sequence
3+
% roll - phi
4+
% pitch - theta
5+
% psi - psi
6+
7+
R = [cos(psi)*cos(theta) -cos(phi)*sin(psi) + cos(psi)*sin(theta)*sin(phi) cos(psi)*cos(phi)*sin(theta) + sin(psi)*sin(phi);
8+
cos(theta)*sin(psi) cos(psi)*cos(phi) + sin(psi)*sin(theta)*sin(phi) -cos(psi)*sin(phi) + cos(phi)*sin(psi)*sin(theta);
9+
-sin(theta) cos(theta)*sin(phi) cos(theta)*cos(phi)];
10+
11+
12+
13+
14+
end
15+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
function norm_value = Norm2D(poly_coef_x,poly_coef_y,t)
2+
%NORM2D Computes the 2D norm from polynomial coefficients of the components of the vector
3+
% Detailed explanation goes here
4+
5+
norm_value = sqrt((polyval(poly_coef_x,t))^2 + (polyval(poly_coef_y,t))^2);
6+
7+
8+
end
9+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
function derivative_value = Norm2Dderivative(poly_coef_x,...
2+
poly_coef_y,...
3+
poly_coef_x_prime,...
4+
poly_coef_y_prime,...
5+
t)
6+
%NORM2DDERIVATIVE Computes the derivative of the 2D norm from polynomial
7+
%coefficients of the components of the vector
8+
% Detailed explanation goes here
9+
10+
derivative_value = (polyval(poly_coef_x,t)*polyval(poly_coef_x_prime,t) +...
11+
polyval(poly_coef_y,t)*polyval(poly_coef_y_prime,t)) /...
12+
Norm2D(poly_coef_x,poly_coef_y,t);
13+
14+
15+
end
16+
Binary file not shown.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
function [poly_coeff_matrix_out_x,...
2+
poly_coeff_matrix_out_y,...
3+
poly_coeff_matrix_out_z] = PolyCoefAssigning(poly_coeff_matrix_in)
4+
%POLYCOEFASSIGNING Assigning polynomial coefficients to designated
5+
%variables
6+
% Detailed explanation goes here
7+
8+
poly_coeff_matrix_in_size = size(poly_coeff_matrix_in);
9+
10+
poly_coeff_matrix_out_size = [poly_coeff_matrix_in_size(1)/3, poly_coeff_matrix_in_size(2)];
11+
12+
poly_coeff_matrix_out_x = zeros(poly_coeff_matrix_out_size(1), poly_coeff_matrix_out_size(2));
13+
poly_coeff_matrix_out_y = zeros(poly_coeff_matrix_out_size(1), poly_coeff_matrix_out_size(2));
14+
poly_coeff_matrix_out_z = zeros(poly_coeff_matrix_out_size(1), poly_coeff_matrix_out_size(2));
15+
16+
for i=0:poly_coeff_matrix_out_size(1)-1
17+
poly_coeff_matrix_out_x(i+1,:) = poly_coeff_matrix_in(3*i + 1,:);
18+
poly_coeff_matrix_out_y(i+1,:) = poly_coeff_matrix_in(3*i + 2,:);
19+
poly_coeff_matrix_out_z(i+1,:) = poly_coeff_matrix_in(3*i + 3,:);
20+
21+
end
22+
23+
24+
end
25+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
function [t_adjusted,segment] = PolyTimeAdjusted(time_waypoint_vector,t)
2+
%POLYTIMEADJUSTED Adjusts the time to be fed to the various polynomials
3+
% Detailed explanation goes here
4+
5+
num_waypoints = length(time_waypoint_vector);
6+
segment = 0;
7+
% disp('START')
8+
for i=1:num_waypoints-1
9+
% disp(['i: ', num2str(i)])
10+
% disp(['t: ', num2str(t)])
11+
if (t >= time_waypoint_vector(i) & t <= time_waypoint_vector(i+1)) % >= <
12+
segment = i;
13+
% disp(['segment: ', num2str(segment)])
14+
% disp(['time_waypoint_vector(segment): ', num2str(time_waypoint_vector(segment))])
15+
t_adjusted = t - time_waypoint_vector(segment);
16+
% disp(['t_adjusted: ', num2str(t_adjusted)])
17+
% break
18+
return
19+
end
20+
end
21+
22+
end
23+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
function poly_coeff_matrix_out = PolyderMatrix(poly_coeff_matrix_in)
2+
%POLYDERMATRIX derivative of the piecewise polynomial coefficient matrix
3+
% Detailed explanation goes here
4+
5+
poly_coeff_matrix_in_size = size(poly_coeff_matrix_in);
6+
7+
poly_coeff_matrix_out = zeros(poly_coeff_matrix_in_size(1), poly_coeff_matrix_in_size(2)-1);
8+
9+
for i=1:poly_coeff_matrix_in_size(1)
10+
poly_coeff_matrix_out(i,:) = polyder(poly_coeff_matrix_in(i,:));
11+
end
12+
13+
14+
end
15+
Binary file not shown.

0 commit comments

Comments
 (0)