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

How to make roscd go to ~/catkin_ws/devel instead of /opt/ros/kinetic?

asked 2018-03-28 07:30:29 -0600

hc gravatar image

updated 2018-08-08 03:08:34 -0600

jayess gravatar image

I have sourced the setup.bash in the devel folder of catkin_ws but still the roscd command takes to /opt/ros/kinetic

On env | grep ROS, the output is:

ROS_ROOT=/opt/ros/kinetic/
ROS_PACKAGE_PATH=/home/username/catkin_ws/src:/opt/ros/kinetic/share
ROS_MASTER_URI=http://localhost:11311
ROS_VERSION=1
ROS_HOSTNAME=localhost
ROSLISP_PACKAGE_DIRECTORIES=
ROS_DISTRO=kinetic
ROS_ETC_DIR=/opt/ros/kinetic/etc/ros
edit retag flag offensive close merge delete

Comments

Just to make sure: did you only add the source /home/username/catkin_ws/devel/setup.bash line to your .bashrc, or did you actually source setup.bash/open up a new terminal after adding the line?

Tim Stadtmann gravatar image Tim Stadtmann  ( 2018-03-28 08:15:09 -0600 )edit

I added it to .bashrc as well. And then sourced it through terminal also.

hc gravatar image hc  ( 2018-03-28 09:10:47 -0600 )edit

source /opt/ros/kinetic/setup.bash source ~/catkin_ws/devel/setup.bash export ROS_HOSTNAME=localhost export ROS_MASTER_URI=http://localhost:11311 export ROS_ROOT=/opt/ros/kinetic/ export ROS_PACKAGE_PATH=/home/username/catkin_ws/src:${ROS_PACKAGE_PATH}

hc gravatar image hc  ( 2018-03-28 09:11:31 -0600 )edit

4 Answers

Sort by ยป oldest newest most voted
2

answered 2020-02-03 23:39:43 -0600

jayess gravatar image

updated 2020-02-07 20:29:48 -0600

So, after reading @SimonDahrs's answer, I checked the source (sorry, couldn't find it in the docs) out and saw that roscd checks two different environment variables: ROS_WORKSPACE and CMAKE_PREFIX_PATH. (Unless I'm missing something, this is basically how it works.) First, roscd checks if ROS_WORKSPACE is set and cds to that location if it is set and returns. If ROS_WORKSPACE isn't set, it checks if CMAKE_PREFIX_PATH is set and iterates through each path and the first path that contains a .catkin directory is cded to. What does this mean?

Each time you source a ROS setup.bash (or equivalent) the CMAKE_PREFIX_PATH is changed and to be the workspace that the setup.bash file resides in. So, if you want to the default path of roscd either set ROS_WORKSPACE to your desired path, or source the setup.bash file from the workspace that you want to have as the default path.

edit flag offensive delete link more
3

answered 2018-08-08 02:01:07 -0600

tfoote gravatar image

Without any arguments it goes to the ROS_ROOT by default. There's no way to override that. If you roscd <PACKAGE_NAME> for some <PACKAGE_NAME> in your workspace it should take you to the package's directory.

edit flag offensive delete link more
1

answered 2019-08-16 02:54:57 -0600

tropic gravatar image

Mine did the same for a fresh Melodic installation. The thing is that if you try to use roscd on the newly instantiated catkin_ws with no packages, then it will go to /opt/ros/melodic. If you add a package to src/ and build the workspace, then roscd should take you to ~/catkin_ws/devel/ afterwards.

edit flag offensive delete link more
0

answered 2020-02-03 05:10:10 -0600

SimonDahrs gravatar image

I encountered this problem, and the other two answers are not correct in my opinion. If you take a look at this tutortial on how to create a workspace: http://wiki.ros.org/catkin/Tutorials/..., you see that there is a step after calling catkin_make, that is: $ source devel/setup.bash. If you call that from within your created workspace, you'll see that roscd will take you to that workspace.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2018-03-28 07:30:29 -0600

Seen: 2,080 times

Last updated: Feb 07 '20