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

Revision history [back]

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 clean your workspace, clean the bashrc, start a new terminal (without any ROS environment sourced), then do manually source /opt/ros/melodic/setup.bash, build your workspace, and then 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.

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 you

  1. clean your workspace, 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, bashrc (i.e. remove all source commands that source a ROS workspace)
  3. start a new terminal (without any ROS environment sourced), then do sourced)
  4. manually source /opt/ros/melodic/setup.bash,
  5. build your workspace, workspace again and then 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.