Configuring environment||ROS2环境配置

Goal: This tutorial will show you how to prepare your ROS 2 environment.

Tutorial level: Beginner

Time: 5 minutes

ROS 2 relies on the notion (concept)of combining workspaces using the shell environment. “Workspace” is a ROS term for the location on your system where you’re developing with ROS 2. The core ROS 2 workspace is called the underlay. Subsequent local workspaces are called overlays.

我觉得他说的underlay在Ubuntu就是指”/opt/ros/版本“这个文件夹;overlay指的就是自己建立的工作空间

When developing with ROS 2, you will typically have several workspaces active concurrently.

Combining workspaces makes developing against different versions of ROS 2, or against different sets of packages, easier. It also allows the installation of several ROS 2 distributions (or “distros”, e.g. Dashing and Eloquent) on the same computer and switching between them.

因为工作空间的存在可以在同一台电脑上同时安装不同的ros版本,例如同时安装ros2和ros

This is accomplished by sourcing setup files every time you open a new shell, or by adding the source command to your shell startup script once. Without sourcing the setup files, you won’t be able to access ROS 2 commands, or find or use ROS 2 packages. In other words, you won’t be able to use ROS 2.

Prerequisites

Before starting these tutorials, install ROS 2 by following the instructions on the ROS 2 Installation page.

The commands used in this tutorial assume you followed the binary packages installation guide for your operating system (Debian packages for Linux). You can still follow along if you built from source, but the path to your setup files will likely be different. You also won’t be able to use the sudo apt install ros-<distro>-<package> command (used frequently in the beginner level tutorials) if you install from source.

If you are using Linux or macOS, but are not already familiar with the shell, this tutorial will help.

Tasks

1 Source the setup files

You will need to run this command on every new shell you open to have access to the ROS 2 commands, like so:

LinuxmacOSWindows

# Replace ".bash" with your shell if you're not using bash
# Possible values are: setup.bash, setup.sh, setup.zsh
source /opt/ros/humble/setup.bash之所以搞得这么麻烦是因为:有可能在同一台电脑上安装了不同版本的ros2版本,这样就需要使用source来指定这个命令由那个版本来处理

Copy to clipboard

Note

The exact command depends on where you installed ROS 2.(上面那个source命令的地址需要更具具体sh文件的位置调整,方正就是要执行那个setup.bash文件) If you’re having problems, ensure the file path leads to your installation.

2 Add sourcing to your shell startup script

If you don’t want to have to source the setup file every time you open a new shell (skipping task 1), then you can add the command to your shell startup script:

LinuxmacOSWindows

echo "source /opt/ros/humble/setup.bash" >> ~/.bashrc

Copy to clipboard

To undo this, locate your system’s shell startup script and remove the appended source command.

3 Check environment variables

Sourcing ROS 2 setup files will set several environment variables necessary for operating ROS 2. If you ever have problems finding or using your ROS 2 packages, make sure that your environment is properly set up using the following command:

LinuxmacOSWindows

printenv | grep -i ROS

Copy to clipboard

Check that variables like ROS_DISTRO and ROS_VERSION are set.

ROS_VERSION=2
ROS_PYTHON_VERSION=3
ROS_DISTRO=humble

Copy to clipboard

If the environment variables are not set correctly, return to the ROS 2 package installation section of the installation guide you followed. If you need more specific help (because environment setup files can come from different places), you can get answers from the community.

3.1 The ROS_DOMAIN_ID variable

See the domain ID article for details on ROS domain IDs.

Once you have determined a unique integer for your group of ROS 2 nodes, you can set the environment variable with the following command:

LinuxmacOSWindows

export ROS_DOMAIN_ID=<your_domain_id>

Copy to clipboard

To maintain this setting between shell sessions, you can add the command to your shell startup script:

echo "export ROS_DOMAIN_ID=<your_domain_id>" >> ~/.bashrc

Copy to clipboard

3.2 The ROS_LOCALHOST_ONLY variable

By default, ROS 2 communication is not limited to localhost. ROS_LOCALHOST_ONLY environment variable allows you to limit ROS 2 communication to localhost only. This means your ROS 2 system, and its topics, services, and actions will not be visible to other computers on the local network. Using ROS_LOCALHOST_ONLY is helpful in certain settings, such as classrooms, where multiple robots may publish to the same topic causing strange behaviors. You can set the environment variable with the following command:

LinuxmacOSWindows

export ROS_LOCALHOST_ONLY=1

Copy to clipboard

To maintain this setting between shell sessions, you can add the command to your shell startup script:

echo "export ROS_LOCALHOST_ONLY=1" >> ~/.bashrc

Copy to clipboard

Summary

The ROS 2 development environment needs to be correctly configured before use. This can be done in two ways: either sourcing the setup files in every new shell you open, or adding the source command to your startup script.

If you ever face any problems locating or using packages with ROS 2, the first thing you should do is check your environment variables and ensure they are set to the version and distro you intended.

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/263752.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【rabbitMQ】模拟work queue,实现单个队列绑定多个消费者

