当前位置:网站首页>是使用local_setup.bash 还是 setup.bash
是使用local_setup.bash 还是 setup.bash
2022-06-28 23:17:00 【首飞爱玩机器人】
编译完ros2程序后,我们会发现install目录下有两个脚本local_setup.bash 和 setup.bash。执行程序前,通常需要source一下install目录下的脚本,以便环境变量准备就绪。这样ros2 run和ros2 launch就能找到对应的执行文件和依赖。
下面的内容是从setup.bash中截取出来的一段。可以发现它会先source 一下/opt/ros/galactic目录再source 一下/home/ubuntu/turtlebot3_ws/install目录,最后再source一下当前目录。这样就会把外部的多个工作空间囊括进来。如果多个工作空间中有相同名字的功能包可能就会互相冲突。
# source chained prefixes
# setting COLCON_CURRENT_PREFIX avoids determining the prefix in the sourced script
COLCON_CURRENT_PREFIX="/opt/ros/galactic"
_colcon_prefix_chain_bash_source_script "$COLCON_CURRENT_PREFIX/local_setup.bash"
# setting COLCON_CURRENT_PREFIX avoids determining the prefix in the sourced script
COLCON_CURRENT_PREFIX="/home/ubuntu/turtlebot3_ws/install"
_colcon_prefix_chain_bash_source_script "$COLCON_CURRENT_PREFIX/local_setup.bash"
# source this prefix
# setting COLCON_CURRENT_PREFIX avoids determining the prefix in the sourced script
COLCON_CURRENT_PREFIX="$(builtin cd "`dirname "${
BASH_SOURCE[0]}"`" > /dev/null && pwd)"
_colcon_prefix_chain_bash_source_script "$COLCON_CURRENT_PREFIX/local_setup.bash"
unset COLCON_CURRENT_PREFIX
unset _colcon_prefix_chain_bash_source_script
而local_setup.bash只会source脚本所在目录。这样只会查找当前install目录下的执行文件和依赖。
所以如果系统里有多个ROS工作空间,谨慎一点的方法是:
1、先source一下/opt/ros/galactic/local_setup.bash
2、在source一下某个用户的工作空间。
如果系统里就一个自己建的用户工作空间。那就直接source用户工作空间中install目录下的setup.bash。一切都搞定了。
它会帮你先source一下/opt/ros/galactic/local_setup.bash,这样就有系统的安装的ros执行程序和依赖了。然后再帮你source本用户空间的install/local_setup.bash。
参考:
https://colcon.readthedocs.io/en/released/developer/environment.html#workspace-level
觉得有用就点赞吧!
我是首飞,一个帮大家填坑的机器人开发攻城狮。
另外在公众号《首飞》内回复“机器人”获取精心推荐的C/C++,Python,Docker,Qt,ROS1/2等机器人行业常用技术资料。
边栏推荐
- Complex nested object pool (4) -- manage the object pool of multi class instances and multi-stage instances
- Non scientific class! The road of self-study!
- CPU、GPU、TPU、NPU区别
- Lecun predicts AgI: big model and reinforcement learning are both ramps! My world model is the new way
- 一张能卖上千万,商家扩张比玩家还快:球星卡的江湖你不懂
- 第四章 存储器管理练习
- 网上注册股票开户很困难么?在线开户是安全么?
- Mono's execution process
- Prometeus 2.36.0 新特性
- See fengzhixia | FENGZikai, the originator of Guoman, for exclusive sale of Digital Collections
猜你喜欢
随机推荐
没找到实习,他总结了这些
Is it safe and reliable for changtou school to help open a securities account? How to drive
一文搞懂shell脚本
MATLAB 学习笔记(6)MATLAB 的 upsample 函数和 downsample 函数
frameworks/base/core/res/res/values/symbols.xml:3915: error: no definition for declared symbol解决办法
Leetcode detailed explanation of stack type
长投学堂帮忙开证券账户是安全靠谱的吗?个人如何开
大三,不简单啊!
Tanghongbin, Yaya live CTO: to truly localize, the product should not have the attribute of "origin"
【狀態機設計】Moore、Mealy狀態機、三段式、二段式、一段式狀態機書寫規範
Undefined symbol main (referred from entry9a.o).
全面掌握const的用法《一》
[matlab] function definition and use
在长投学堂开通证券账户是安全可靠的吗?
LeCun预言AGI:大模型和强化学习都是斜道!我的世界模型才是新路
Online linear programming: Dual convergence, new algorithms, and regret bounds
IDC: Alibaba cloud ranks first in the market share of China's data governance platform in 2021
Is it difficult to register stocks and open accounts online? Is it safe to open an account online?
Is it safe to open a stock account online?
Production environment sonarqube installation



![[API packet capturing in selenium automation] installation and configuration of browsermobproxy](/img/67/3e15b2191ee23a8c4453aad007651d.png)





![[matlab]函数定义与使用](/img/43/a7970ca8e075151277f7773434f7db.png)