代码在交叉的多个ROS包之间展开,带有命令行的导航工具如ls cd 可能是非常冗余的,这就是为什么ROS提供工具来帮助我们。
rospack的使用
rospack让你能够获取包的信息,在这个教程中,我们仅仅涉及find 选项,它将返回包的路径。
用法:
# rospack find [包名称]
Example:
$ rospack find roscpp
返回:
如果你是采用apt 方式安装的系统,你们结果返回:
indigo:版本号
duan@duan-virtual-machine:~/catkin_ws/devel$ rospack find roscpp
/opt/ros/hydro/share/roscpp
-----------------------------------------------------------------------------
roscd使用
ros是rosbash 集的一部分,他允许你直接切换目录到包中。
用法:
# roscd [locationname[/subdir]]
Run this example:
$ roscd roscpp
用pwd显示当前所在文件夹子
$ pwd
你会看到:
备注: roscd像其它的ROS工具一样,他仅发现ROS包在ROS_PACKAGE_PATH内,通过echo $ROS_PACKAGE_PATH察看ROS 目录,
$ echo $ROS_PACKAGE_PATH
结果如下,目录之间用;号隔开。
/opt/ros/indigo/base/install/share:/opt/ros/indigo/base/install/stacks
Subdirectories
roscd 能够移动到一个包的子目录
$ roscd roscpp/cmake
$ pwd
结果:
roscd log
roscd log将带你到ROS储存log的文件夹,如果你没有运行过任何ROS程序,他将产生错误,因为log不存在
$ roscd log
Using rosls
rosls 直接进入包中,并列出文件名称。
# rosls [locationname[/subdir]]
$ rosls roscpp_tutorials
TAB /符号
它将冗长的打印处整个包的名字。
I
# roscd roscpp_tut 按下TAB
After pushing the TAB key, the command line should fill out the rest:
$ roscd roscpp_tutorials/
按键联想
# roscd tur<<< now push the TAB key >>>
$ roscd turtle
$ roscd turtle
# roscd turtles<<< now push the TAB key >>>
$ roscd turtlesim/
回顾:
观察前文ROS的命名风格
- rospack = ros + pack(age)
- roscd = ros + cd
- rosls = ros + ls
This naming pattern holds for many of the ROS tools.