Ubuntu 22.10系统下ROS2安装相关技术咨询
Hey there, let's work through this ROS2 installation snag on Ubuntu 22.10 together! First, a quick clarification: you mentioned "Kinetic Kudu"—that's actually the codename for Ubuntu 22.10, not a ROS version (ROS1 Kinetic is for Ubuntu 16.04, so easy mix-up!). The correct ROS2 distribution to use with Ubuntu 22.10 is Iron Irwini, since it's specifically built for this non-LTS release. Let's walk through the steps and common fixes:
1. First, set up your system locale
ROS2 relies on UTF-8 locale support, so let's make sure that's configured properly:
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
2. Add ROS2 software repositories
Next, we need to add the official ROS2 repo to your system's package sources:
- First install the tools needed to manage repositories:
sudo apt install software-properties-common sudo add-apt-repository universe - Import the ROS2 GPG key to verify package integrity:
sudo apt update && sudo apt install curl sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg - Add the ROS2 repo to your
sources.list.ddirectory:echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
3. Install ROS2 packages
Now let's install the actual ROS2 packages. I recommend the desktop full version (it includes all tools, examples, and GUI apps) for most users:
- First update your package index:
sudo apt update - Install the desktop full package:
sudo apt install ros-iron-desktop - If you only need core functionality (no GUI), go with the base package instead:
sudo apt install ros-iron-base
4. Set up environment variables
To use ROS2 commands, you need to load its environment variables in each terminal session. You can do this manually each time:
source /opt/ros/iron/setup.bash
Or make it permanent so it loads automatically every time you open a terminal:
echo "source /opt/ros/iron/setup.bash" >> ~/.bashrc
(If you use zsh instead of bash, replace ~/.bashrc with ~/.zshrc in the command above.)
5. Verify the installation
Let's make sure everything works correctly:
- Open a new terminal, run the talker node:
source /opt/ros/iron/setup.bash ros2 run demo_nodes_cpp talker - Open another terminal, run the listener node:
source /opt/ros/iron/setup.bash ros2 run demo_nodes_cpp listener
If you see the talker printing "Hello World!" messages and the listener receiving them, your installation is successful!
Common issues to watch out for
- GPG key errors: If you get a key-related error during
apt update, re-run the step where you import the ROS2 GPG key. Sometimes network hiccups can cause the key to not download properly. - Package not found: Double-check that the repository command used the correct Ubuntu codename. For 22.10, it should be
kinetic—the command we use pulls this automatically from your system, so it should be correct, but you can verify by running. /etc/os-release && echo $UBUNTU_CODENAMEin a terminal. - ROS commands not recognized: Make sure you've sourced the setup script correctly. If you added it to
bashrc, try restarting your terminal or runningsource ~/.bashrcmanually.
If you run into any specific error messages during these steps, share the exact output and I can help you troubleshoot further!
备注:内容来源于stack exchange,提问作者Dom

