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

Copy to clipboard

Note

The exact command depends on where you installed ROS 2. 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.pswp.cn/news/211697.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/211697.shtml
英文地址,請注明出處:http://en.pswp.cn/news/211697.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

C++進階篇8---智能指針

一、引言 為什么需要智能指針&#xff1f; 在上一篇異常中&#xff0c;關于內存釋放&#xff0c;我們提到過一個問題---當我們申請資源之后&#xff0c;由于異常的執行&#xff0c;代碼可能直接跳過資源的釋放語句到達catch&#xff0c;從而造成內存的泄露&#xff0c;對于這種…

C# Winform 日志系統

目錄 一、效果 1.刷新日志效果 2.單獨日志的分類 3.保存日志的樣式 二、概述 三、日志系統API 1.字段 Debug.IsScrolling Debug.Version Debug.LogMaxLen Debug.LogTitle Debug.IsConsoleShowLog 2.方法 Debug.Log(string) Debug.Log(string, params object[]) …

數據結構之內部排序

目錄 7-1 直接插入排序 輸入格式: 輸出格式: 輸入樣例: 輸出樣例: 7-2 尋找大富翁 輸入格式: 輸出格式: 輸入樣例: 輸出樣例: 7-3 PAT排名匯總 輸入格式: 輸出格式: 輸入樣例: 輸出樣例: 7-4 點贊狂魔 輸入格式&#xff1a; 輸出格式&#xff1a; 輸入樣例&a…

RabbitMQ在國內為什么沒有那么流行?

MQ&#xff08;消息隊列&#xff09;的世界。MQ&#xff0c;就像是一個巨大的郵局&#xff0c;負責在不同服務或應用間傳遞消息。它可以幫助我們解耦系統&#xff0c;提高性能&#xff0c;還能做到異步處理和流量削峰。 基本使用 RabbitMQ是一個開源的消息代理和隊列服務器&a…

spring boot + uniapp 微信公眾號 jsapi 支付

后端支付類 package com.ruoyi.coupon.payment;import com.google.gson.Gson; import com.ruoyi.coupon.payment.dto.PayParamJsapiDto; import com.ruoyi.coupon.payment.dto.RefundParam; import com.ruoyi.coupon.service.ICouponConfigService; import com.wechat.pay.jav…

FFmpeg抽取視頻h264數據重定向

根據視頻重定向技術解析中的 截獲解碼視頻流的思路&#xff0c;首先需要解決如何輸出視頻碼流的問題。 目前只針對h264碼流進行獲取&#xff0c;步驟如下&#xff1a; 打開mp4文件并創建一個空文件用于存儲H264數據 提取一路視頻流資源 循環讀取流中所有的包(AVPacket),為…

redis中使用pipeline批量處理請求提升系統性能

在操作數據庫時&#xff0c;為了加快程序的執行速度&#xff0c;在新增或更新數據時&#xff0c;可以通過批量提交的方式來減少應用和數據庫間的傳輸次數&#xff1b;在redis中也有這樣的技術實現批量處理&#xff0c;也就是管道——Pipeline。它也是通過批量提交數據的方式來實…

線程安全3--wait和notify

文章目錄 wait and notify&#xff08;等待通知機制notify補充 wait and notify&#xff08;等待通知機制 引入wait notify就是為了能夠從應用層面上&#xff0c;干預到多個不同線程代碼的執行順序&#xff0c;這里說的干預&#xff0c;不是影響系統的線程調度策略&#xff08…

uni-app應用設置 可以根據手機屏幕旋轉進行 (橫/豎) 屏切換

