wsl2的ubuntu22.04中安装ros2

1、设置编码

复制代码
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8

2、hosts文件中添加域名解析

vim /etc/hosts

199.232.96.133 raw.githubusercontent.com

199.232.96.133 raw.github.com

3、设置软件源

复制代码
sudo apt update && sudo apt install curl gnupg2 lsb-release

curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -

sudo sh -c 'echo "deb [arch=$(dpkg --print-architecture)] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" > /etc/apt/sources.list.d/ros2-latest.list'

4、安装ros2安装包

复制代码
sudo apt update
sudo apt install ros-humble-desktop

注意:

此处以Ubuntu22.04下安装ROS2 Humble为例,如使用Ubuntu 20.04,请将"humble"改为"foxy。

或者安装基础版

复制代码
sudo apt install ros-humble-ros-base
apt-get update

5、然后我们还需要安装编译工具colcon

复制代码
sudo apt install python3-colcon-common-extensions

6、设置环境变量

复制代码
source /opt/ros/humble/setup.bash

7、安装自动补全工具

复制代码
sudo apt install python3-argcomplete

8、验证

跑几个例程测试一下: 先运行一个talker:

source /opt/ros/humble/setup.bash

ros2 run demo_nodes_cpp talker

再运行一个Listener

source /opt/ros/humble/setup.bash

ros2 run demo_nodes_py listener

问题一:

Failed to connect to raw.githubusercontent.com port 443: Connection refused

解决办法:通过修改hosts解决此问题。

查询真实IP:

在https://www.ipaddress.com/

查询raw.githubusercontent.com和raw.github.com的真实IP。

修改hosts:

sudo vim /etc/hosts

添加如下内容:

199.232.96.133 raw.githubusercontent.com

199.232.96.133 raw.github.com

更多参考:https://blog.csdn.net/xiaxinkai/article/details/112975134

https://blog.csdn.net/weixin_45367061/article/details/122678266

电脑端环境配置 - OriginBot智能机器人开源套件

相关推荐
米糕闯编程12 天前
鱼香ros2(二十五)导航
机器人·slam·ros2·launch·navigation2
兜里只有三分钱~16 天前
从 URDF 到 SDK:开发者视角拆解启元 T1/Q1 机器人架构
机器人·sdk·仿真·ros2·urdf
特立独行的猫a19 天前
ROS 2 主流DDS中间件入门:Cyclone DDS 与 Fast DDS 完全指南
中间件·ros2·dds·fast dds·cyclone dds
轻口味23 天前
启元无真机二开实战1:54 个接口能做什么、不能做什么——启元 Q1/T1 SDK 能力全景与版本矩阵
线性代数·矩阵·ros2·具身智能·启元机器人
热金鼠25 天前
2.ROS2 核心机制与命令行实操
ros2
大雨歌1 个月前
笛卡尔坐标 → 自然坐标(Frenet) 逐步推导全解 -2
ros2
米糕闯编程1 个月前
鱼香ros2(十七)C++小海龟巡逻
开发语言·c++·机器人·ros2·服务·小海龟
风合星语1 个月前
2026 机器人工程实例(七):Nav2 到站了,任务却没完成——AMR 载货导航中的托盘滑移与验收闭环
人工智能·机器人·ros2·机器人仿真·nav2·mujoco·amr
米糕闯编程1 个月前
鱼香ros2(十二)C++话题订阅与发布
开发语言·c++·ros2·话题
朝朝辞暮i1 个月前
C++ 第 36 课:Action——机械臂/VLA 非常重要
开发语言·c++·算法·ros2