Simulation of continuum robot in 2D
12 views (last 30 days)
Show older comments
% actuator space
delta_l_2 = 1; % change in length of tendon 1 and tendon 2 (assume to be the same)
length_1_range = 10:-delta_l_2:5;
length_2_range = 20:delta_l_2:25;
[~,n] = size(length_1_range);
length_1 = zeros(n,100)';
length_2 = zeros(n,100)';
for i = 1:n
length_1(:,i) = linspace(0,length_1_range(i),100); % length of tendon 1
for j = 1:n
length_2(:,j) = linspace(0,length_2_range(j),100); % length of tendon 2
end
end
% Configuration space
d=2; % radius of the continuum robot
length = (length_2 + length_1)/2;
theta = (length_2 - length_1)./(2*d); % rad
r = (2.*length_1.*d)./(length_2-length_1);
% Task space
o1_x = r-r.*cos(theta);
o1_y = r.*sin(theta);
% o1 = [o1_x,o1_y];
figure(1)
plot(o1_x(2:100,:),o1_y(2:100,:),LineWidth=4,LineStyle="-")
legend('length 1 = 10, length 2 = 20','length 1 = 9, length 2 = 21',...
'length 1 = 8, length 2 = 22','length 1 = 7, length 2 = 23',...
'length 1 = 6, length 2 = 24','length 1 = 5, length 2 = 25')
Hi there, I have coded up for the trajectory of the continuum robot when lengths of the tendon change. However, I wanted to change this code into a live simulation but I don't know how to do it. Can anyone help me with that? THANK YOU!!
0 Comments
Answers (1)
Ninad
on 14 Sep 2023
Hi Yen,
As per my understanding, you wish to visualize the plot that you have created above.
You may plot the graph inside a `for` loop, one value at a time. `pause` function can be used to delay the frames, so the visualization looks like an animation. `cla` command can also be used inside the loop to clear the current axes.
I have made some modifications to your code, to serve your purpose and saved it in a file named `continuumRobotSimulation.m` and attached it with this post.
Please review the code and see if it solves your problem.
References:
pause function: https://in.mathworks.com/help/matlab/ref/pause.html
cla command: https://in.mathworks.com/help/matlab/ref/cla.html
0 Comments
See Also
Categories
Find more on Robotics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!