ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

One-liner to find path to ROS stack or package

asked 2014-02-10 04:40:44 -0600

bchr gravatar image

updated 2014-02-10 04:41:36 -0600

I was wondering if there was a clean way to find the path to a given ROS stack or package from the command line on Hydro, whether it is installed or just in the ROS_PACKAGE_PATH, i.e. what is probably used by roscd or roslaunch with the $(find ros_stack) arguments.

If I try to find an uninstalled ROS stack with rospack find ros_stack, it fails, whereas rosstack find ros_stack succeeds. For now I use this trick which works for both packages and stacks, whether they are installed or just present in ROS_PACKAGE_PATH:

$ ros_stack_path=`roscd ros_stack && pwd && cd - &>/dev/null`

Is there a better one-liner for this?

I also noticed something surprising. If I try both rospack and rosstack on a metapackage (e.g. navigation):

$ rospack  find navigation             ---> fails
$ rosstack find navigation             ---> succeeds

Is that the expected behavior?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2014-02-10 08:56:17 -0600

Ed Venator gravatar image
rosstack find pkg_name 2>/dev/null || rospack find pkg_name

This can also be defined as a Bash function

rosstack_pack(){
  rosstack $@ 2>/dev/null || rospack $@
}

and used like

rosstack_pack find pkg_name

Further magic would be required for autocompletion to work.

edit flag offensive delete link more

Comments

I guess this is the most direct way to go. Thanks!

bchr gravatar image bchr  ( 2014-02-11 04:23:07 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2014-02-10 04:40:44 -0600

Seen: 449 times

Last updated: Feb 10 '14