【wiki原文请看这里】
描述:此教程协助你在你的电脑上安装ROS并配置ROS环境
教程等级:初级
下一个教程:浏览ROS文件系统
目录
1.安装ROS
2.管理你的环境
3.创建一个ROS工作区
1.安装ROS
在开始此教程之前,请按照“ROS安装指导”中的描述完成ROS安装。(译者备注:arm平台安装请看这里,译者的arm板是英伟达Jetson TK1)
注意:如果你通过“apt”之类的包管理工具安装ROS,那么这些包将是不可写的,并且用户无法修改。当用户使用从源下载的ROS包或者新建一个ROS包,必须是在用户可以操作的目录内,比如“/home”目录。
2.管理你的ROS环境
在安装ROS的时候,你会被提示用“source”命令操作几个setup.*sh文件中的一个,或者是添加这些“sourcing”到你的shell启动脚本中。这么做的原因是ROS依赖于 通过shell环境联合起来的空间( This is required because ROS relies on the notion of combining spaces using the shell environment.)。这使得在开发时against不同版本的ROS或不同设置的ROS包 更容易。
如果你在查找或使用ROS包的时候遇到了问题,请确认你已经正确设置你的环境。检查的一个方法是 确认环境变量比如ROS_ROOT/ROS_PACKAGE_PATH被设置:
<pre style="box-sizing: border-box; font-family: courier, monospace; font-size: 13px; white-space: pre-wrap; padding: 5pt; margin-top: 0px; margin-bottom: 10px; line-height: 1.428571429; color: rgb(51, 51, 51); word-break: break-all; word-wrap: break-word; background-color: rgb(243, 245, 247); border: 1pt solid rgb(174, 189, 204); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px;">$ printenv | grep ROS
如果它们未被设置,那么你可能需要用“source”一些setiup.*sh文件。
Environment setup files are generated for you, but can come from different places:
- ROS packages installed with package managers provide setup.*sh files
-
rosbuild workspaces provide setup.*sh files using tools like rosws
-
Setup.*sh files are created as a by-product of building or installing catkin packages
<pre style="box-sizing: border-box; font-family: courier, monospace; font-size: 13px; white-space: pre-wrap; padding: 5pt; margin-top: 0px; margin-bottom: 10px; line-height: 1.428571429; color: rgb(51, 51, 51); word-break: break-all; word-wrap: break-word; background-color: rgb(243, 245, 247); border: 1pt solid rgb(174, 189, 204); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px;">$ source /opt/ros/<distro>/setup.bash
<pre style="box-sizing: border-box; font-family: courier, monospace; font-size: 13px; white-space: pre-wrap; padding: 5pt; margin-top: 0px; margin-bottom: 10px; line-height: 1.428571429; color: rgb(51, 51, 51); word-break: break-all; word-wrap: break-word; background-color: rgb(243, 245, 247); border: 1pt solid rgb(174, 189, 204); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px;">$ source /opt/ros/kinetic/setup.bash
你需要在你打开的每个shell中运行这句命令行来获得使用ROS commands的权利,除非你把这句命令行添加到.bashrc。这么处理(译者注:在每个shell中运行不同的source命令)允许你在同一台电脑上安装几个不同的ROS发行版本并且随时在它们之中切换。
</pre><pre style="box-sizing: border-box; font-family: courier, monospace; font-size: 13px; white-space: pre-wrap; padding: 5pt; margin-top: 0px; margin-bottom: 10px; line-height: 1.428571429; color: rgb(51, 51, 51); word-break: break-all; word-wrap: break-word; background-color: rgb(243, 245, 247); border: 1pt solid rgb(174, 189, 204); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px;">$ mkdir -p ~/catkin_ws/src
<span class="anchor" id="ROS.2BAC8-Tutorials.2BAC8-catkin.2BAC8-CreateWorkspace.line-2-1" style="box-sizing: border-box;"></span>$ cd ~/catkin_ws/src
<span class="anchor" id="ROS.2BAC8-Tutorials.2BAC8-catkin.2BAC8-CreateWorkspace.line-3-1" style="box-sizing: border-box;"></span>$ catkin_init_workspace
</pre>尽管工作区是空的(在“src”文件夹中没有包,只有一个CMakeLists.txt)你仍然可以build这个工作区。</div><div><pre name="code" class="html">
$ cd ~/catkin_ws/ $ catkin_make
</pre></div>当使用catkin工作区时,catkin_make命令很方便。如果这时候你查看你的当前目录,现在应该有“build”、“devel”文件夹。在“devel”文件夹中你可以看到几个setup.*sh文件。source它们中的任何一个都会把这个工作区路径写到你的环境列表顶部。查看通用catkin文档:<a target=_blank href="http://wiki.ros.org/catkin" target="_blank">catkin</a>来了解更多相关信息。在你source你的心setup.*sh文件之前:</p><p><pre style="box-sizing: border-box; font-family: courier, monospace; font-size: 13px; white-space: pre-wrap; padding: 5pt; margin-top: 0px; margin-bottom: 10px; line-height: 1.428571429; color: rgb(51, 51, 51); word-break: break-all; word-wrap: break-word; background-color: rgb(243, 245, 247); border: 1pt solid rgb(174, 189, 204); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px;">$ source devel/setup.bash
确保你的工作区被正确的写到环境列表,确保ROS_PACKAGE_PATH环境变量包含了你所在的这个目录.
<pre style="box-sizing: border-box; font-family: courier, monospace; font-size: 13px; white-space: pre-wrap; padding: 5pt; margin-top: 0px; margin-bottom: 10px; line-height: 1.428571429; color: rgb(51, 51, 51); word-break: break-all; word-wrap: break-word; background-color: rgb(243, 245, 247); border: 1pt solid rgb(174, 189, 204); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px;">$ echo $ROS_PACKAGE_PATH
<span class="anchor" id="ROS.2BAC8-Tutorials.2BAC8-catkin.2BAC8-CreateWorkspace.line-2-3" style="box-sizing: border-box;"></span>/home/youruser/catkin_ws/src:/opt/ros/kinetic/share:/opt/ros/kinetic/stacks
现在你的环境已经设置好,继续下一个教程:
浏览ROS文件系统。