虚拟机版本:VMware-workstation-full-15.0.0
系统环境:ubuntu16.04-4
ROS版本:kinetic
一、基础环境配置
1.使用ubuntu16.04版本的系统镜像,在Vmware上新建虚拟机,并使系统启动。设置可以参考下图。
2.为了增加安装下载速度,替换原有系统更新源为阿里云的源(先保证虚拟机ubuntu系统可正常联网)
$ sudo gedit /etc/apt/sources.list
替换为下列内容
## Note, this file is written by cloud-init on first boot of an instance
## modifications made here will not survive a re-bundle.
## if you wish to make changes you can:
## a.) add 'apt_preserve_sources_list: true' to /etc/cloud/cloud.cfg
## or do the same in user-data
## b.) add sources in /etc/apt/sources.list.d
## c.) make changes to template file /etc/cloud/templates/sources.list.tmpl
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://mirrors.aliyun.com/ubuntu/ xenial main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main
## Major bug fix updates produced after the final release of the
## distribution.
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
# deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
# deb-src http://mirrors.aliyun.com/ubuntu/ xenial multiverse
# deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
# deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
## Uncomment the following two lines to add software from the 'backports'
## repository.
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
# deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
# deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu xenial partner
# deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security universe
# deb http://mirrors.aliyun.com/ubuntu xenial-security multiverse
# deb-src http://mirrors.aliyun.com/ubuntu xenial-security multiverse
执行更新:
$ sudo apt-get update
3.选择系统设置->软件和更新->ubuntu软件允许 “restricted”、“universe” 和"multiverse"这三种安装模式。更新选项卡全部选择选项。
二、ROS环境安装
1.设置软件安装地址(这是中国区源地址,下载速度快,ROS官网默认的太慢了)
$ sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ \$DISTRIB_CODENAME main" \> /etc/apt/sources.list.d/ros-latest.list'
2.添加KEY
$ sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
3.更新源
$ sudo apt-get update
如出现下列问题
输入:
$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F42ED6FBAB17C654
再次执行:sudo apt-get update
4.安装ROS桌面完整版,执行下列命令,询问时输入Y进行安装,安装可能需要一段时间后,耐心等待。
$ sudo apt-get install ros-kinetic-desktop-full
5.初始化rosdep
在开始使用ROS之前你还需要初始化rosdep。rosdep可以方便在你需要编译某些源码的时候为其安装一些系统依赖,同时也是某些ROS核心功能组件所必需用到的工具。
$ sudo rosdep init rosdep update
6. 环境配置
如果每次打开一个新的终端时ROS环境变量都能够自动配置好(即添加到bash会话中),那将会方便很多:
$ echo “source /opt/ros/kinetic/setup.bash” >> ~/.bashrc source ~/.bashrc
7. 构建工厂依赖
到目前为止,你已经安装了运行核心ROS包所需的内容。为了创建和管理自己的ROS工作区,有各种各样的工具和需求分别分布。例如:rosinstall是一个经常使用的命令行工具,它使你能够轻松地从一个命令下载许多ROS包的源树。
要安装这个工具和其他构建ROS包的依赖项,请运行:
$ sudo apt-get install python-rosinstall python-rosinstall-generator python-wstool build-essential
三、安装moveit-core
$ sudo apt-get install ros-kinetic-moveit-core
四、安装industrial
$ sudo apt-get install ros-kinetic-industrial-core
五、下载AUBO的ROS源代码
1.在工作目录下,新建一个名称为src的文件夹(这里遇到一个坑,必须将源代码放在src目录下,这个catkin_make的编译规则有关),并进入该目录
$ mkdir -p catkin_work/src cd atkin_work/src
2.下载源代码
git clone https://github.com/lg609/aubo_robot.git
六、编译
1.退回到上一级目录,也就是catkin_work目录
cd ../
2.使用catkin_make进行编译
catkin_make
如出现以下问题
运行下面的命令
sudo apt-get install ros-\$ROS_DISTRO-moveit-visual-tools rosdep install --from-paths src --ignore-src -r -y
再次执行编译命令。
七、运行
1.进入目录src/aubo_robot/aubo_i5_moveit_config/launch
cd src/aubo_robot/aubo_i5_moveit_config/launch
2.运行命令,下面的IP地址为aubo机器人仿真软件的地址,使用之前先ping通(好像必须真实机械臂,只是仿真使用IP设为127.0.0.1)
roslaunch moveit_planning_execution.launch robot_ip:=127.0.0.1
出现下列问题
出现这个问题又是一个坑,原来ROS的工作空间不是随便建立的,必须要在~/catkin_ws/src下,有两种方法解决,一种是重新建立ROS工作空间以符合要求,第二种是将现在的工作空间加入ROS的环境变量,以下是第二种方法的步骤
$ sudo gedit ~/.bashrc
在文件末尾添加export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/你的工作空间路径/src,如下所示
再执行source命令以生效
$ source ~/.bashrc
这时候再次运行roslaunch moveit_planning_execution.launch robot_ip:=127.0.0.1可以启动rviz了,如下图所示
但是还有如下报错
关闭rviz软件界面,输入Ctrl+C结束软件,输入下列命令,即可消除这个错误(根据ROS的工作目录进行修改)
$ source \~/catkin_work/devel/setup.bash
如出现如下报错:
安装ros-kinetic-moveit
sudo apt-get install ros-kinetic-moveit
最后再次运行roslaunch moveit_planning_execution.launch robot_ip:=127.0.0.1,即可正常启动,在MotionPlaning界面下,下选择Planning标签页,设置初始姿态为现在,结束姿态为随机,并点击update。
最后执行Panning and Execute,即可看到仿真结果。