Skip to content

Commit

Permalink
Initial commit R2022b.
Browse files Browse the repository at this point in the history
  • Loading branch information
smiller01985 committed Oct 13, 2022
1 parent 3aee5de commit a72381d
Show file tree
Hide file tree
Showing 71 changed files with 61 additions and 40 deletions.
Binary file modified CFL_Core/Libraries/Contact_Forces_Lib.slx
Binary file not shown.
Binary file modified CFL_Core/Libraries/Parts_Lib.slx
Binary file not shown.
12 changes: 12 additions & 0 deletions CFL_Core/Scripts_Data/CFL_activeVariantBlock.m
@@ -0,0 +1,12 @@
function blk = CFL_activeVariantBlock(variant_sub_name)
% Code to return path to block which is the active variant.

% Copyright 2022 The MathWorks, Inc.

vnt_list = get_param(variant_sub_name,'Variants');
vnt_actv = get_param(variant_sub_name,'ActiveVariant');

blk = [];
if(~isempty(vnt_actv))
blk = vnt_list(strcmp(vnt_actv,{vnt_list(:).Name})).BlockName;
end
9 changes: 5 additions & 4 deletions CFL_Core/Scripts_Data/CFL_contact_setModel.m
Expand Up @@ -5,10 +5,11 @@ function CFL_contact_setModel(mdlname,contactModel)

% Copyright 2014-2022 The MathWorks, Inc.

CF_bpth=find_system(mdlname,'RegExp','on','LookUnderMasks','on','FollowLinks','on','force_law','.*');
CF_bpth_box2box=find_system(mdlname,'RegExp','on','LookUnderMasks','on','FollowLinks','on','force_law_box2box','.*');
CF_bpth_box2belt=find_system(mdlname,'RegExp','on','LookUnderMasks','on','FollowLinks','on','force_law_box2belt','.*');
CF_bpth_sph2belt=find_system(mdlname,'RegExp','on','LookUnderMasks','on','FollowLinks','on','force_law_sph2bel','.*');
f=Simulink.FindOptions('FollowLinks',1,'LookUnderMasks','All','RegExp',1);
CF_bpth=getfullname(Simulink.findBlocks(mdlname,'friction_law','.*',f));
CF_bpth_box2box=getfullname(Simulink.findBlocks(mdlname,'force_law_box2box','.*',f));
CF_bpth_box2belt=getfullname(Simulink.findBlocks(mdlname,'force_law_box2belt','.*',f));
CF_bpth_sph2belt=getfullname(Simulink.findBlocks(mdlname,'force_law_sph2bel','.*',f));

if(~isempty(CF_bpth))

Expand Down
9 changes: 5 additions & 4 deletions CFL_Core/Scripts_Data/CFL_friction_setModel.m
Expand Up @@ -5,10 +5,11 @@ function CFL_friction_setModel(mdlname,frictionModel)

% Copyright 2014-2022 The MathWorks, Inc.

CF_bpth=find_system(mdlname,'RegExp','on','LookUnderMasks','on','FollowLinks','on','friction_law','.*');
CF_bpth_box2box=find_system(mdlname,'RegExp','on','LookUnderMasks','on','FollowLinks','on','friction_law_box2box','.*');
CF_bpth_box2belt=find_system(mdlname,'RegExp','on','LookUnderMasks','on','FollowLinks','on','friction_law_box2belt','.*');
CF_bpth_sph2belt=find_system(mdlname,'RegExp','on','LookUnderMasks','on','FollowLinks','on','friction_law_sph2bel','.*');
f=Simulink.FindOptions('FollowLinks',1,'LookUnderMasks','All','RegExp',1);
CF_bpth=getfullname(Simulink.findBlocks(mdlname,'friction_law','.*',f));
CF_bpth_box2box =getfullname(Simulink.findBlocks(mdlname,'friction_law_box2box','.*',f));
CF_bpth_box2belt=getfullname(Simulink.findBlocks(mdlname,'friction_law_box2belt','.*',f));
CF_bpth_sph2belt=getfullname(Simulink.findBlocks(mdlname,'friction_law_sph2bel','.*',f));