上一篇&#xff1a; springboot整合rabbitMQ模拟简单收发消息 https://blog.csdn.net/m0_67930426/article/details/134904766?spm1001.2014.3001.5502 在这篇文章的基础上进行操作 基本思路&#xff1a; 1.在rabbitMQ控制台创建一个新的队列 2.在publisher服务中定义一个…

SQL Server数据库的备份和还原

6.2 SQL Server备份和还原 数据库管理员最担心的情况就是数据库瘫痪&#xff0c;造成数据丢失&#xff0c;而备份作为数据的副本&#xff0c;可以有 效地保护和恢复数据。本节将介绍数据备份的原因&#xff0c;备份的方式.SOL Server的恢复模式.以及备 份策略和备份设备。 6.2…

有趣的数学 用示例来阐述什么是初值问题一

一、初值问题简述 在多变量微积分中&#xff0c;初值问题是一个常微分方程以及一个初始条件&#xff0c;该初始条件指定域中给定点处未知函数的值。在物理学或其他科学中对系统进行建模通常相当于解决初始值问题。 通常给定的微分方程有无数个解&#xff0c;因此我们很自然地会…

链表OJ—链表中倒数第k个节点

提示&#xff1a;文章写完后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 文章目录 前言 1、链表中倒数第k个节点题目&#xff1a; 方法讲解&#xff1a; 图文解析&#xff1a; 代码实现&#xff1a; 总结 前言 世上有两种耀眼的光芒&#xff0c;一…

【论文笔记】FSD V2: Improving Fully Sparse 3D Object Detection with Virtual Voxels

原文链接&#xff1a;https://arxiv.org/abs/2308.03755 1. 引言 完全稀疏检测器在基于激光雷达的3D目标检测中有较高的效率和有效性&#xff0c;特别是对于长距离场景而言。 但是&#xff0c;由于点云的稀疏性&#xff0c;完全稀疏检测器面临的一大困难是中心特征丢失&…

三. LiDAR和Camera融合的BEV感知算法-融合算法的基本介绍

目录 前言0. 简述1. 融合背景2. 融合思路3. 融合性能优劣总结下载链接参考 前言 自动驾驶之心推出的《国内首个BVE感知全栈系列学习教程》&#xff0c;链接。记录下个人学习笔记&#xff0c;仅供自己参考 本次课程我们来学习下课程第三章——LiDAR和Camera融合的BEV感知算法&am…

英特尔高度依赖台积电:未来2年CPU订单达140亿美元

此前我们针对英特尔/三星/台积电对2nm工艺的发展有过探讨&#xff0c;具体请参考&#xff1a; 扩展阅读&#xff1a;华山论剑&#xff1a;2nm芯片工艺谁更强&#xff1f; 其中&#xff0c;英特尔未来几年的主要目标之一是在技术领先方面击败台积电&#xff0c;并从需要前沿节…

基于java swing 药品销售管理系统

大家好&#xff0c;我是DeBug&#xff0c;很高兴你能来阅读&#xff01;作为一名热爱编程的程序员&#xff0c;我希望通过这些教学笔记与大家分享我的编程经验和知识。在这里&#xff0c;我将会结合实际项目经验&#xff0c;分享编程技巧、最佳实践以及解决问题的方法。无论你是…

TCP为什么可靠之“重传机制”

TCP重传机制 TCP针对数据包丢失的情况&#xff0c;会通过重传机制解决&#xff0c;包括像超时重传、快速重传、选择确认SACK、D-SACK 超时重传 TCP会设置一个定时器&#xff0c;如果在发送数据之后的规定时间内&#xff0c;没有收到对方的ACK报文&#xff0c;就会触发重新发…

049:VUE 引入jquery的方法和配置

第049个 查看专栏目录: VUE ------ element UI 专栏目标 在vue和element UI联合技术栈的操控下&#xff0c;本专栏提供行之有效的源代码示例和信息点介绍&#xff0c;做到灵活运用。 &#xff08;1&#xff09;提供vue2的一些基本操作&#xff1a;安装、引用&#xff0c;模板使…

Windows系统Java开发环境安装

总结一下Java软件开发工程师常见的环境的安装&#xff0c;仅限Windows环境。 以下下载链接均来自官网&#xff0c;网络条件自己克服。 目录 1. JDKJDK Oracle 官网下载地址配置系统环境变量 2. Mavenapache maven 官网地址本地仓库和中央仓库配置配置系统环境变量 3. GitGit 官…

运维05:自动化

人工运维时代 运维人员早期需要维护众多的机器&#xff0c;因此需要执行很多重复的劳动&#xff0c;很多机器需要同时部署相同的服务或者是执行相同的命令&#xff0c;还得反复地登录不同的机器&#xff0c;执行重复的动作 自动化运维时代 早期运维人员会结合ssh免密登录&…