ubuntu22.04安装ros2 ros2-px4
时间: 2023-08-20 20:06:13 浏览: 298
安装ROS2:
1. 添加ROS2软件源
```
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.list'
```
2. 安装ROS2
```
sudo apt update
sudo apt install ros-foxy-desktop
```
3. 设置ROS2环境
```
echo "source /opt/ros/foxy/setup.bash" >> ~/.bashrc
source ~/.bashrc
```
安装ROS2-PX4:
1. 安装依赖
```
sudo apt install python3-rosdep python3-colcon-common-extensions python3-rosinstall-generator
```
2. 初始化rosdep
```
sudo rosdep init
rosdep update
```
3. 创建工作空间
```
mkdir -p ~/px4_ros2_ws/src
cd ~/px4_ros2_ws/src
```
4. 下载PX4-Firmware
```
git clone https://github.com/PX4/PX4-Autopilot.git --branch v1.12.3 --single-branch
```
5. 下载PX4-ROS2
```
git clone https://github.com/PX4/px4_ros_com.git --branch v0.1.0 --single-branch
```
6. 安装依赖
```
cd px4_ros_com/scripts
./install_ros2.bash
```
7. 构建
```
cd ~/px4_ros2_ws
colcon build --symlink-install --packages-select px4_msgs px4_ros_com
```
8. 设置ROS2环境
```
echo "source ~/px4_ros2_ws/install/local_setup.bash" >> ~/.bashrc
source ~/.bashrc
```
9. 运行示例
```
ros2 launch px4_ros_com px4_bridge_launch.py
```
阅读全文