首先 我們打開項目的 manifest.json 在左側導航欄中找到 源碼視圖 然后找到 app-plus 配置 在下面加上 "orientation": [//豎屏正方向"portrait-primary",//豎屏反方向"portrait-secondary",//橫屏正方向"landscape-primary",//橫屏…

第57天:django學習(六)

模版之過濾器 語法&#xff1a; {{obj|filter__name:param}} 變量名字|過濾器名稱&#xff1a;變量 default 如果一個變量是false或者為空&#xff0c;使用給定的默認值。否則&#xff0c;使用變量的值。例如&#xff1a; {{ value|default:"nothing"}} length …

IDEA啟動應用時報錯:錯誤: 找不到或無法加載主類 @C:\Users\xxx\AppData\Local\Temp\idea_arg_filexxx

IDEA啟動應用時報錯&#xff0c;詳細錯誤消息如下&#xff1a; C:\devel\jdk1.8.0_201\bin\java.exe -agentlib:jdwptransportdt_socket,address127.0.0.1:65267,suspendy,servern -XX:TieredStopAtLevel1 -noverify -Dspring.output.ansi.enabledalways -Dcom.sun.management…

基于以太坊的智能合約開發Solidity(事件日志篇)

//聲明版本號&#xff08;程序中的版本號要和編譯器版本號一致&#xff09; pragma solidity ^0.5.17; //合約 contract EventTest {//狀態變量uint public Variable;//構造函數constructor() public{Variable 100;}event ValueChanged(uint newValue); //事件聲明event Log(…

ElasticSearch之cat plugins API

命令樣例如下&#xff1a; curl -X GET "https://localhost:9200/_cat/plugins?vtrue&pretty" --cacert $ES_HOME/config/certs/http_ca.crt -u "elastic:ohCxPHQBEs5*lo7F9"執行結果輸出如下&#xff1a; name component version…

class064 Dijkstra算法、分層圖最短路【算法】

class064 Dijkstra算法、分層圖最短路【算法】 算法講解064【必備】Dijkstra算法、分層圖最短路 code1 743. 網絡延遲時間 // Dijkstra算法模版&#xff08;Leetcode&#xff09; // 網絡延遲時間 // 有 n 個網絡節點&#xff0c;標記為 1 到 n // 給你一個列表 times&…

法律服務網站建設效果如何

律師事務所及法律知識咨詢機構等往往是眾多人群需求的服務&#xff0c;服務多樣化及內容多元化&#xff0c;市場中也有大量品牌&#xff0c;在實際消費服務中大多以本地事務所為主&#xff0c;而線上咨詢服務則一般沒有區域限制&#xff0c;同行增多及人們知識獲取渠道增加&…

C++-引用和指針區別

文章目錄 1.變量的組成2.指針2.1 定義2.2 使用指針操作變量2.3 為什么使用指針 3.引用3.1 定義3.2 引用注意事項 4.引用和指針的區別 1.變量的組成 變量的組成&#xff1a;變量地址&#xff0c;變量名&#xff0c;變量值 例&#xff1a; int i 12;2.指針 2.1 定義 指針用于存…

如何為游戲角色3D模型設置紋理貼圖

在線工具推薦&#xff1a; 3D數字孿生場景編輯器 - GLTF/GLB材質紋理編輯器 - 3D模型在線轉換 - Three.js AI自動紋理開發包 - YOLO 虛幻合成數據生成器 - 三維模型預覽圖生成器 - 3D模型語義搜索引擎 當談到游戲角色的3D模型風格時&#xff0c;有幾種不同的風格&#xf…

Mybatis中的查詢操作

單表查詢 單表查詢在《初始Mybatis》中已經介紹過&#xff0c;這里就不在介紹了。咱們這里只說單表查詢中的“like查詢”。like查詢單獨使用#{}報錯 <select id"selectByKeyword" resultType"com.example.demo.entity.Userinfo">select * from use…

計網Lesson8 - NAT技術與鏈路層概述

文章目錄 NAT 技術1. 因特網的接入方式2. 公網和私網3. NAT 技術 鏈路層1. 數據鏈路層概述2. 數據鏈路層的三個問題2.1 封裝成幀2.2 透明傳輸2.3 差錯檢測 NAT 技術 1. 因特網的接入方式 光貓將電信號轉換為數字信號發送給路由器 光纖入戶 光纖傳遞的就是數字信號&#xff0c…

python+pytest接口自動化(12)-自動化用例編寫思路 (使用pytest編寫一個測試腳本)

經過之前的學習鋪墊&#xff0c;我們嘗試著利用pytest框架編寫一條接口自動化測試用例&#xff0c;來厘清接口自動化用例編寫的思路。 我們在百度搜索天氣查詢&#xff0c;會出現如下圖所示結果&#xff1a; 接下來&#xff0c;我們以該天氣查詢接口為例&#xff0c;編寫接口測…