Configuring environment||ROS2环境配置

news2024/11/30 0:26:08

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.coloradmin.cn/o/1299796.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

读书笔记:《股票量化交易的七个策略》

从长远来看&#xff0c;基本面最重要&#xff1b;从短期来看&#xff0c;价格和情绪最重要。在别人贪婪时恐惧&#xff0c;在别人恐惧时贪婪。 相对强弱指数策略【趋势反转】 相对强弱指数&#xff08;Relative Strength Index&#xff0c;RSI&#xff09; RSI的取值范围在0到…

亚马逊云科技re_Invent 2023产品体验:亚马逊云科技产品应用实践 国赛选手带你看Elasticache Serverless

抛砖引玉 讲一下作者背景&#xff0c;曾经参加过国内世界技能大赛云计算的选拔&#xff0c;那么在竞赛中包含两类&#xff0c;一类是架构类竞赛&#xff0c;另一类就是TroubleShooting竞赛&#xff0c;对应的分别为AWS GameDay和AWS Jam&#xff0c;想必也有朋友玩过此类竞赛&…

【C++】输入输出流 ⑥ ( cout 标准输出流对象 | cout 常用 api 简介 | cout.put(char c) 函数 )

文章目录 一、cout 标准输出流对象1、cout 标准输出流对象简介2、cout 常用 api 简介 二、cout.put(char c) 函数1、cout.put(char c) 函数 简介2、代码示例 - cout.put(char c) 函数 一、cout 标准输出流对象 1、cout 标准输出流对象简介 cout 是 标准输出流 对象 , 是 ostrea…

Redis的概念与常见命令

&#x1f307;个人主页&#xff1a;平凡的小苏 &#x1f4da;学习格言&#xff1a;命运给你一个低的起点&#xff0c;是想看你精彩的翻盘&#xff0c;而不是让你自甘堕落&#xff0c;脚下的路虽然难走&#xff0c;但我还能走&#xff0c;比起向阳而生&#xff0c;我更想尝试逆风…

新版Spring Security6.2架构 (一)

Spring Security 新版springboot 3.2已经集成Spring Security 6.2&#xff0c;和以前会有一些变化&#xff0c;本文主要针对官网的文档进行一些个人翻译和个人理解&#xff0c;不对地方请指正。 整体架构 Spring Security的Servlet 支持是基于Servelet过滤器&#xff0c;如下…

永磁同步电机反电动势系数怎么算?磁链强度怎么算?转矩系数怎么算?

在进行永磁同步电机simulink仿真时&#xff0c;一个关键参数就是永磁体磁链强度&#xff0c; 实际上在simulink中&#xff0c;永磁体磁链强度/反电动势系数/转矩系数这三个是放一起的&#xff0c;这是因为他们都可互相算出来。 Torque constat (Nm/A) 转矩系数 1.5 * Np *…

Java 匿名内部类使用的外部变量,为什么一定要加 final?

问题描述 Effectively final Java 1.8 新特性&#xff0c;对于一个局部变量或方法参数&#xff0c;如果他的值在初始化后就从未更改&#xff0c;那么该变量就是 effectively final&#xff08;事实 final&#xff09;。 这种情况下&#xff0c;可以不用加 final 关键字修饰。 …

计算机设备管理器如何看内存,怎么查看电脑配置信息?3种方法,让你掌握电脑全部信息!...

转载&#xff1a;https://blog.csdn.net/weixin_35849957/article/details/118512756?spm1001.2014.3001.5502 原标题&#xff1a;怎么查看电脑配置信息&#xff1f;3种方法&#xff0c;让你掌握电脑全部信息&#xff01; 电脑的配置决定了电脑性能高低以及运行速度。而电脑…

Ubuntu22.04 LTS + CUDA12.3 + CUDNN8.9.7 + PyTorch2.1.1

简介 本文记录Ubuntu22.04长期支持版系统下的CUDA驱动和cuDNN神经网络加速库的安装&#xff0c;并安装PyTorch2.1.1来测试是否安装成功。 安装Ubuntu系统 如果是旧的不支持UEFI启动的主板&#xff0c;请参考本人博客U盘系统盘制作与系统安装&#xff08;详细图解&#xff09…

深度学习基础介绍

