I wanted to give ROS a try on my Ubuntu 20.04 machine and I installed the ROS packages as per instructions given in the ROS website, but after successful installation, roscd fails with command not found:
joesan@joesan-InfinityBook-S-14-v5:/opt/ros/noetic$ roscd
bash: roscd: command not found
joesan@joesan-InfinityBook-S-14-v5:/opt/ros/noetic$
Here is the content inside the noetic folder:
joesan@joesan-InfinityBook-S-14-v5:~$ cd /opt/ros/noetic/
drwxr-xr-x joesan joesan 4 KB Sat Aug 29 08:46:37 2020 .
drwxr-xr-x joesan joesan 4 KB Fri Aug 28 21:18:54 2020 ..
.rw-r--r-- joesan joesan 0 B Fri Jul 24 18:47:51 2020 .catkin
.rw-r--r-- joesan joesan 55 B Fri Jul 24 18:47:51 2020 .rosinstall
.rwxr-xr-x joesan joesan 13 KB Fri Jul 24 18:47:51 2020 _setup_util.py
drwxr-xr-x joesan joesan 4 KB Fri Aug 28 21:19:38 2020 bin
.rwxr-xr-x joesan joesan 506 B Fri Jul 24 18:47:51 2020 env.sh
drwxr-xr-x joesan joesan 4 KB Fri Aug 28 21:18:54 2020 etc
drwxr-xr-x joesan joesan 4 KB Fri Aug 28 21:19:39 2020 include
drwxr-xr-x joesan joesan 12 KB Fri Aug 28 21:19:39 2020 lib
.rw-r--r-- joesan joesan 283 B Fri Jul 24 18:47:51 2020 local_setup.bash
.rw-r--r-- joesan joesan 346 B Fri Jul 24 18:47:51 2020 local_setup.sh
.rw-r--r-- joesan joesan 293 B Fri Jul 24 18:47:51 2020 local_setup.zsh
.rw-r--r-- joesan joesan 260 B Fri Jul 24 18:47:51 2020 setup.bash
.rw-r--r-- joesan joesan 2.7 KB Fri Jul 24 18:47:51 2020 setup.sh
.rw-r--r-- joesan joesan 270 B Fri Jul 24 18:47:51 2020 setup.zsh
drwxr-xr-x joesan joesan 12 KB Fri Aug 28 21:19:40 2020 share
joesan@joesan-InfinityBook-S-14-v5:/opt/ros/noetic$
As you can see I have this line in my .bashrc as well:
# Source the ROS setup profile
source /opt/ros/noetic/setup.bash
Any ideas why I could not get roscd command working? I installed the full version:
sudo apt install ros-noetic-desktop-full
Is there anything that I'm missing?
So finally I was able to get this resolved! I have a .bash_profile where I have all my user specific commands and shortcuts. In this file I also source additional setup files. So what I did now was to remove the source command for ROS from the .bashrc and put this in the .bash_profile file and source the whole .bash_profile file from within .bashrc like this:
if [ -f ~/.bash_profile ]; then
. ~/.bash_profile
fi
In the .bash_profile, I have the source command like this:
# Source the ROS setup profile
source /opt/ros/noetic/setup.bash
This help me fix the error!