Get Workspace Path in Terminal

asked 2018-04-12 05:45:12 -0600

Felix Widmaier gravatar image

Is there an easy way to get the path to the current workspace (i.e. the directory containing src, build, devel) with a bash command?

I could somehow extract it from $ROS_PACKAGE_PATH but I am wondering if there is an easier way.

edit retag flag offensive close merge delete

Comments

1

$CMAKE_PREFIX_PATH typically contains the paths to the workspaces. Entries have devel or install suffixed though (it points to specific spaces, not the top-level workspace).

roscd (without any arg) cds into the top-level space sourced.

Not sure there is a command / tool for this.

gvdhoorn gravatar image gvdhoorn  ( 2018-04-12 05:52:03 -0600 )edit

@gvdhoorn Thanks, $CMAKE_PREFIX_PATH looks good. It still needs some processing to extract the path but at least it more deterministic than $ROS_PACKAGE_PATH.

Felix Widmaier gravatar image Felix Widmaier  ( 2018-04-12 09:51:56 -0600 )edit

Another way I have done this, albeit somewhat inelegant, is to use $(find aaa) to get an absolute path off a package and then tree down to it. $(find my_package)/../../my_file_in_workspace.

James NT gravatar image James NT  ( 2019-06-19 00:07:44 -0600 )edit