如何将Creo/ProE Mechanism 转化为URDF并显示在RVIZ中

原网址: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 

要将UG模型转化为urdf,可以使用simmechanics-to-urdf工具。首先,你需要克隆simmechanics-to-urdf的git仓库,并安装它。你可以按照以下步骤进行操作:\[1\] 1. 执行以下命令克隆git仓库: ``` git clone https://github.com/robotology/simmechanics-to-urdf ``` 2. 进入simmechanics-to-urdf目录: ``` cd simmechanics-to-urdf ``` 3. 使用sudo权限安装simmechanics-to-urdf: ``` sudo python setup.py install ``` 安装完成后,你可以使用simmechanics_to_urdf命令来生成urdf文件。你需要提供SimMechanics模型的XML文件和一个参数配置文件。执行以下命令来生成urdf文件:\[2\] ``` simmechanics_to_urdf 00_MESH_ALL.xml --yaml config.yaml --output xml >> arm.urdf ``` simmechanics_to_urdf命令将会生成一个urdf文件,其包含了模型的所有物体、参考框架、惯性框架和关节信息。请注意,如果不使用参数配置文件,生成的模型可能在静止时看起来正确,但在运动时可能无法正确移动。因此,建议使用参数配置文件来确保模型的正确性。\[3\] #### 引用[.reference_title] - *1* *2* *3* [如何将Creo/ProE Mechanism 转化为URDF显示RVIZ](https://blog.csdn.net/u011608180/article/details/86570017)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值