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

ROSCD goes to wrong workspace - ROS Melodic

asked 2020-11-28 15:07:25 -0500

liamr0y gravatar image

updated 2020-11-30 02:33:00 -0500

gvdhoorn gravatar image

At present, I have two ROS workspaces on my Ubuntu 18.04 system.

One is the root, located at: /opt/ros/melodic

The other is the workspace I actually use for my projects, located at: ~/catkinws_melodic

Whenever I use roscd, it brings me to the first workspace (/opt/ros/melodic), and I can only get to the second workspace ~/catkinws_melodic if I specify a package along with roscd (ex. roscd tbot brings me to ~/catkinws_melodic/src/tbot)

Is there a way to make roscd by itself bring me to the workspace I use regularly, rather than the one located in the /opt directory?

In my .bashrc I have these two lines:

source /opt/ros/melodic/setup.bash
source /home/parallels/catkinws_melodic/devel/setup.bash

Also, here are my present environment variables:

ROS_ETC_DIR=/opt/ros/melodic/etc/ros
ROS_ROOT=/opt/ros/melodic/share/ros
ROS_MASTER_URI=http://localhost:11311  
ROS_VERSION=1
ROS_PYTHON_VERSION=2
ROS_PACKAGE_PATH=/opt/ros/melodic/share:/home/parallels/catkinws_melodic/
ROSLISP_PACKAGE_DIRECTORIES=
ROS_DISTRO=melodic

Thanks for the help!!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-11-30 02:28:34 -0500

mgruhler gravatar image

updated 2020-11-30 04:23:38 -0500

The issue is with your ROS_PACKAGE_PATH. roscd brings you to the first workspace on the path. So they should be the other way around on you package path.

I highly discourage from manually fiddling with the ROS_PACKAGE_PATH variable (if you've done that or plan on doing that). Also note that you don't need to have multiple source statements for workspaces in your .bashrc. With catkin, the last setting wins.

I suggest you

  1. clean your workspace (i.e. remove build, devel and logs folder, if they exist; if you've built with catkin-tools, you can use the catkin clean command)
  2. clean the bashrc (i.e. remove all source commands that source a ROS workspace)
  3. start a new terminal (without any ROS environment sourced)
  4. manually source /opt/ros/melodic/setup.bash
  5. build your workspace again and source the workspaces setup.bash

I'm assuming the package path is then in the correct order and your roscd should work the way you want. If you want your workspace to be automatically sourced, put only the source command of your workspace into the bashrc.

edit flag offensive delete link more

Comments

I suggest you clean your workspace, clean the bashrc [..]

These are the steps I would also take, but please add a little bit more detail: what does "clean your workspace" mean exactly? Same for .bashrc.

gvdhoorn gravatar image gvdhoorn  ( 2020-11-30 02:31:44 -0500 )edit
1

agreed and done.

mgruhler gravatar image mgruhler  ( 2020-11-30 04:23:53 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2020-11-28 15:07:25 -0500

Seen: 645 times

Last updated: Nov 30 '20