当前位置:   article > 正文

Ubuntu 22.04源码编译安装ROS Noetic_ubuntu22.04安装ros1

ubuntu22.04安装ros1

ROS1对Ubuntu的支持只到20.04,如果要在22.04上安装ROS1只能从源码编译安装。

1. 添加源

由于ROS1官网不支持,因此只能添加ROS2的源

  1. $ sudo apt update && sudo apt install curl
  2. $ sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
  3. $ 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
  4. $ sudo apt update

2. 安装编译依赖项

  1. $ sudo apt-get install python3-rosdep python3-rosinstall-generator python3-vcstools python3-vcstool build-essential
  2. $ sudo pip3 install -U rosdep rosinstall_generator vcstool
  3. $ sudo pip3 install --upgrade setuptools

3. rosdep安装依赖,这一步不用折腾国内怎么访问GitHub的问题了,因为ROS1官网不支持Ubuntu22.04,所以每个依赖项的手动安装。

4. 新建catkin workspace

  1. $ mkdir ~/ros_catkin_ws
  2. $ cd ~/ros_catkin_ws

5. 拉取ROS Noetic源码

  1. $ rosinstall_generator desktop --rosdistro noetic --deps --tar > noetic-desktop.rosinstall
  2. $ mkdir ./src
  3. $ vcs import --input noetic-desktop.rosinstall ./src

`vcs import` 这一步因为墙的原因大概率会失败(terminal中打印EEEE,成功会打印....), 直接替换noetic-desktop.rosinstall中所有的github.com为kgithub.com,然后再次执行

$ vcs import --input noetic-desktop.rosinstall ./src

6. 手动安装ROS Noetic依赖项

$ sudo apt install libboost-all-dev uuid-dev python3-nose google-mock libgtest-dev libbz2-dev libgpgme-dev libssl-dev python3-coverage libboost-program-options-dev python3-psutil python3-opengl python3-pygraphviz python3-pydot qt5-qmake sbcl libapr1-dev libaprutil1-dev libboost-regex-dev liblog4cxx-dev python3-matplotlib libpyside2-dev libshiboken2-dev pyqt5-dev python3-pyqt5 python3-pyqt5.qtsvg python3-pyside2.qtsvg python3-sip-dev shiboken2 lm-sensors graphviz python3-paramiko python3-pycryptodome python3-gnupg python3-defusedxml python3-pyqt5.qtopengl libcurl4-openssl-dev libpoco-dev libogre-1.9-dev libassimp-dev libogre-1.9.0v5 libyaml-cpp-dev libgl1-mesa-dev libglu1-mesa-dev libqt5opengl5 libqt5opengl5-dev libopencv-dev python3-opencv python3-pykdl tango-icon-theme liborocos-kdl-dev libtinyxml-dev libtinyxml2-dev liburdfdom-headers-dev python3-numpy python3-empy libboost-filesystem-dev libboost-thread-dev python3-pygraphviz python3-pygraphviz python3-mock libboost-date-time-dev libboost-system-dev liburdfdom-dev libboost-chrono-dev libboost-dev libqt5core5a libqt5gui5 libqt5widgets5 qtbase5-dev  libconsole-bridge-dev liblz4-dev python3-pyqt5.qtwebkit exfatprogs

 7. 编译

$ ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=/usr/bin/python3