if(~isempty(CF_bpth))

Expand Down
9 changes: 5 additions & 4 deletions CFL_Core/Scripts_Data/CFL_visual_setOnOff.m
Expand Up @@ -5,10 +5,11 @@ function CFL_visual_setOnOff(mdlname,visOnOff)

% Copyright 2014-2022 The MathWorks, Inc.

CF_bpth=find_system(mdlname,'RegExp','on','LookUnderMasks','on','FollowLinks','on','vis_on','.*');
CF_bpth_box2box=find_system(mdlname,'RegExp','on','LookUnderMasks','on','FollowLinks','on','vis_on_box2box','.*');
CF_bpth_box2belt=find_system(mdlname,'RegExp','on','LookUnderMasks','on','FollowLinks','on','vis_on_pla2pla','.*');
CF_bpth_sph2belt=find_system(mdlname,'RegExp','on','LookUnderMasks','on','FollowLinks','on','vis_on_sph2bel','.*');
f=Simulink.FindOptions('FollowLinks',1,'LookUnderMasks','All','RegExp',1);
CF_bpth=getfullname(Simulink.findBlocks(mdlname,'vis_on','.*',f));
CF_bpth_box2box =getfullname(Simulink.findBlocks(mdlname,'vis_on_box2box','.*',f));
CF_bpth_box2belt=getfullname(Simulink.findBlocks(mdlname,'vis_on_pla2pla','.*',f));
CF_bpth_sph2belt=getfullname(Simulink.findBlocks(mdlname,'vis_on_sph2bel','.*',f));

