ros command

1.Install ROS

2.Managing Your Environment

printenv | grep ROS

3.Create a ROS Workspace

$ mkdir -p ~/catkin_ws/src
$ cd ~/catkin_ws/
$ catkin_make

how to set new enviroment parameter:

source ~/work/catkin_ws/devel/setup.bash   

         

Filesystem Tools

Code is spread across many ROS packages. Navigating with command-line tools such as ls and cd can be very tedious which is why ROS provides tools to help you.

Using rospack

rospack allows you to get information about packages. In this tutorial, we are only going to cover the find option, which returns the path to package.

Usage:

$ rospack find [package_name]

Example:

$ rospack find roscpp

would return:

  • YOUR_INSTALL_PATH/share/roscpp

If you installed ROS Kinetic from apt on Ubuntu Linux you would see exactly:

  • /opt/ros/kinetic/share/roscpp

Using roscd

roscd is part of the rosbash suite. It allows you to change directory (cd) directly to a package or a stack.

Usage:

$ roscd <package-or-stack>[/subdir]

To verify that we have changed to the roscpp package directory, run this example:

$ roscd roscpp

Now let's print the working directory using the Unix command pwd:

$ pwd

You should see:

  • YOUR_INSTALL_PATH/share/roscpp

You can see that YOUR_INSTALL_PATH/share/roscpp is the same path that rospack find gave in the previous example.

Note that roscd, like other ROS tools, will only find ROS packages that are within the directories listed in your ROS_PACKAGE_PATH. To see what is in your ROS_PACKAGE_PATH, type:

$ echo $ROS_PACKAGE_PATH

Your ROS_PACKAGE_PATH should contain a list of directories where you have ROS packages separated by colons. A typical ROS_PACKAGE_PATH might look like this:

  • /opt/ros/kinetic/base/install/share

Similarly to other environment paths, you can add additional directories to your ROS_PACKAGE_PATH, with each path separated by a colon ':'.

Subdirectories

roscd can also move to a subdirectory of a package or stack.

Try:

$ roscd roscpp/cmake
$ pwd

You should see:

  • YOUR_INSTALL_PATH/share/roscpp/cmake

roscd log

roscd log will take you to the folder where ROS stores log files. Note that if you have not run any ROS programs yet, this will yield an error saying that it does not yet exist.

If you have run some ROS program before, try:

$ roscd log

Using rosls

rosls is part of the rosbash suite. It allows you to ls directly in a package by name rather than by absolute path.

Usage:

$ rosls <package-or-stack>[/subdir]

Example:

$ rosls roscpp_tutorials

would return:

  • cmake launch package.xml  srv

Tab Completion

It can get tedious to type out an entire package name. In the previous example, roscpp_tutorials is a fairly long name. Luckily, some ROS tools support TAB completion.

Start by typing:

$ roscd roscpp_tut<<< now push the TAB key >>>

After pushing the TAB key, the command line should fill out the rest:

$ roscd roscpp_tutorials/

This works because roscpp_tutorials is currently the only ROS package that starts with roscpp_tut.

Now try typing:

$ roscd tur<<< now push the TAB key >>>

After pushing the TAB key, the command line should fill out as much as possible:

$ roscd turtle

However, in this case there are multiple packages that begin with turtle. Try typing TAB another time. This should display all the ROS packages that begin with turtle:

  • turtle_actionlib/  turtlesim/         turtle_tf/

On the command line you should still have:

$ roscd turtle

Now type an s after turtle and then push TAB:

$ roscd turtles<<< now push the TAB key >>>

Since there is only one package that starts with turtles, you should see:

$ roscd turtlesim/

If you want to see a list of all currently installed packages, you can use tab completion for that as well:

$ rosls <<< now push the TAB key twice >>>

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值