一、SolidWorks模型转URDF文件

1. 下载并安装sw2urdf插件

插件介绍:http://wiki.ros.org/sw_urdf_exporter
插件:https://github.com/ros/solidworks_urdf_exporter/releases (注意安装对应SolidWorks版本的插件)
插件安装
1)下载exe文件双击安装;
2)SolidWorks软件主页 - 工具 - 插件 - 勾选 SW2URDF
3)打开SolidWorks模型 - 工具 - file - Export as URDF

2. 建立旋转轴和参考坐标系

根据构建机器人的需求,在需要添加驱动的位置构建机器人关机的参考坐标系和旋转轴(机械臂可以参考DH方法构建)。
注意:这里的旋转轴和坐标系只要方向对即可(旋转轴同轴,坐标系Z轴方向是对的),无需特别精细。

3.生成URDF文件

3.1 添加运动副

1)初始只有 base_link;
2)点击 base_link ,可以改动连杆的名字,参考坐标系,添加连杆零件(即相对于基坐标固定的零件),添加子连杆;
3)点击构建的子连杆,可以改动连杆的名字,运动副的名字(即joint),参考坐标系,旋转轴,设置运动副类型(continuous电机可无限旋转;revolute舵机可加限位;prismatic移动电机,fixed固定),添加连杆零件(即相对于此坐标固定的零件),添加子连杆。

3.2 生成urdf配置文件

1)点击 Preview and Export 进入配置界面;
2)确定关节属性,可以在此步骤进行改动,点击next;
3)确定连杆属性,包括惯性矩,可视化和碰撞体属性(确认加载即可,不需要改动);
4)点击 Export URDF and Meshes;
5)将生成的文件拷到相应的系统中。

3.3 显示URDF文件

在Ubuntu系统中,可以直接 launch 生成的功能包中的 display.launch 文件。

可能存在问题:
1)机器人整体散架:
可能原因:SolidWorks2018 中的模型不能相同,不只是名字,模型也要有差别(虽然很扯,但模型更改后就没问题了)。

二、URDF转PROTO文件

1. 安装 urdf2webots 插件

官网:https://pypi.org/project/urdf2webots/2.0.3/
GitHub:https://github.com/cyberbotics/urdf2webots

具体安装说明,推荐看官网
注意:不同版本的 Webots 对应不同版本的插件

安装方法1: pip (推荐)

# 最新版本插件
pip install urdf2webots
# 相应版本的插件,经测试 Webots2020a可用; 可能需要使用不同的 pip 版本,如 pip3
pip install urdf2webots==1.0.9

安装方法2: sources

# 最新版本插件,相应版本的插件可以在 releases 中查找
git clone https://github.com/cyberbotics/urdf2webots.git
cd urdf2webots
pip install -r requirements.txt

2. 使用urdf2webots 插件

参考:官网

使用方法1:(推荐)

# 可能需要使用不同的 python 版本,如 python3.5 - m
python -m urdf2webots.importer --input=someRobot.urdf [--output=outputFile] [--normal] [--box-collision] [--tool-slot=linkName] [--help]

使用方法2:

# 可能需要使用不同的 python 版本,如 python3.5
python
>> from urdf2webots.importer import convertUrdfFile
>> convertUrdfFile(input = 'MY_PATH/MY_URDF.urdf')

可能存在问题:
1)AttributeError: ‘_NamespacePath’ object has no attribute ‘sort’
解决方法:

pip3 install --upgrade pip
pip3 install --upgrade setuptools

3. 导入 proto 文件

1)将生成的 proto 文件放入对应世界的 proto 文件件中;
2)Webots软件主页 - 点击新增 - 添加 PROTO nodes (Current Project)。

三、Webots机器人控制器添加

向导 - 新增机器人控制器 - C++/Python - 确定控制器名称 - 完成。
四轮车控制器:

// File:          car_controller.cpp
// Date:
// Description:
// Author: summer
// Modifications:// You may need to add webots include files such as
// <webots/DistanceSensor.hpp>, <webots/Motor.hpp>, etc.
// and/or to add some other includes
#include <webots/Robot.hpp>
#include <webots/Motor.hpp>
// All the webots classes are defined in the "webots" namespace
using namespace webots;// This is the main program of your controller.
// It creates an instance of your Robot instance, launches its
// function(s) and destroys it at the end of the execution.
// Note that only one instance of Robot should be created in
// a controller program.
// The arguments of the main function can be specified by the
// "controllerArgs" field of the Robot node
int main(int argc, char **argv) {// create the Robot instance.Robot *robot = new Robot();// get the time step of the current world.int timeStep = (int)robot->getBasicTimeStep();// You should insert a getDevice-like function in order to get the// instance of a device of the robot. Something like:Motor *motor1 = robot->getMotor("left_wheel_j1");Motor *motor2 = robot->getMotor("left_wheel_j2");Motor *motor3 = robot->getMotor("right_wheel_j1");Motor *motor4 = robot->getMotor("right_wheel_j2");//  DistanceSensor *ds = robot->getDistanceSensor("dsname");//  ds->enable(timeStep);// Main loop:// - perform simulation steps until Webots is stopping the controllerwhile (robot->step(timeStep) != -1) {// Read the sensors:// Enter here functions to read sensor data, like://  double val = ds->getValue();// Process sensor data here.// Enter here functions to send actuator commands, like:// forword// motor1->setPosition(-100.0);// motor2->setPosition(-100.0);// motor3->setPosition(100.0);// motor4->setPosition(100.0);// backmotor1->setPosition(35.0);motor2->setPosition(35.0);motor3->setPosition(-35.0);motor4->setPosition(-35.0);motor1->setVelocity(1.5);motor2->setVelocity(1.5);motor3->setVelocity(1.5);motor4->setVelocity(1.5);};// Enter here exit cleanup code.delete robot;return 0;
}

