原网址:http://wiki.icub.org/wiki/Creo_Mechanism_to_URDF

参考网址:https://it.mathworks.com/help/physmod/smlink/ug/installing-and-linking-simmechanics-link-software.html

                  https://github.com/robotology-playground/simmechanics-to-urdf

ROS网址:http://wiki.ros.org/simmechanics_to_urdf

1.导出模型步骤:

CAD (Creo) → SimMechanics (MathWorks) → URDF

2.具体工作流程

     第一部分:结构工程师简化CAD机器人模型

     1.使用简单表示(Simp Rep)对零件进行分组,注意包括所需的所有零件(可能包括螺钉)。

     2.将获得的简单表示(Simp Rep)重命名

     3.将分组的部件保存为收缩包络(shrinkwrap)

     4.创建一个新的模拟机制并使用收缩部件组装机器人

    (注:第4项我没有看懂,所以只做了一个机器人的装配文件(assembly file)。期间需要注意的是:CAD中的简单表示是什么?收缩包络是什么?简化后的Simp Rep的质量,质心,转动惯量如何计算,安装关系;ROS中的计算单位和CAD的计算单位不一样。)

     第二部分:使用插件将第一部分中的装配文件(assembly file)转化为stl文件和一个xml机器人描述文件

    1.在CAD/ProE中安装Simscape Multibody Link 插件,具体步骤参考上面的参考网址;安装完成以后再

    2.使能Simscape Multibody Link 插件;点击Creo菜单栏中的 “工具 --> 辅助应用程序”,如下图:

3.注册插件(选择下载的protk.dat文件)

4.启动插件

5.点击 “启动”按钮后,在 "工具" 中出现一个“工具”选项,如下图:

6.插件安装成功后,下一步生成ROS所需要的STL文件和一个XML的机器人描述文件;点击“工具 --> SimMechanics Link --> Export --> SimMechanics First Generation”,选择一个目标文件夹。如下图:

7.插件导出的内容如下:(一个xml文件,和许多stl文件);打开xml文件开一下内容,然后你就会明白是什么回事了。这里不详细解释,参考链接。http://wiki.ros.org/simmechanics_to_urdf

8.切换系统到ubuntu(当前为Window),在ubuntu ROS系统上,生成urdf的文件。

工作的原理是:

The SimMechanics Link creates an XML file (PhysicalModelingXMLFile) and a collection of STL files. The XML describes all of the bodies, reference frames, inertial frames and joints for the model. The script convert.py takes this information and converts it to a URDF. However, there are some tricks and caveats, which can maneuvered using a parameter file. Not using a parameter file will result in a model that looks correct when not moving, but possibly does not move correctly.

  • Debian/Ubuntu 安装 simmechanics-to-urdf

Install the necessary dependencies with apt-get:

sudo apt-get install python-lxml python-yaml python-numpy python-setuptools python-catkin-pkg

You can install urdf_parser_py from its git repository:

git clone https://github.com/ros/urdf_parser_py
cd urdf_parser_py
sudo python setup.py install

Install simmechanics-to-urdf

git clone https://github.com/robotology/simmechanics-to-urdf
cd simmechanics-to-urdf
sudo python setup.py install
  • 生成urdf文件 

cd 到 Creo / ProE  Simscape Multibody Link 插件生成的文件夹(共享到ubuntu系统上的),关于如何创建共享文件夹,请查看这个链接:https://blog.csdn.net/u011608180/article/details/86470001

cd copy && ls

 2.执行simmechanics_to_urdf命令,生成urdf,如下:

simmechanics_to_urdf 00_MESH_ALL.xml --yaml config.yaml --output xml >> arm.urdf

3.测试生成的urdf文件是否正确,如下:

check_urdf arm.urdf

其中config.yaml的内容如下:(我只列了重要的一部分)

scale: "0.001 0.001 0.001"
forcelowercase: Yes
filenameformat:
    "package://arm_description/meshes/%s"

4.在ROS的RVIZ中使用URDF文件

roslaunch arm_description display.launch

注:此时显示遇到一个错误

[ERROR] [1548054318.991262697]: The STL file 'package://arm_description/meshes/01-mesh_rt_prt.stl' is malformed. It starts with the word 'solid' and also contains the word 'endsolid', indicating that it's an ASCII STL file, but rviz can only load binary STL files so it will not be loaded. Please convert it to a binary STL file.

解决办法:(对每一个stl文件进行如下操作,我只列举了第一个,此过程需要安装meshlab)

sudo apt-get install meshlab
meshlabserver -i 01-mesh_rt_prt.stl -o ../01-mesh_rt_prt.stl

最终的效果如下图:

 

后记:这种方式能够快速的从CAD文件转换到URDF文件,非常的方便。下一步就可以在gazebo中进行仿真了。此时你会发现joint关节不能够转动,限位也不对。

我的youtube上面的一个视频:https://www.youtube.com/watch?v=xo6JBVRfn3w 

Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