1
+ % Configure visual tags
2
+ visualSub = [gcb ' /Visuals' ];
3
+ radiusBlocks = find_system(visualSub ,' FollowLinks' ,' on' ,' LookUnderMasks' ,' on' ,' BlockType' ,' From' );
4
+ for idx = 1 : numel(radiusBlocks )
5
+ lh = get_param(radiusBlocks{idx },' LineHandles' );
6
+ delete_line(lh .Outport );
7
+ end
8
+ delete_block(radiusBlocks );
9
+ vecBlock = [visualSub ' /Vector Concatenate' ];
10
+ set_param(vecBlock ,' NumInputs' ,num2str(numRobots ));
11
+ for idx = 1 : numRobots
12
+ blkName = [visualSub ' /From' num2str(idx )];
13
+ blkPos = [0 30 200 50 ] + (idx - 1 )*[0 30 0 30 ];
14
+ add_block(' simulink/Signal Routing/From' ,blkName );
15
+ set_param(blkName ,' GotoTag' ,[' slMultiRobotEnv_Visuals_' num2str(idx )]);
16
+ set_param(blkName ,' Position' ,blkPos );
17
+ add_line(visualSub ,[' From' num2str(idx ) ' /1' ],[' Vector Concatenate/' num2str(idx )]);
18
+ end
19
+
20
+ % Configure pose tags
21
+ poseSub = [gcb ' /Poses' ];
22
+ poseBlocks = find_system(poseSub ,' FollowLinks' ,' on' ,' LookUnderMasks' ,' on' ,' BlockType' ,' From' );
23
+ for idx = 1 : numel(poseBlocks )
24
+ lh = get_param(poseBlocks{idx },' LineHandles' );
25
+ delete_line(lh .Outport );
26
+ end
27
+ delete_block(poseBlocks );
28
+ vecBlock = [poseSub ' /Vector Concatenate' ];
29
+ set_param(vecBlock ,' NumInputs' ,num2str(numRobots ));
30
+ for idx = 1 : numRobots
31
+ blkName = [poseSub ' /From' num2str(idx )];
32
+ blkPos = [0 30 200 50 ] + (idx - 1 )*[0 30 0 30 ];
33
+ add_block(' simulink/Signal Routing/From' ,blkName );
34
+ set_param(blkName ,' GotoTag' ,[' slMultiRobotEnv_Pose_' num2str(idx )]);
35
+ set_param(blkName ,' Position' ,blkPos );
36
+ add_line(poseSub ,[' From' num2str(idx ) ' /1' ],[' Vector Concatenate/' num2str(idx )]);
37
+ end
38
+
39
+ % Configure range tags
40
+ rangeSub = [gcb ' /Ranges' ];
41
+ rangeBlocks = find_system(rangeSub ,' FollowLinks' ,' on' ,' LookUnderMasks' ,' on' ,' BlockType' ,' From' );
42
+ for idx = 1 : numel(rangeBlocks )
43
+ lh = get_param(rangeBlocks{idx },' LineHandles' );
44
+ delete_line(lh .Outport );
45
+ end
46
+ delete_block(rangeBlocks );
47
+ vecBlock = [rangeSub ' /Vector Concatenate' ];
48
+ set_param(vecBlock ,' NumInputs' ,num2str(numRobots ));
49
+ for idx = 1 : numRobots
50
+ blkName = [rangeSub ' /From' num2str(idx )];
51
+ blkPos = [0 30 200 50 ] + (idx - 1 )*[0 30 0 30 ];
52
+ add_block(' simulink/Signal Routing/From' ,blkName );
53
+ set_param(blkName ,' GotoTag' ,[' slMultiRobotEnv_Ranges_' num2str(idx )]);
54
+ set_param(blkName ,' Position' ,blkPos );
55
+ add_line(rangeSub ,[' From' num2str(idx ) ' /1' ],[' Vector Concatenate/' num2str(idx )]);
56
+ end
57
+
58
+ % Initialize range sensor bus
59
+ internal .createRangeSensorBus ;
60
+
61
+ % Configure object detector tags
62
+ objDetSub = [gcb ' /ObjectDetectorParams' ];
63
+ objDetBlocks = find_system(objDetSub ,' FollowLinks' ,' on' ,' LookUnderMasks' ,' on' ,' BlockType' ,' From' );
64
+ for idx = 1 : numel(objDetBlocks )
65
+ lh = get_param(objDetBlocks{idx },' LineHandles' );
66
+ delete_line(lh .Outport );
67
+ end
68
+ delete_block(objDetBlocks );
69
+ vecBlock = [objDetSub ' /Vector Concatenate' ];
70
+ set_param(vecBlock ,' NumInputs' ,num2str(numRobots ));
71
+ for idx = 1 : numRobots
72
+ blkName = [objDetSub ' /From' num2str(idx )];
73
+ blkPos = [0 30 200 50 ] + (idx - 1 )*[0 30 0 30 ];
74
+ add_block(' simulink/Signal Routing/From' ,blkName );
75
+ set_param(blkName ,' GotoTag' ,[' slMultiRobotEnv_ObjDet_' num2str(idx )]);
76
+ set_param(blkName ,' Position' ,blkPos );
77
+ add_line(objDetSub ,[' From' num2str(idx ) ' /1' ],[' Vector Concatenate/' num2str(idx )]);
78
+ end
79
+
80
+ % Configure robot detector tags
81
+ robotDetSub = [gcb ' /RobotDetectorParams' ];
82
+ robotDetBlocks = find_system(robotDetSub ,' FollowLinks' ,' on' ,' LookUnderMasks' ,' on' ,' BlockType' ,' From' );
83
+ for idx = 1 : numel(robotDetBlocks )
84
+ lh = get_param(robotDetBlocks{idx },' LineHandles' );
85
+ delete_line(lh .Outport );
86
+ end
87
+ delete_block(robotDetBlocks );
88
+ vecBlock = [robotDetSub ' /Vector Concatenate' ];
89
+ set_param(vecBlock ,' NumInputs' ,num2str(numRobots ));
90
+ for idx = 1 : numRobots
91
+ blkName = [robotDetSub ' /From' num2str(idx )];
92
+ blkPos = [0 30 200 50 ] + (idx - 1 )*[0 30 0 30 ];
93
+ add_block(' simulink/Signal Routing/From' ,blkName );
94
+ set_param(blkName ,' GotoTag' ,[' slMultiRobotEnv_RobotDet_' num2str(idx )]);
95
+ set_param(blkName ,' Position' ,blkPos );
96
+ add_line(robotDetSub ,[' From' num2str(idx ) ' /1' ],[' Vector Concatenate/' num2str(idx )]);
97
+ end
98
+
99
+ % Configure waypoints port
100
+ hasWaypointPort = ~isempty(find_system(gcb ,' FollowLinks' ,' on' ,' LookUnderMasks' ,' on' ,' BlockType' ,' Inport' ,' Name' ,' waypoints' ));
101
+ if ~showWaypoints & hasWaypointPort
102
+ replace_block(gcb ,' FollowLinks' ,' on' ,' Name' ,' waypoints' ,' built-in/Ground' ,' noprompt' );
103
+ elseif showWaypoints & ~hasWaypointPort
104
+ replace_block(gcb ,' FollowLinks' ,' on' ,' Name' ,' waypoints' ,' built-in/Inport' ,' noprompt' );
105
+ end
106
+
107
+ % Configure objects port
108
+ hasObjectPort = ~isempty(find_system(gcb ,' FollowLinks' ,' on' ,' LookUnderMasks' ,' on' ,' BlockType' ,' Inport' ,' Name' ,' objects' ));
109
+ if ~showObjects & hasObjectPort
110
+ replace_block(gcb ,' FollowLinks' ,' on' ,' Name' ,' objects' ,' built-in/Ground' ,' noprompt' );
111
+ elseif showObjects & ~hasObjectPort
112
+ replace_block(gcb ,' FollowLinks' ,' on' ,' Name' ,' objects' ,' built-in/Inport' ,' noprompt' );
113
+ end
114
+
115
+ % Ensure the waypoints and objects ports are organized correctly
116
+ if strcmp(get_param([gcb ' /waypoints' ],' BlockType' ),' Inport' )
117
+ set_param([gcb ' /waypoints' ],' Port' ,' 1' );
118
+ end
0 commit comments