定义&#xff1a; 深度学习是机器学习领域中一个新的研究方向&#xff0c;被引入机器学习使其更接近于最初的目标&#xff0c;即人工智能AI&#xff0c; Artifical Intelligence。 深度学习是学习样本数据的内在规律和表示层次&#xff0c;这些学习过程中获得的信息对诸如文字…

Docker网络架构介绍

本文主要介绍了Docker容器的单机网络架构与集群网络架构&#xff0c;辅以演示&#xff0c;并简单介绍了网络管理中的命令。 前文&#xff1a; Docker的安装与简单操作命令-CSDN博客 docker网络原理介绍 与ovs类似&#xff0c;docker容器采用veth-pair linux bridge (虚拟交…

CPU设计——Triumphcore——MP_work版本

该版本用作系统寄存器的实现&#xff0c;M/S/U状态的实现与切换&#xff0c;以及load/store的虚实地址转换 设计指标 2023.12.8 2023.12.9 不实现mideleg和medeleg&#xff0c;因此一旦出现异常&#xff0c;直接切换至M态&#xff0c; 调试记录 到存储区中取PTE要额外至少…

hive 命令行中使用 replace 和nvl2 函数报错

1.有时候在命令行的情况下使用 replace 函数时会报错 这个时候可以使用 translate 代替 2.有时候使用 nvl2() 函数的时候会报错 这个时候可以用 case when 来代替

IO / day06 作业

1.使用有名管道&#xff0c;完成两个进程的相互通信 代码&#xff1a; // 使用有名管道&#xff0c;完成两个进程的相互通信#include <myhead.h>// task sender void *tasks(void *arg) {printf("I am tasks\n");int fdw -1;const char **ppargv (const c…

Redis核心知识点总结

1.Redis介绍 Redis 是 NoSQL&#xff0c;但是可处理 1 秒 10w 的并发&#xff08;数据都在内存中&#xff09; 使用 java 对 redis 进行操作类似 jdbc 接口标准对 mysql&#xff0c;有各类实现他的实现类&#xff0c;我们常用的是 druid 其中对 redis&#xff0c;我们通常用 J…

链表面试题的总结和思路分享

꒰˃͈꒵˂͈꒱ write in front ꒰˃͈꒵˂͈꒱ ʕ̯•͡˔•̯᷅ʔ大家好&#xff0c;我是xiaoxie.希望你看完之后,有不足之处请多多谅解&#xff0c;让我们一起共同进步૮₍❀ᴗ͈ . ᴗ͈ აxiaoxieʕ̯•͡˔•̯᷅ʔ—CSDN博客 本文由xiaoxieʕ̯•͡˔•̯᷅ʔ 原创 CSDN …

Vite4、Vue3、Axios 针对请求模块化封装搭配自动化导入(简单易用)

针对请求模块化封装搭配自动化导入&#xff08;简单易用&#xff09; 目标目录目标代码前提步入正题src / utils / index.jssrc /api / index.jssrc /api / request.jssrc /api / service.jssrc /api / utils.jssrc /api / modules / demo.js 自动化配置vite.config.jseslint 校…

《PySpark大数据分析实战》-01.关于数据

&#x1f4cb; 博主简介 &#x1f496; 作者简介&#xff1a;大家好&#xff0c;我是wux_labs。&#x1f61c; 热衷于各种主流技术&#xff0c;热爱数据科学、机器学习、云计算、人工智能。 通过了TiDB数据库专员&#xff08;PCTA&#xff09;、TiDB数据库专家&#xff08;PCTP…

VSCode安装与使用

VS Code 安装及使用 1、下载 进入VS Code官网&#xff1a;地址&#xff0c;点击 DownLoad for Windows下载windows版本 注&#xff1a; Stable&#xff1a;稳定版Insiders&#xff1a;内测版 2、安装 双击安装包&#xff0c;选择我同意此协议&#xff0c;再点击下一步 选择你…

jquery实现省市区三级联动

一、技术: 前端采用的是jsp页面 后端采用springmvc+mybatis+mysql8 效果图 二、cascadeSelect.jsp页面 <%@ page contentType="text/html;charset=UTF-8" language="java" %> <%String path = request.getContextPath();String basePath = r…