Time variable for robot trajectory
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi,
I am trying to build robot trajectory to work on inverse dynamics.Trajectory is using polynomial expressions as below.
a0=2;
a1=0;
a2=9.75;
a3=3.25;
theta1=a0+(a1*t)+(a2*t*t)+(a3*t*t*t);Joint angle
v1=a1+(2*a2*t)+(3*a3*t*t); Joint velocity
a1=(2*a2)+(6*a3*t); Joint acceleration
I have used clok block of simulink to provide time input t. I dont think it is the right process. Do we have any other block in simulink to provide time input?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1432658/image.jpeg)
댓글 수: 2
Sam Chak
2023년 7월 13일
I don't see any issue so far. What problem did you encounter in Simulink?
t = linspace(0, 2, 10001);
a0 = 2;
a1 = 0;
a2 = 9.75;
a3 = 3.25;
theta1 = a0 + a1*t + a2*t.^2 + a3*t.^3; % Joint angle
v1 = a1 + 2*a2*t + 3*a3*t.^2; % Joint velocity
a1 = 2*a2 + 6*a3*t; % Joint acceleration
채택된 답변
Sam Chak
2023년 7월 14일
After checking your comment, I think you need to update the polynomials for each time interval. For one-time use, it maybe okay to use the Clock block. That Clock block outputs the current simulation time at each simulation step. The following example shows how to compute the Quintic Polynomial Trajectories for
, based your desired initial and final values.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1434368/image.png)
t0 = 1; % start time
t1 = 2; % end time
A = [1 t0 t0^2 t0^3 t0^4 t0^5;
0 1 2*t0 3*t0^2 4*t0^3 5*t0^4;
0 0 2 6*t0 12*t0^2 20*t0^3;
1 t1 t1^2 t1^3 t1^4 t1^5;
0 1 2*t1 3*t1^2 4*t1^3 5*t1^4;
0 0 2 6*t1 12*t1^2 20*t1^3]
B = [3; 2; 1; 4; 3; 2]; % desired initial and final values
x = A\B
t = linspace(t0, t1, 10001);
y = x(1) + x(2)*t + x(3)*t.^2 + x(4)*t.^3 + x(5)*t.^4 + x(6)*t.^5;
dy = gradient(y)./gradient(t);
ddy = gradient(dy)./gradient(t);
tiledlayout(3, 1, 'TileSpacing', 'compact')
nexttile
plot(t, y, 'linewidth', 1.5, 'color', '#cc3232'), grid on
ylabel({'$\theta$ / rad'}, 'interpreter', 'latex', 'fontsize', 12)
title('Quintic Polynomial Trajectories', 'fontsize', 12)
nexttile
plot(t, dy, 'linewidth', 1.5, 'color', '#e6b415'), grid on
ylabel({'$\dot{\theta}$ / (rad/s)'}, 'interpreter', 'latex', 'fontsize', 12)
nexttile
plot(t, ddy, 'linewidth', 1.5, 'color', '#2dc937'), grid on
ylabel({'$\ddot{\theta}$ / (rad/s$^2$)'}, 'interpreter', 'latex', 'fontsize', 12)
xlabel({'$t$ / s'}, 'interpreter', 'latex', 'fontsize', 12)
댓글 수: 0
추가 답변 (1개)
Parth Saraf
2023년 7월 13일
Hi,
If you want to avoid using Clock block, you may use the Ramp block or the "From Workspace" block.
You can create a time vector in the workspace which may be useful.
Hope this helps!
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Robotics에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!