ros2上怎样才能玩rmf?

本文档详细记录了在Ubuntu 20.04上从源码编译ROS2 Foxy版本的RMF的步骤,包括设置Gazebo库、安装依赖、下载源码和编译过程。在尝试Galactic版本失败后,作者成功使用Foxy版本,并解决了编译中遇到的ignition-gazebo3Config缺失问题。
摘要由CSDN通过智能技术生成

环境

日期:2022/4/22
ubuntu版本:20.4
ros2版本:foxy (源码下载)
gcc:9
python:3.8
官网上说用Galactic版本的ros2更好,一开始我就用的Galactic,期间遇到了很多错误,我就想换个版本试试吧,结果很快成功编译了,这里有可能是笔者才疏学浅不知道怎么build,也可能是官方未对新版本适配,反正现在是可以了。hhh

1.设置gazebo库

sudo apt update
sudo apt install -y wget
sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list'
wget https://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -

2.从源码开始构建

官网显示可以通过Demos安装一个简化版本,这里介绍完整版的内容
1.下载依赖项:

此处不要下载rmf!


sudo apt update && sudo apt install \
  git cmake python3-vcstool curl \
  qt5-default \
  -y
python3 -m pip install flask-socketio
sudo apt-get install python3-colcon*

2.下载 rosdep

sudo apt install python3-rosdep
sudo rosdep init
rosdep update

3.下载源码(这一部分极其重要!)

mkdir -p ~/rmf_ws/src
cd ~/rmf_ws
wget https://raw.githubusercontent.com/open-rmf/rmf/main/rmf.repos

这是下载的rmf.repos内容:

repositories:
  rmf/rmf_battery:
    type: git
    url: https://github.com/open-rmf/rmf_battery.git
    version: main
  rmf/rmf_internal_msgs:
    type: git
    url: https://github.com/open-rmf/rmf_internal_msgs.git
    version: main
  rmf/rmf_api_msgs:
    type: git
    url: https://github.com/open-rmf/rmf_api_msgs.git
    version: main
  rmf/rmf_ros2:
    type: git
    url: https://github.com/open-rmf/rmf_ros2.git
    version: main
  rmf/rmf_task:
    type: git
    url: https://github.com/open-rmf/rmf_task.git
    version: main
  rmf/rmf_traffic:
    type: git
    url: https://github.com/open-rmf/rmf_traffic.git
    version: main
  rmf/rmf_utils:
    type: git
    url: https://github.com/open-rmf/rmf_utils.git
    version: main
  rmf/ament_cmake_catch2:
    type: git
    url: https://github.com/open-rmf/ament_cmake_catch2.git
    version: main
  rmf/rmf_visualization:
    type: git
    url: https://github.com/open-rmf/rmf_visualization.git
    version: main
  rmf/rmf_visualization_msgs:
    type: git
    url: https://github.com/open-rmf/rmf_visualization_msgs.git
    version: main
  rmf/rmf_building_map_msgs:
    type: git
    url: https://github.com/open-rmf/rmf_building_map_msgs.git
    version: main
  rmf/rmf_simulation:
    type: git
    url: https://github.com/open-rmf/rmf_simulation.git
    version: main
  rmf/rmf_traffic_editor:
    type: git
    url: https://github.com/open-rmf/rmf_traffic_editor.git
    version: main
  demonstrations/rmf_demos:
    type: git
    url: https://github.com/open-rmf/rmf_demos.git
    version: main
  thirdparty/menge_vendor:
    type: git
    url: https://github.com/open-rmf/menge_vendor.git
    version: master
  thirdparty/nlohmann_json_schema_validator_vendor:
    type: git
    url: https://github.com/open-rmf/nlohmann_json_schema_validator_vendor.git
    version: main
  thirdparty/pybind11_json_vendor:
    type: git
    url: https://github.com/open-rmf/pybind11_json_vendor.git
    version: main
  thirdparty/ros_ign:
    type: git
    url: https://github.com/ignitionrobotics/ros_ign.git
    version: ros2

我对其稍微进行了更改:

repositories:
  rmf/rmf_battery:
    type: git
    url: https://github.com/open-rmf/rmf_battery.git
    version: main
  rmf/rmf_internal_msgs:
    type: git
    url: https://github.com/open-rmf/rmf_internal_msgs.git
    version: main
  rmf/rmf_api_msgs:
    type: git
    url: https://github.com/open-rmf/rmf_api_msgs.git
    version: main
  rmf/rmf_ros2:
    type: git
    url: https://github.com/open-rmf/rmf_ros2.git
    version: main
  rmf/rmf_task:
    type: git
    url: https://github.com/open-rmf/rmf_task.git
    version: main
  rmf/rmf_traffic:
    type: git
    url: https://github.com/open-rmf/rmf_traffic.git
    version: main
  rmf/rmf_utils:
    type: git
    url: https://github.com/open-rmf/rmf_utils.git
    version: main
  rmf/ament_cmake_catch2:
    type: git
    url: https://github.com/open-rmf/ament_cmake_catch2.git
    version: main
  rmf/rmf_visualization:
    type: git
    url: https://github.com/open-rmf/rmf_visualization.git
    version: main
  rmf/rmf_visualization_msgs:
    type: git
    url: https://github.com/open-rmf/rmf_visualization_msgs.git
    version: main
  rmf/rmf_building_map_msgs:
    type: git
    url: https://github.com/open-rmf/rmf_building_map_msgs.git
    version: main
  rmf/rmf_simulation:
    type: git
    url: https://github.com/open-rmf/rmf_simulation.git
    version: main
  rmf/rmf_traffic_editor:
    type: git
    url: https://github.com/open-rmf/rmf_traffic_editor.git
    version: 1.3.0
  demonstrations/rmf_demos:
    type: git
    url: https://github.com/open-rmf/rmf_demos.git
    version: main
  thirdparty/menge_vendor:
    type: git
    url: https://github.com/open-rmf/menge_vendor.git
    version: master
  thirdparty/nlohmann_json_schema_validator_vendor:
    type: git
    url: https://github.com/open-rmf/nlohmann_json_schema_validator_vendor.git
    version: main
  thirdparty/pybind11_json_vendor:
    type: git
    url: https://github.com/open-rmf/pybind11_json_vendor.git
    version: main
  thirdparty/ros_ign:
    type: git
    url: https://github.com/ignitionrobotics/ros_ign.git
    version: foxy

然后下载就可以了!

vcs import src < rmf.repos

编译

编译的时候报错:ignition-gazebo3Config 这个玩意没有
所以:

 sudo apt install ros-foxy-ros-ign

之后就没有报错了。
现在就可以编译了:

cd ~/rmf_ws
rosdep install --from-paths src --ignore-src --rosdistro galactic -y
source /opt/ros/galactic/setup.bash
colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release

成功!

可以开心的学习rmf了!希望看到这里的小伙伴都可以编译成功!
rmf网站:

https://github.com/open-rmf/rmf_demos/tree/main
https://osrf.github.io/ros2multirobotbook/intro.html

以上内容参考:
https://github.com/open-rmf/rmf/tree/main

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值