SolidWorks STP模型->URDF->Webots proto模型

1. STP 转 URDF

参考:

从solidworks导出URDF模型_sw_urdf镜像下载-CSDN博客

solidworks模型利用sw2urdf生成urdf模型导入CoppeliaSim(v-rep)步骤及相关错误(以及导入到ros的Rviz中用moveit进行路径规划)_逆风的少年的博客-CSDN博客

1> 安装sw_urdf_exporter

①从sw_urdf_exporter - ROS Wiki下载sw2urdfSetup.exe文件,下载后点击安装

 ②SW中:工具>插件>勾选SW2URDF,启用插件

 ③工具>tools/有的版本是File>Export as URDF

 2>配置URDF文件信息

①根据需求配置URDF父子关系、关节及其坐标系

base关节需要配置坐标系;旋转关节需要配置旋转轴和坐标系;直线关节需要配置移动轴。

其余按照UI界面提示配置。

②配置完成后点击Preview and Export……导出

③导出时会根据坐标系、材质等生成相关的坐标系、关节名称、固有属性如质量和RPY等信息

已知SW2018存在的问题:

如果使用了相同的零部件,在导出后放到ubuntu工作空间下编译, 执行launch文件夹下的launch文件,即用RVIZ或者gazebo显示零部件时会出现散架的情况。

解决方法:

把每个重复的零部件都稍作修改(不影响外观和使用),另存为新零件,再在设计树上右键替换。最后导出即可。导出的文件夹内容如下。

 

另,实测sw2016不存在如上问题。建议安装2016进行如上模型转换的工作。

检查模型是否正确的方法:

将生成的模型整个文件夹放到ubuntu下的工作空间目录/src文件夹中,编译工作空间。

cd到上面截图的launch文件夹下,执行

roslaunch display.launch

  roslaunch gazebo.launch

分别启动rviz和gazebo进行检查。

rviz需要点击add把模型调出来,gazebo直接就会显示。

2. URDF 转 Webots proto

参考:

利用插件将solidworks模型转化为URDF文件,再转化为proto文件并导入Webots_webots导入urdf-CSDN博客

1>安装urdf2webots工具

在终端中执行

pip install urdf2webots==1.0.8

如果不指定版本号,则会安装最新版。对目前的需求来说,用1.0.8版本足矣。 

我用的pip install,其他安装方法可以自行搜索。

 2>文件转换

python -m urdf2webots.importer --input=someRobot.urdf [--output=outputFile] [--normal] [--box-collision] [--tool-slot=linkName] [--help]

示例:python -m urdf2webots.importer --input=D:\\moon_dog_v4\\urdf\\moon_dog_v4.urdf --output=D:\\moon_dog_v4\\urdf  --disable-mesh-optimization

[]是argument,可选参数:

-h, --help: Show the help message and exit.
–input=INPUT: Specifies the URDF file to convert.
–output=OUTPUT: If set, specifies the path and, if ending in “.proto”, name of the resulting PROTO file. The filename minus the .proto extension will be the robot name (for PROTO conversion only).
–robot-name: Specify the name of the robot and generate a Robot node string instead of a PROTO file (has to be unique).
–normal: If set, the normals are exported if present in the URDF definition.
–box-collision: If set, the bounding objects are approximated using boxes.
–tool-slot=LinkName: Specify the link that you want to add a tool slot to (exact link name from URDF, for PROTO conversion only).
–translation=“0 0 0”: Set the translation field of the PROTO file or Webots Robot node string.
–rotation=“0 0 1 0”: Set the rotation field of the PROTO file or Webots Robot node string.
–init-pos=JointPositions: Set the initial positions of your robot joints. Example: --init-pos=“[1.2, 0.5, -1.5]” would set the first 3 joints of your robot to the specified values, and leave the rest with their default value.
–link-to-def: Creates a DEF with the link name for each solid to be able to access it using getFromProtoDef(defName) (for PROTO conversion only).
–joint-to-def: Creates a DEF with the joint name for each joint to be able to access it using getFromProtoDef(defName) (for PROTO conversion only).
–relative-path-prefix: If --input is not set, the relative paths in your URDF file sent through stdin will use this prefix. For example: filename=“head.obj” with --relative-path-prefix=“/home/user/myRobot/” will become filename=“/home/user/myRobot/head.obj”.

需要加上output就会生成proto文件,其他的[]选项里面可以不用
————————————————
版权声明:本文为CSDN博主「逆风的少年」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_45125306/article/details/118641926

 终端画面:

 也有其他转换方法,可以自行搜索。

 3. proto导入webots

把刚才生成的proto文件复制到某一个世界的目录下,如\xx机器人\WebotsWorlds\protos

在webots中的左边一列任意node上右键>新增/add new>proto nodes(current world)就可以看到导入的机器人了。

  • 16
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值