Skip to content

Commit 2546802

Browse files
committed
WIP for adding old model sl_ibvs.slx to the Toolbox
Refactored the Simulink library roblocks into 3 sublibraries
1 parent 87340db commit 2546802

7 files changed

+101
-0
lines changed

toolbox/generallib.slx

48.2 KB
Binary file not shown.

toolbox/mobilelib.slx

45.3 KB
Binary file not shown.

toolbox/roblocks.slx

-19.8 KB
Binary file not shown.

toolbox/sl_ibvs.slx

114 KB
Binary file not shown.

toolbox/slcamera.m

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
function p = slcamera(cam, u)
2+
if all(u == 0)
3+
% Simulink is probing for the dimensions
4+
np = (length(u)-16)/3;
5+
p = zeros(np, 2);
6+
else
7+
P = reshape(u(17:end), [], 3);
8+
Tcam = reshape(u(1:16), 4, 4);
9+
p = cam.plot(P, pose=Tcam);
10+
drawnow;
11+
end
12+
13+
% function slcamera(block)
14+
% setup(block);
15+
% end
16+
%
17+
% function setup(block)
18+
% % Set number of input ports
19+
% block.NumInputPorts = 1;
20+
% block.InputPort(1).DimensionsMode = 'Variable'; % Allow variable dimensions
21+
% block.InputPort(1).DirectFeedthrough = true;
22+
%
23+
% % Set the number of output ports
24+
% block.NumOutputPorts = 1; % Assuming one output port
25+
% block.OutputPort(1).Dimensions = 2; % Example output dimensions, adjust as needed
26+
%
27+
% % Set block sample time
28+
% block.SampleTimes = [0 0]; % Continuous
29+
%
30+
% % Set the block methods
31+
% block.RegBlockMethod('InitializeConditions', @mdlInitializeConditions);
32+
% block.RegBlockMethod('Outputs', @mdlOutputs);
33+
% end
34+
%
35+
% function mdlInitializeConditions(block)
36+
% % Initialize conditions if needed
37+
% end
38+
%
39+
% function mdlOutputs(block)
40+
% u = block.InputPort(1).Data; % Get input data
41+
% if all(u == 0)
42+
% % Simulink is probing for the dimensions
43+
% np = (length(u) - 16) / 3;
44+
% p = zeros(np, 2);
45+
% else
46+
% P = reshape(u(17:end), [], 3);
47+
% Tcam = reshape(u(1:16), 4, 4);
48+
% p = cam.plot(P, 'pose', Tcam, 'drawnow');
49+
% end
50+
% block.OutputPort(1).Data = p; % Set output data
51+
% end

toolbox/sltrprint.m

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
%STRPRINT S-function for transformation display in a block
2+
%
3+
% Input is the SE2 or SE3 transform to display.
4+
5+
6+
function sltrprint(block)
7+
setup(block);
8+
end
9+
10+
function setup(block)
11+
% Set number of dialog parameters
12+
block.NumDialogPrms = 1; % Example for options, adjust as needed
13+
14+
% Set the number of input ports
15+
block.NumInputPorts = 1;
16+
block.InputPort(1).DimensionsMode = 'Fixed'; % Allow variable dimensions
17+
% block.InputPort(1).DirectFeedthrough = true;
18+
19+
% Set the number of output ports
20+
block.NumOutputPorts = 0; % No outputs
21+
22+
% Set block sample time
23+
block.SampleTimes = [0 0]; % Continuous
24+
25+
% Set the block methods
26+
block.RegBlockMethod('InitializeConditions', @mdlInitializeConditions);
27+
block.RegBlockMethod('Outputs', @mdlOutputs);
28+
end
29+
30+
function mdlInitializeConditions(block)
31+
% Initialize conditions if needed
32+
end
33+
34+
function mdlOutputs(block)
35+
u = block.InputPort(1).Data; % Get input data
36+
options = block.DialogPrm(1).Data; % Get options from dialog
37+
38+
if ~isempty(u)
39+
if length(u) == 3
40+
s = printtform2d(trvec2tform(u(1:2)) * rotm2d(u(3)), options{:});
41+
elseif istform2d(u)
42+
s = printtform2d(u, options{:});
43+
elseif istform(u)
44+
s = printtform(u);
45+
else
46+
error('RVC:sltrprint', 'unknown type passed, expecting 3x1, 3x3, 4x4');
47+
end
48+
set_param(block.BlockHandle, MaskDisplay=sprintf("disp('%s');", s));
49+
end
50+
end

toolbox/visualservolib.slx

42 KB
Binary file not shown.

0 commit comments

Comments
 (0)