if(~isempty(CF_bpth))
for i=1:length(CF_bpth)
Expand Down
Binary file modified CFL_Core/Test_Models/Test2D_Disks_in_Box.slx
Binary file not shown.
Binary file modified CFL_Core/Test_Models/Test3D_Balls_in_Box.slx
Binary file not shown.
@@ -0,0 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?>
<Info>
<Category UUID="FileClassCategory">
<Label UUID="ad2dea70-790c-4d13-aa0b-381399c1ae7d"/>
</Category>
</Info>
Binary file modified Examples/2D/Ball_Bearing/Libraries/sm_ball_bearing_testrig_lib.slx
Binary file not shown.
Binary file modified Examples/2D/Ball_Bearing/sm_ball_bearing_testrig.slx
Binary file not shown.
Binary file modified Examples/2D/Cam_Follower/Cam_Follower.slx
Binary file not shown.
Binary file modified Examples/2D/Cam_Follower_Constraint/Cam_Follower_Constraint.slx
Binary file not shown.
Binary file modified Examples/2D/Conveyor_Belts/Belts_01_Two_Belts.slx
Binary file not shown.
Binary file modified Examples/2D/Geneva_Drive/CAD/Export/Geneva_Drive_imported.slx
Binary file not shown.
Binary file modified Examples/2D/Geneva_Drive/Geneva_Drive.slx
Binary file not shown.
Binary file modified Examples/2D/Mini_Golf/Libraries/Actuation_Lib.slx
Binary file not shown.
Binary file modified Examples/2D/Mini_Golf/Libraries/Course_Holes_Lib.slx
Binary file not shown.
Binary file modified Examples/2D/Mini_Golf/Libraries/Golf_Components_Lib.slx
Binary file not shown.
Binary file modified Examples/2D/Mini_Golf/Mini_Golf_Course.slx
Binary file not shown.
Binary file modified Examples/2D/Mini_Golf/Mini_Golf_Results.xls
Binary file not shown.
Binary file modified Examples/2D/Simple/Collision/Collision_01_Ball_Infinite_Plane.slx
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Examples/2D/Simple/Collision/Collision_04_Disks_in_Box.slx
Binary file not shown.
Binary file modified Examples/2D/Simple/Collision/Collision_05_Disk_in_Ring.slx
Binary file not shown.
Binary file modified Examples/2D/Simple/Collision/Collision_06_Catapult.slx
Binary file not shown.
Binary file not shown.
Binary file modified Examples/2D/Simple/Collision/Collision_08_Compare_Forces.slx
Binary file not shown.
Binary file modified Examples/2D/Simple/Friction/Friction_01_Box_on_Ramp_Constraint.slx
Binary file not shown.
Binary file modified Examples/2D/Simple/Friction/Friction_02_Box_on_Ramp.slx
Binary file not shown.
Binary file not shown.
Binary file modified Examples/2D/Simple/Friction/Friction_04_Disk_Rolling_on_Ramp.slx
Binary file not shown.
Binary file modified Examples/2D/Simple/Friction/Friction_05_Beam_on_Wheel.slx
Binary file not shown.
Binary file modified Examples/2D/Simple/Friction/Friction_06_Disk_on_Disk.slx
Binary file not shown.
Binary file modified Examples/2D/Simple/Friction/Friction_07_Floating_Disks.slx
Binary file not shown.
Binary file modified Examples/2D/Simple/Friction/Friction_08_Disks_and_Ring.slx
Binary file not shown.
Binary file modified Examples/2D/Simple/Friction/Friction_09_Ring_on_Disk_Float.slx
Binary file not shown.
Binary file modified Examples/2D/Simple/Friction/Friction_10_Ball_on_Wheel.slx
Binary file not shown.
Binary file modified Examples/2D/Spinning_Boxes/Spinning_Boxes.slx
Binary file not shown.
Binary file modified Examples/3D/Caster_4_Whl/Caster_4_Whl.slx
Binary file not shown.
Binary file modified Examples/3D/Caster_4_Whl/Caster_4_Whl_Hill.slx
Binary file not shown.
Binary file modified Examples/3D/Gripper_2Belts/Gripper_2Belts.slx
Binary file not shown.
Expand Up @@ -55,7 +55,8 @@
wdfm = 'sm_lib/Frames and Transforms/World Frame';
rvjt = 'sm_lib/Joints/Revolute Joint';
sdjt = 'sm_lib/Joints/6-DOF Joint';
slid = 'sm_lib/Body Elements/Solid';
slid = 'sm_lib/Body Elements/Spherical Solid';
rlid = 'sm_lib/Body Elements/Revolved Solid';
mcfg = 'sm_lib/Utilities/Mechanism Configuration';
scfg = 'nesl_utility/Solver Configuration';

Expand All @@ -80,13 +81,13 @@
%% Clean out model

% Delete lines
linehan = find_system(mdl,'FindAll','on','type','line');
linehan = find_system(mdl,'MatchFilter',@Simulink.match.allVariants,'FindAll','on','type','line');
if ~isempty(linehan)
delete(linehan)
end

% Delete blocks
blkhan = find_system(mdl,'Type','Block');
blkhan = find_system(mdl,'MatchFilter',@Simulink.match.allVariants,'Type','Block');
if ~isempty(blkhan)
delete_block(blkhan)
end
Expand All @@ -107,14 +108,14 @@
sub_h = add_block('simulink/Ports & Subsystems/Subsystem',[mdl '/' subsys_name],'Position',subsys_position);

% Delete lines
linehan = find_system(sub_h,'LookUnderMasks','all','FollowLinks','on','FindAll','on','type','line');
linehan = find_system(sub_h,'MatchFilter',@Simulink.match.allVariants,'LookUnderMasks','all','FollowLinks','on','FindAll','on','type','line');
if ~isempty(linehan)
delete(linehan)
end

% Delete blocks
inport_h = find_system(sub_h,'BlockType','Inport');
outport_h = find_system(sub_h,'BlockType','Outport');
inport_h = find_system(sub_h,'MatchFilter',@Simulink.match.allVariants,'BlockType','Inport');
outport_h = find_system(sub_h,'MatchFilter',@Simulink.match.allVariants,'BlockType','Outport');
delete_block(inport_h);
delete_block(outport_h);

