ros2:not found install/setup.bash

本文讲述了如何在Ubuntu22.04LTS上使用ROS2Humble版本创建工作空间,包括mkdir、cd、colconbuild等步骤,遇到的问题是缺少setup.bash,解决方案是使用local_setup.sh代替。作者提醒读者注意环境变量的配置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

最近学习ros2,按照以下步骤创建工作空间

mkdir -p ws00_helloworld/src #创建工作空间以及子级目录 src,工作空间名称可以自定义
cd ws00_helloworld #进入工作空间
colcon build #编译
终端下,进入ws00_helloworld/src目录,使用如下指令创建一个C++功能包:

ros2 pkg create pkg01_helloworld_cpp --build-type ament_cmake --dependencies rclcpp --node-name helloworld
终端下进入到工作空间,执行如下指令:

colcon build
. install/setup.bash
ros2 run pkg01_helloworld_cpp helloworld
程序执行,正常情况下,应该在终端下将输出文本:"hello world!"。 

但是,运行后报错,没有setup.bash

 以下是我创建的工作空间的install文件夹(编译后)

 以下是教程创建工作空间后的install文件夹

 发现缺少了很多东西,

解决方法就是,我的ubuntu版本是22.04LTS,ros2 版本是humble.

指令应该用:

. install/local_setup.bash

就是setup.bash改为local_setup.sh

该步操作作用为刷新一遍环境变量

先暂时这么写,等到笔者学习深入了再加补充,欢迎大家评论区交流

--------------------------

ubuntu版本是22.04LTS,ros2 版本是humble.配置环境变量用以下方式:

$ source install/local_setup.sh # 仅在当前终端生效 $ echo " source ~/dev_ws/install/local_setup.sh" >> ~/.bashrc # 所有终端均生效

 

bash: /home/ros/catkin_ws/devel/setup.bash: 没有那个文件或目录 bash: /home/ros/catkin_ws/devel/setup.bash: 没有那个文件或目录 ros@ros-virtual-machine:~$ mkdir -p catkin_ws/src ros@ros-virtual-machine:~$ cd catkin_ws/src ros@ros-virtual-machine:~/catkin_ws/src$ catkin_create_pkg learn_topic std_msgs rospy roscpp Created file learn_topic/package.xml Created file learn_topic/CMakeLists.txt Created folder learn_topic/include/learn_topic Created folder learn_topic/src Successfully created files in /home/ros/catkin_ws/src/learn_topic. Please adjust the values in package.xml. ros@ros-virtual-machine:~/catkin_ws/src$ cd .. ros@ros-virtual-machine:~/catkin_ws$ catkin_make Base path: /home/ros/catkin_ws Source space: /home/ros/catkin_ws/src Build space: /home/ros/catkin_ws/build Devel space: /home/ros/catkin_ws/devel Install space: /home/ros/catkin_ws/install Creating symlink "/home/ros/catkin_ws/src/CMakeLists.txt" pointing to "/opt/ros/noetic/share/catkin/cmake/toplevel.cmake" #### #### Running command: "cmake /home/ros/catkin_ws/src -DCATKIN_DEVEL_PREFIX=/home/ros/catkin_ws/devel -DCMAKE_INSTALL_PREFIX=/home/ros/catkin_ws/install -G Unix Makefiles" in "/home/ros/catkin_ws/build" #### -- The C compiler identification is GNU 9.4.0 -- The CXX compiler identification is GNU 9.4.0 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Using CATKIN_DEVEL_PREFIX: /home/ros/catkin_ws/devel -- Using CMAKE_PREFIX_PATH: /opt/ros/noetic -- This workspace overlays: /opt/ros/noetic -- Found PythonInterp: /usr/bin/python3 (found suitable version "3.8.10", minimum re
最新发布
03-26
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值