首页 > 解决方案 > 在 Ubuntu 20.04 中找不到 ROS 包

问题描述

我想在我的 Ubuntu 20.04 机器上尝试 ROS,并按照 ROS 网站中给出的说明安装了 ROS 包,但是在成功安装后,roscd 失败并找不到命令:

joesan@joesan-InfinityBook-S-14-v5:/opt/ros/noetic$ roscd
bash: roscd: command not found
joesan@joesan-InfinityBook-S-14-v5:/opt/ros/noetic$ 

这是 noetic 文件夹中的内容:

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$ 

如您所见,我的 .bashrc 中也有这一行:

# Source the ROS setup profile
source /opt/ros/noetic/setup.bash

任何想法为什么我无法让 roscd 命令工作?我安装了完整版:

sudo apt install ros-noetic-desktop-full

有什么我想念的吗?

标签: ros

解决方案


所以最后我能够解决这个问题!我有一个 .bash_profile,其中包含所有用户特定的命令和快捷方式。在这个文件中,我还提供了其他设置文件。所以我现在所做的是从 .bashrc 中删除 ROS 的源命令并将其放入 .bash_profile 文件中,并从 .bashrc 中获取整个 .bash_profile 文件,如下所示:

if [ -f ~/.bash_profile ]; then
    . ~/.bash_profile
fi

在 .bash_profile 中,我有这样的源命令:

# Source the ROS setup profile
source /opt/ros/noetic/setup.bash

这可以帮助我修复错误!


推荐阅读