Expand Down Expand Up @@ -160,7 +161,6 @@

% Set parameters for inner spheres
set_param(insph_h(insph_i),...
'GeometryShape','Sphere',...
'SphereRadius','inner_sphere_rad',...
'GraphicDiffuseColor','clr_inner_sphere',...
'Density','1000');
Expand All @@ -179,13 +179,12 @@

%% Add Outer Sphere

outsph_h = add_block(slid,...
outsph_h = add_block(rlid,...
[bdroot '/' get_param(sub_h,'Name') '/OutSph'],...
'Position',blk_or+[1 0 1 0]*600,...
'Orientation','Left');

set_param(outsph_h,...
'GeometryShape','GeneralSolidOfRevolution',...
'RevolutionCrossSection','outer_sphere_xs',...
'RevolutionExtent','Full',...
'GraphicDiffuseColor','clr_outer_sphere',...
Expand Down
Binary file not shown.
Binary file modified Examples/3D/Robot_2_Whl/Robot_2_Whl.slx
Binary file not shown.
Binary file modified Examples/3D/Robot_6Legs_4Bar/Libraries/sm_robot_6legs_4bar_lib.slx
Binary file not shown.
Binary file modified Examples/3D/Robot_6Legs_4Bar/sm_robot_6legs_4bar.slx
Binary file not shown.
Binary file modified Examples/3D/Simple/Collision/Coll3D_01_Ball_Plane_Fixed.slx
Binary file not shown.
Binary file modified Examples/3D/Simple/Collision/Coll3D_02_Ball_Plane_Spin.slx
Binary file not shown.
Binary file modified Examples/3D/Simple/Collision/Coll3D_03_Balls_in_Box.slx
Binary file not shown.
Binary file modified Examples/3D/Simple/Collision/Coll3D_04_Ball_in_Tube_Fixed.slx
Binary file not shown.
Binary file modified Examples/3D/Simple/Collision/Coll3D_05_Ball_Peg_Board.slx
Binary file not shown.
Binary file modified Examples/3D/Simple/Collision/Coll3D_06_Ball_in_Ball.slx
Binary file not shown.
Binary file modified Examples/3D/Simple/Collision/Coll3D_07_Balls_and_Sliding_Tube.slx
Binary file not shown.
Binary file modified Examples/3D/Simple/Collision/Coll3D_08_Ball_in_Spinning_Cone.slx
Binary file not shown.
Binary file modified Examples/3D/Simple/Friction/Frict3D_01_Box_on_Table.slx
Binary file not shown.
Binary file modified Examples/3D/Simple/Friction/Frict3D_02_Ball_on_Table.slx
Binary file not shown.
Binary file modified Examples/3D/Simple/Friction/Frict3D_03_Board_on_Balls.slx
Binary file not shown.
Binary file modified Examples/3D/Simple/Friction/Frict3D_04_Ball_on_Ball.slx
Binary file not shown.
Binary file modified Examples/3D/Simple/Friction/Frict3D_05_Tube_on_Balls.slx
Binary file not shown.
Binary file modified Examples/3D/Simple/Friction/Frict3D_06_Ball_on_Balls.slx
Binary file not shown.
Binary file modified Examples/3D/Simple/Friction/Frict3D_07_Ball_in_Ball.slx
Binary file not shown.
Binary file modified Examples/3D/Simple/Friction/Frict3D_08_Ball_on_Driven_Tube.slx
Binary file not shown.
Binary file modified Examples/3D/Tread_Drive/sm_tread_drive.slx
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -19,7 +19,7 @@ directly, or include it as a Referenced Project just as is done
in this project.


General approach for using this library:
General approach for using this library
1. Identify the parts in your system that will hit each other during simulation
2. Figure out which edges or surfaces will touch.
The contact models provided allow you to model contact between combinations
Expand Down
Binary file modified Scripts_Data/CFL_Results.xlsx
Binary file not shown.
Binary file modified Scripts_Data/CFL_Results_REF.xlsx
Binary file not shown.
4 changes: 2 additions & 2 deletions Scripts_Data/Doc/Contact_Forces_Demo_Script.html
Expand Up @@ -6,7 +6,7 @@
<!--
This HTML was auto-generated from MATLAB code.
To make changes, update the MATLAB code and republish this document.
--><title>Simscape Multibody Contact Forces Library</title><meta name="generator" content="MATLAB 9.12"><link rel="schema.DC" href="http://purl.org/dc/elements/1.1/"><meta name="DC.date" content="2022-03-10"><meta name="DC.source" content="Contact_Forces_Demo_Script.m"><style type="text/css">
--><title>Simscape Multibody Contact Forces Library</title><meta name="generator" content="MATLAB 9.13"><link rel="schema.DC" href="http://purl.org/dc/elements/1.1/"><meta name="DC.date" content="2022-09-18"><meta name="DC.source" content="Contact_Forces_Demo_Script.m"><style type="text/css">
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{margin:0;padding:0;border:0;outline:0;font-size:100%;vertical-align:baseline;background:transparent}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:'';content:none}:focus{outine:0}ins{text-decoration:none}del{text-decoration:line-through}table{border-collapse:collapse;border-spacing:0}

html { min-height:100%; margin-bottom:1px; }
Expand Down Expand Up @@ -85,7 +85,7 @@
<tr><b><a href="matlab:web('Contact_Forces_Demo_Script_3D_Applications.html');">3D Applications</a></b><br>
</style>
</style>
</p><p>Copyright 2014-2022 The MathWorks&#8482;, Inc.</p><p class="footer"><br><a href="https://www.mathworks.com/products/matlab/">Published with MATLAB&reg; R2022a</a><br></p></div><!--
</p><p>Copyright 2014-2022 The MathWorks&#8482;, Inc.</p><p class="footer"><br><a href="https://www.mathworks.com/products/matlab/">Published with MATLAB&reg; R2022b</a><br></p></div><!--
##### SOURCE BEGIN #####
%% Simscape Multibody Contact Forces Library
%
Expand Down
33 changes: 17 additions & 16 deletions Scripts_Data/Test_All_CFL_Examples.m
Expand Up @@ -67,6 +67,7 @@
friction_law_list = {'friction_law','friction_law_box2box','friction_law_box2belt'};
force_variants = {'Linear','Nonlinear'};
friction_variants = {'None','Stick-Slip Continuous'};
f=Simulink.FindOptions('FollowLinks',0,'LookUnderMasks','All','RegExp',1);

for mdl_i = 1:length(mdlnames)
mdl = char(mdlnames{mdl_i});
Expand All @@ -78,19 +79,19 @@
disp(['TESTING ' mdl ' ...']);

for frclaw_i=1:length(force_law_list)
block_pths = find_system(bdroot,'RegExp','on','LookUnderMasks','all',char(force_law_list(frclaw_i)),'.*');
block_pths=Simulink.findBlocks(mdl,char(force_law_list(frclaw_i)),'.*',f);
if(~isempty(block_pths))
for i=1:length(block_pths)
set_param(char(block_pths(i)),char(force_law_list(frclaw_i)),'Linear');
set_param(block_pths(i),char(force_law_list(frclaw_i)),'Linear');
end
end
end

for frilaw_i=1:length(friction_law_list)
block_pths = find_system(bdroot,'RegExp','on','LookUnderMasks','all',char(friction_law_list(frilaw_i)),'.*');
block_pths=Simulink.findBlocks(mdl,char(friction_law_list(frilaw_i)),'.*',f);
if(~isempty(block_pths))
for i=1:length(block_pths)
set_param(char(block_pths(i)),char(friction_law_list(frilaw_i)),'None');
set_param(block_pths(i),char(friction_law_list(frilaw_i)),'None');
end
end
end
Expand All @@ -103,19 +104,19 @@
CFL_Res{mdl_i+1,5} = sprintf('%5.3f',Elapsed_Sim_Time);

for frclaw_i=1:length(force_law_list)
block_pths = find_system(bdroot,'RegExp','on','LookUnderMasks','all',char(force_law_list(frclaw_i)),'.*');
block_pths=Simulink.findBlocks(mdl,char(force_law_list(frclaw_i)),'.*',f);
if(~isempty(block_pths))
for i=1:length(block_pths)
set_param(char(block_pths(i)),char(force_law_list(frclaw_i)),'Linear');
set_param(block_pths(i),char(force_law_list(frclaw_i)),'Linear');
end
end
end

for frilaw_i=1:length(friction_law_list)
block_pths = find_system(bdroot,'RegExp','on','LookUnderMasks','all',char(friction_law_list(frilaw_i)),'.*');
block_pths=Simulink.findBlocks(mdl,char(friction_law_list(frilaw_i)),'.*',f);
if(~isempty(block_pths))
for i=1:length(block_pths)
set_param(char(block_pths(i)),char(friction_law_list(frilaw_i)),'Stick-Slip Continuous');
set_param(block_pths(i),char(friction_law_list(frilaw_i)),'Stick-Slip Continuous');
end
end
end
Expand All @@ -125,19 +126,19 @@
CFL_Res{mdl_i+1,7} = sprintf('%5.3f',Elapsed_Sim_Time);

for frclaw_i=1:length(force_law_list)
block_pths = find_system(bdroot,'RegExp','on','LookUnderMasks','all',char(force_law_list(frclaw_i)),'.*');
block_pths=Simulink.findBlocks(mdl,char(force_law_list(frclaw_i)),'.*',f);
if(~isempty(block_pths))
for i=1:length(block_pths)
set_param(char(block_pths(i)),char(force_law_list(frclaw_i)),'Nonlinear');
set_param(block_pths(i),char(force_law_list(frclaw_i)),'Nonlinear');
end
end
end

for frilaw_i=1:length(friction_law_list)
block_pths = find_system(bdroot,'RegExp','on','LookUnderMasks','all',char(friction_law_list(frilaw_i)),'.*');
block_pths=Simulink.findBlocks(mdl,char(friction_law_list(frilaw_i)),'.*',f);
if(~isempty(block_pths))
for i=1:length(block_pths)
set_param(char(block_pths(i)),char(friction_law_list(frilaw_i)),'None');
set_param(block_pths(i),char(friction_law_list(frilaw_i)),'None');
end
end
end
Expand All @@ -147,19 +148,19 @@
CFL_Res{mdl_i+1,9} = sprintf('%5.3f',Elapsed_Sim_Time);

for frclaw_i=1:length(force_law_list)
block_pths = find_system(bdroot,'RegExp','on','LookUnderMasks','all',char(force_law_list(frclaw_i)),'.*');
block_pths=Simulink.findBlocks(mdl,char(force_law_list(frclaw_i)),'.*',f);
if(~isempty(block_pths))
for i=1:length(block_pths)
set_param(char(block_pths(i)),char(force_law_list(frclaw_i)),'Nonlinear');
set_param(block_pths(i),char(force_law_list(frclaw_i)),'Nonlinear');
end
end
end

for frilaw_i=1:length(friction_law_list)
block_pths = find_system(bdroot,'RegExp','on','LookUnderMasks','all',char(friction_law_list(frilaw_i)),'.*');
block_pths=Simulink.findBlocks(mdl,char(friction_law_list(frilaw_i)),'.*',f);
if(~isempty(block_pths))
for i=1:length(block_pths)
set_param(char(block_pths(i)),char(friction_law_list(frilaw_i)),'Stick-Slip Continuous');
set_param(block_pths(i),char(friction_law_list(frilaw_i)),'Stick-Slip Continuous');
end
end
end
Expand Down

0 comments on commit a72381d

Please sign in to comment.