The problem of data exchange between STP format of 3D modeling model and simscape in Matlab

Recently, I was researching to convert the data in the 3D model to MATLAB for simulation. I initially learned that Simscape in the MATLAB toolkit can perform physical modeling. The following content is mainly seen from the official website of Maiswalker, of course, there is also a little bit of my own thinking.
The CAD model can be converted to the equivalent Simscape. The conversion relies on the smimport function, the central parameter of which is the name of the XML multi-body description file. The XML file passes the data needed to recreate the original model to Simscape Multibody. If there are unsupported constraints in the model, the approximate values ​​can be passed to Simscape.
There are two steps to convert a CAD model: export and import. One is to export from 3D modeling software, convert the CAD assembly model into XML multi-entity description file and a set of step or STL part geometry files. The second is to import to matlab; convert multi-entity description and part geometry files into SLX Simscape multi-entity model and M data files. The model obtains all block parameter inputs from the data file, which is the .m file.
Insert picture description here
The converted model represents a CAD part called a solid in the Simscape multi-entity software, using the Simulink subsystem, which contains multiple entities and rigid conversion blocks. The solid block provides the geometry, inertia and color of the solid. The rigid transformation block provides the frame with the posture required for the connection between the entities.
**Theoretically, CAD part models can be exported from any CAD application. **But XML is needed as the information medium, and how the 3D software generates the relevant XML is a problem. The stp format can be read with notepad, but it is not a format that simscape can read, so directly changing the suffix of the stp file to xml will not work.
For example, I used UG to draw a drone model, but I haven't found a suitable method to convert the model parameters to XML that can be recognized by simscape.
But Messwalker officially launched a plug-in: Simscape Multibody Link CAD, which can export models in a valid XML format. But this plug-in is currently only compatible with three desktop CAD applications: SolidWorks, Cre and Inventor. The plug-in not only generates XML multi-body description files, but also any geometry files needed for visualization in the final converted model.

Installation
1. Download
Download the plug-in from the Maiswalker official website, and download as you actually need; https://www.mathworks.com/campaigns/offers/download_smlink.html

Then you need to leave the email and other information, just fill it in. Finally download the plug-in to the local, the compressed package does not need to be opened; there are not many requirements for the storage location.
2. Installation
Run MATLAB as an administrator, and then enter install_addon('zipname') in the command line window, zipname is the name of the corresponding compressed file, for example, I downloaded smlink.r2018b.win64.zip, then it is in the command line window Enter install_addon('smlink.r2018b.win64.zip')
Insert picture description here
. The above figure is the prompt of the command line window after the installation is complete.
3. Register MATLAB as an automation server.
Then enter regmatlabserver in the command line window. Then MATLAB prompts that it is busy. After a while, if If there is no other prompt, it means that the registration is successful.

4. To enable the solidworks software,
enter smlink_linksw in the MATLAB command line (don’t be misled by the subtitle, go to the sw operation, note that it is still in MATLAB), after success, the following figure will pop up
Insert picture description here
and then open sw, and find ->plugins in the top toolbar ->Other plug-ins, check the Simscape Multibody Link, as shown in the figure below,
Insert picture description here
open the part to be converted, and then click on the tool, you will see the option of Simscape Multibody Link, click Simscape Multibody Link-> Export ->Simscape Multibody

Insert picture description here
The system pops up a dialog box to generate the XML file
Insert picture description here
and the corresponding STEP file. The automatically generated STEP file is the STEP model of a single component in the assembly model.

Next is the import part.
Importing refers to importing an XML file into Matlab, the input is an XML file and a series of STEP files, the tool is Matlab, and the output is the slx file about the assembly model and its assembly parameter m file.
Change the Matlab directory to the directory where XML and STEP are located, and enter "smimport('xmlname')", where xmlname is the name of the XML file, as shown in the figure below,
Insert picture description here
then Mtalb opens Simulink and generates the corresponding slx file based on the XML information, which is related to the file data .m file
Insert picture description here
Insert picture description here
At this point, the entire conversion process is basically complete.

In addition to using XML as an intermediate format file conversion, there is another way to use Urdf format. Do in-depth research later.

Guess you like

Origin blog.csdn.net/weixin_42896636/article/details/110879529