Ubuntu (Debian) — ROS 2 Documentation: Foxy documentation
sudo apt update
sudo apt install locales
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
sudo apt install software-properties-common
sudo add-apt-repository universe
sudo apt update && sudo apt install curl gnupg lsb-release
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(source /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
这个可能解析不了
sudo vi /etc/hosts 增加
185.199.110.133 raw.githubusercontent.com
185.199.108.133 raw.githubusercontent.com
185.199.109.133 raw.githubusercontent.com
140.82.114.3 github.com
199.232.69.194 github.global.ssl.fastly.net
185.199.108.153 assets-cdn.github.com
185.199.110.153 assets-cdn.github.com
185.199.111.153 assets-cdn.github.com
sudo apt update
sudo apt upgrade
## 推荐桌面版,比较推荐。
sudo apt install ros-foxy-desktop
## 安装时间可能较长,安心等待。
source /opt/ros/humble/setup.bash
echo " source /opt/ros/humble/setup.bash" >> ~/.bashrc
启动第一个终端,通过以下命令启动一个数据的发布者节点:
ros2 run demo_nodes_cpp talker
启动第二个终端,通过以下命令启动一个数据的订阅者节点:
ros2 run demo_nodes_py listener
如果“Hello World”字符串在两个终端中正常传输,说明通信系统没有问题。
小海龟仿真示例
再来试一试ROS中的经典示例——小海龟仿真器。
启动两个终端,分别运行如下指令:
$ ros2 run turtlesim turtlesim_node
$ ros2 run turtlesim turtle_teleop_key
sudo apt install python3-colcon-common-extensions