robotics-toolbox-matlab
robotics-toolbox-matlab copied to clipboard
How can we generate a circular trajectory in simulink?
Hello. I am using your toolbox and I wish to use the Simulink blocks. I was able to use the jtraj block to generate a linear trajectory. However, for a circular trajectory where the manipulator arm starts from a position and returns to the same position after going around in a circle, the jtraj block wouldn't work since it requires an initial and final joint position and then it interpolates between them (for a circular trajectory, the initial and final joint position are the same of course).
So, how do I go on about this? I am able to do this successfully in Matlab code:
%%Trajectory generation
%CIRCLE
radius=0.2;
res=200;
gran=linspace(0,2*pi,res);
x=radius*cos(gran)+0.452;
y=radius*sin(gran)-0.150;
%plot(y,x)
for i=1:1:res
TTc(:,:,i)=transl([x(i) y(i) 0.25]);
end
qq=ikine6s(p560,TTc);
% plot(p560,qq)
%signal for simulink
tfin=10;
timegran=size(qq);
timestep=timegran(1);
t=linspace(0,tfin,timestep);
qqs=[t' qq];
% qqs(:,6) = pi/4;
%Q1: PLOT OF JOINT SPACE TRAJECTORIES WITH INTERPOLATION STARTS HERE
% %choose one of four initial joint coordinates
% q_curr = qz;
% q_curr = qr;
% q_curr = qs;
q_curr = qn;
all_q = [];
all_t = [];
new_t = [0:0.5:1];
for time=1:timestep
q = jtraj(q_curr,qq(time,:),new_t);
q_curr = qq(time,:);
all_q = [all_q;q];
all_t = [all_t new_t];
new_t = [new_t(end):0.5:new_t(end)+1];
end
% plot(all_t, all_q)
% legend('q1','q2','q3','q4','q5','q6')
% xlabel('Time (s)')
% ylabel('Position (rad)')
%Q1: PLOT OF JOINT SPACE TRAJECTORIES WITH INTERPOLATION ENDS HERE
How do I use the jtraj Simulink block to do the above? Is it even possible to do that in Simulink for the circular trajectory? This is what my current Simulink configuration looks like (I used it to interpolate a linear trajectory):
