-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_fig4.m
65 lines (43 loc) · 1.38 KB
/
main_fig4.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
%% Test Kinematics
clc;
clear all;
close all;
%% Define links
links{1} = buildLinkType1();
links{2} = buildLinkType2();
links{3} = buildLinkType3();
links{4} = buildLinkType4();
links{5} = buildLinkType5();
%% Build Robot
robot = BuildRobot(links);
%% Solve Kinematics & Plot
force_array = linspace(0,1.5,4);
n = length(force_array);
legend_array = cell(1,n);
clrs = lines(n);
h_figure = figure;
for i = 1:n
f = force_array(i);
robot.links{end}.extLoad = @(T)constGlobalLoad(T, [0;f;0], [0.0, 0.0]);
tensions = [6, 3];
robot = SolveRJMKin(robot, tensions);
h_plots(i) = plotRJM_noFrame(robot, clrs(i,:));
% plot forces
if i > 1
tipP = robot.T{end}(1:2,3)';
drawArrowTip(tipP + [8*(i-1), 0], 0.0, 4, clrs(i,:), 1)
plot([tipP(1), tipP(1) + 8*(i-1)-1], [tipP(2), tipP(2)], 'Color', clrs(i,:), 'LineWidth', 2);
plot(tipP(1), tipP(2), 'o', 'MarkerSize', 2, 'Color', clrs(i,:), 'LineWidth', 2);
end
% legends
legend_array{i} = ['force = ', num2str(f)];
end
axis equal
grid on
text(17,0,'Base', 'FontSize', 12)
set(h_figure,'Position',[100,100,450,350])
set(gca,'LooseInset',get(gca,'TightInset'))
axis equal
set(gca, 'XLim', gca().XLim + [-5, 5], 'YLim', gca().YLim + [-5, 5])
set(gca,'LooseInset',get(gca,'TightInset'))
legend(h_plots, legend_array, 'Interpreter','latex', 'FontSize', 12, 'Location', 'SouthWest');