可能仍会有以下问题

  • rosconsole
  1. Errors << rosconsole:make /home/youliang/ros_ws/build/catkin_ws/logs/rosconsole/build.make.002.log
  2. /home/youliang/ros_ws/build/catkin_ws/src/rosconsole/src/rosconsole/impl/rosconsole_log4cxx.cpp: In function ‘void ros::console::impl::initialize()’:
  3. /home/youliang/ros_ws/build/catkin_ws/src/rosconsole/src/rosconsole/impl/rosconsole_log4cxx.cpp:169:23: error: cannot convert ‘ros::console::impl::ROSConsoleStdioAppender*’ to ‘log4cxx::AppenderPtr’ {aka ‘std::shared_ptr<log4cxx::Appender>’}
  4. 169 | logger->addAppender(new ROSConsoleStdioAppender);
  5. | ^~~~~~~~~~~~~~~~~~~~~~~~~~~
  6. | |
  7. | ros::console::impl::ROSConsoleStdioAppender*
  8. In file included from /usr/include/log4cxx/spi/loggingevent.h:28,
  9. from /usr/include/log4cxx/layout.h:29,
  10. from /usr/include/log4cxx/appenderskeleton.h:28,
  11. from /home/youliang/ros_ws/build/catkin_ws/src/rosconsole/src/rosconsole/impl/rosconsole_log4cxx.cpp:42:
  12. /usr/include/log4cxx/logger.h:144:60: note: initializing argument 1 of ‘virtual void log4cxx::Logger::addAppender(log4cxx::AppenderPtr)’
  13. 144 | virtual void addAppender(const AppenderPtr newAppender);
  14. | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
  15. /home/youliang/ros_ws/build/catkin_ws/src/rosconsole/src/rosconsole/impl/rosconsole_log4cxx.cpp: In function ‘void* ros::console::impl::getHandle(const string&)’:
  16. /home/youliang/ros_ws/build/catkin_ws/src/rosconsole/src/rosconsole/impl/rosconsole_log4cxx.cpp:203:36: error: cannot convert ‘log4cxx::LoggerPtr’ {aka ‘std::shared_ptr<log4cxx::Logger>’} to ‘void*’ in return
  17. 203 | return log4cxx::Logger::getLogger(name);
  18. | ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
  19. | |

 从GitHub - lucasw/rosconsole拉取rosconsole的源码,切到concise_output_roso分支,覆盖到

~/ros_catkin_ws/src下。

  • shared_mutex的问题
  1. make[2]: *** [CMakeFiles/tf.dir/build.make:118: CMakeFiles/tf.dir/src/transform_listener.cpp.o] Error 1
  2. In file included from /usr/include/log4cxx/log4cxx.h:45,
  3. from /usr/include/log4cxx/logstring.h:28,
  4. from /usr/include/log4cxx/level.h:22,
  5. from /opt/ros/noetic/include/ros/console.h:46,
  6. from /opt/ros/noetic/include/ros/ros.h:40,
  7. from /tmp/makepkg/ros-noetic-tf/src/geometry-1.13.2/tf/src/transform_broadcaster.cpp:34:
  8. /usr/include/log4cxx/boost-std-configuration.h:10:18: error: ‘shared_mutex’ in namespace ‘std’ does not name a type
  9. 10 | typedef std::shared_mutex shared_mutex;
  10. | ^~~~~~~~~~~~
  11. /usr/include/log4cxx/boost-std-configuration.h:10:13: note: ‘std::shared_mutex’ is only available from C++17 onwards
  12. 10 | typedef std::shared_mutex shared_mutex;
  13. | ^~~
  14. /usr/include/log4cxx/boost-std-configuration.h:12:30: error: ‘shared_lock’ in namespace ‘std’ does not name a template type
  15. 12 | using shared_lock = std::shared_lock<T>;
  16. | ^~~~~~~~~~~
  17. /usr/include/log4cxx/boost-std-configuration.h:12:25: note: ‘std::shared_lock’ is only available from C++14 onwards
  18. 12 | using shared_lock = std::shared_lock<T>;
  19. | ^~~
  20. In file included from /opt/ros/noetic/include/ros/console.h:46,
  21. from /opt/ros/noetic/include/ros/ros.h:40,
  22. from /tmp/makepkg/ros-noetic-tf/src/geometry-1.13.2/tf/src/transform_broadcaster.cpp:34:
  23. /usr/include/log4cxx/level.h:283:29: error: ‘mutex’ in namespace ‘std’ does not name a type
  24. 283 | static std::mutex initMutex;
  25. | ^~~~~
  26. /usr/include/log4cxx/level.h:25:1: note: ‘std::mutex’ is defined in header ‘<mutex>’; did you forget to ‘#include <mutex>’?
  27. 24 | #include <log4cxx/helpers/object.h>
  28. +++ |+#include <mutex>
  29. 25 |

解决方案:

修改/usr/include/log4cxx/boost-std-configuration.h中的

  1. #define STD_SHARED_MUTEX_FOUND 1
  2. #define Boost_SHARED_MUTEX_FOUND 0

 为

  1. #define STD_SHARED_MUTEX_FOUND 0
  2. #define Boost_SHARED_MUTEX_FOUND 1

再有其他问题自行Google解决。

 7. 最后source环境变量愉快使用ROS Noetic吧~

$ source ~/ros_catkin_ws/install_isolated/setup.bash
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/天景科技苑/article/detail/1011262
推荐阅读
相关标签
  

闽ICP备14008679号