四、添加 ROS 控制器

本文参考文档均以超链接形式在文中给出。
以上内容根据自己理解和实践所写,如有错误,请批评指正。

Ubuntu系统中Webot机器人配置相关推荐

  1. 在RedHat Linux系统中安装和配置snmp服务

    在RedHat Linux系统中安装和配置snmp服务 检查系统是否安装snmp服务 # rpm -qa|grep snmp net-snmp-5.3.2.2-17.el5 net-snmp-perl ...

  2. Windows共享Linux打印机,在Ubuntu系统中使用局域网内Windows共享打印机的方法

    最近有一台HP打印机要使用,它连接一台Windows 7电脑,作为共享的打印机,然后我在Ubuntu系统中配置局域网内Windows共享打印机,阅读了很多教程才成功连接打印机,现在把方法分享出来.可以 ...

  3. PPA 完全指南,如何在 Ubuntu 系统中使用 PPA

    如果你在使用 Ubuntu 系统,或其它衍生版本,如 Linux Mint.Linux Lite 或者 Zorin OS 等,可能会遇到添加使用 PPA 的情况.那什么是 PPA?为什么要使用 PPA ...

  4. 服务器重装Ubuntu系统+深度学习环境配置

    服务器重装Ubuntu系统+深度学习环境配置 2020年12月14日(勉强成功 最后并不是按照下面这样一步步安装的(可能是由于服务器的硬件问题),而是直接安装CUDA,在安装过程中会提示是否安装nvi ...

  5. (八)在ECS实例的Ubuntu系统中安装Hadoop

    在阿里云ECS的Ubuntu系统中安装Hadoop,和在本地电脑安装Hadoop,基本相似,但是,也有略微差别,必须正确配置,否则,会导致无法顺利启动.安装Hadoop之前,请确保已经根据前面的博客& ...

  6. GPT问答:在Ubuntu系统中,利用QtCreator的QSqlQuery语句,连接到其他目录的mission_history.db数据库,并将其中的名为 mission 表单,以xls格式导出

    问题原文: 麻烦实现一下,在Ubuntu系统中,利用QtCreator的 QSqlQuery语句,连接到其他目录的mission_history.db 数据库,并将其中的名为 mission 表单,以 ...

  7. 在ubuntu系统中搭建笔记文档(typora+Picgo+Gitee)(全程记录)

    在ubuntu系统中搭建笔记文档(typora+Picgo+Gitee)(全程记录) 系统配置:ubuntu18.04 1.安装typora typora官网 Typora常用快捷键(翻译) 命令行中 ...

  8. 在ubuntu系统中使用dpkg命令安装后缀名为deb的软件包

    在ubuntu系统中使用dpkg命令安装后缀名为deb的软件包: dpkg命令常用格式如下: #查看文件结构(其中-c等价于--contents) sudo dpkg -c xx.deb #安装软件包 ...

  9. Linux系统中FTP的配置(图文详解-全)

    Linux系统中FTP的配置 二.    把安全级别调低           #vi /etc/selinux/config           注意:在RHEL4三.FTP软件包 #mount /d ...

最新文章

  1. 2022-2028年中国餐具行业市场研究及前瞻分析报告
  2. 在Visual Studio中使用命令行参数进行调试
  3. PelleeNet_SSD
  4. 升职加薪必看!如何试出一个Java开发者真正的水平
  5. virtualbox 创建桥接网络_VirtualBox 桥接上网方式的配置
  6. linux 卸载skype,如何将Skype与Ubuntu Unity集成 | MOS86
  7. summit_Chrome Dev Summit 2018的亮点
  8. lnmp mysql 远程访问_LNMP环境下 远程连接mysql数据库
  9. Visual Studio 2010 美女与程序员的爱情网剧+《耀和你一起》壁纸包
  10. Bailian2981 大整数加法【大数】(POJ NOI0106-10)
  11. ZipEntry的使用
  12. 激光条纹中心提取——灰度重心法
  13. c++实现LSTM,ADAM优化,预测大写数字
  14. 英文标题首字母大写规则
  15. 一些javascript内容
  16. python 爬取贝壳网小区名称_用Python爬取贝壳网新房和二手房数据
  17. ppt给图片增加高斯模糊_PPT图片处理小技巧
  18. matlab之矩阵输入(一)
  19. 实例比较单精度浮点型,双精度浮点型运算结果精度
  20. android 手机分区失败怎么办,一种Android系统Data分区自修复方法及系统专利_专利查询 - 天眼查...

热门文章

  1. 高效管理笔记,选择IHome在线笔记
  2. 使用快客引流脚本,你不得不知的引流脚本相关知识
  3. Linux日志服务器_ELK搭建
  4. 大马小马问题就看这一篇
  5. Ajax实现无刷新分页效果
  6. vue 项目放弃“tui-editor“:“1.3.3“,
  7. Ubuntu 用户切换
  8. pywinauto桌面自动化
  9. python手机app开发_利用python开发app实战的方法
  10. 大象转身牵一发动全身,阿里推猫享不仅仅对标京东