ROS1對Ubuntu的支持只到20.04,,如果要在22.04上安裝ROS1只能從源碼編譯安裝,。
1. 添加源
由于ROS1官網(wǎng)不支持,,因此只能添加ROS2的源
$ sudo apt update && sudo apt install curl $ sudo curl -sSL https://raw./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./ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
2. 安裝編譯依賴項
$ sudo apt-get install python3-rosdep python3-rosinstall-generator python3-vcstools python3-vcstool build-essential $ sudo pip3 install -U rosdep rosinstall_generator vcstool $ sudo pip3 install --upgrade setuptools
3. rosdep安裝依賴,,這一步不用折騰國內(nèi)怎么訪問GitHub的問題了,,因為ROS1官網(wǎng)不支持Ubuntu22.04,,所以每個依賴項的手動安裝,。
4. 新建catkin workspace
5. 拉取ROS Noetic源碼
$ rosinstall_generator desktop --rosdistro noetic --deps --tar > noetic-desktop.rosinstall $ vcs import --input noetic-desktop.rosinstall ./src
`vcs import` 這一步因為墻的原因大概率會失?。╰erminal中打印EEEE,,成功會打印....), 直接替換noetic-desktop.rosinstall中所有的github.com為kgithub.com,,然后再次執(zhí)行
$ 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
可能仍會有以下問題
Errors << rosconsole:make /home/youliang/ros_ws/build/catkin_ws/logs/rosconsole/build.make.002.log /home/youliang/ros_ws/build/catkin_ws/src/rosconsole/src/rosconsole/impl/rosconsole_log4cxx.cpp: In function 'void ros::console::impl::initialize()’: /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>’} 169 | logger->addAppender(new ROSConsoleStdioAppender); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ | ros::console::impl::ROSConsoleStdioAppender* In file included from /usr/include/log4cxx/spi/loggingevent.h:28, from /usr/include/log4cxx/layout.h:29, from /usr/include/log4cxx/appenderskeleton.h:28, from /home/youliang/ros_ws/build/catkin_ws/src/rosconsole/src/rosconsole/impl/rosconsole_log4cxx.cpp:42: /usr/include/log4cxx/logger.h:144:60: note: initializing argument 1 of 'virtual void log4cxx::Logger::addAppender(log4cxx::AppenderPtr)’ 144 | virtual void addAppender(const AppenderPtr newAppender); | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~ /home/youliang/ros_ws/build/catkin_ws/src/rosconsole/src/rosconsole/impl/rosconsole_log4cxx.cpp: In function 'void* ros::console::impl::getHandle(const string&)’: /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 203 | return log4cxx::Logger::getLogger(name); | ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
從GitHub - lucasw/rosconsole拉取rosconsole的源碼,,切到concise_output_roso分支,覆蓋到
~/ros_catkin_ws/src下,。
make[2]: *** [CMakeFiles/tf.dir/build.make:118: CMakeFiles/tf.dir/src/transform_listener.cpp.o] Error 1 In file included from /usr/include/log4cxx/log4cxx.h:45, from /usr/include/log4cxx/logstring.h:28, from /usr/include/log4cxx/level.h:22, from /opt/ros/noetic/include/ros/console.h:46, from /opt/ros/noetic/include/ros/ros.h:40, from /tmp/makepkg/ros-noetic-tf/src/geometry-1.13.2/tf/src/transform_broadcaster.cpp:34: /usr/include/log4cxx/boost-std-configuration.h:10:18: error: 'shared_mutex’ in namespace 'std’ does not name a type 10 | typedef std::shared_mutex shared_mutex; /usr/include/log4cxx/boost-std-configuration.h:10:13: note: 'std::shared_mutex’ is only available from C++17 onwards 10 | typedef std::shared_mutex shared_mutex; /usr/include/log4cxx/boost-std-configuration.h:12:30: error: 'shared_lock’ in namespace 'std’ does not name a template type 12 | using shared_lock = std::shared_lock<T>; /usr/include/log4cxx/boost-std-configuration.h:12:25: note: 'std::shared_lock’ is only available from C++14 onwards 12 | using shared_lock = std::shared_lock<T>; In file included from /opt/ros/noetic/include/ros/console.h:46, from /opt/ros/noetic/include/ros/ros.h:40, from /tmp/makepkg/ros-noetic-tf/src/geometry-1.13.2/tf/src/transform_broadcaster.cpp:34: /usr/include/log4cxx/level.h:283:29: error: 'mutex’ in namespace 'std’ does not name a type 283 | static std::mutex initMutex; /usr/include/log4cxx/level.h:25:1: note: 'std::mutex’ is defined in header '<mutex>’; did you forget to '#include <mutex>’? 24 | #include <log4cxx/helpers/object.h>
解決方案:
修改/usr/include/log4cxx/boost-std-configuration.h中的
#define STD_SHARED_MUTEX_FOUND 1 #define Boost_SHARED_MUTEX_FOUND 0
為
#define STD_SHARED_MUTEX_FOUND 0 #define Boost_SHARED_MUTEX_FOUND 1
再有其他問題自行Google解決,。
7. 最后source環(huán)境變量愉快使用ROS Noetic吧~
$ source ~/ros_catkin_ws/install_isolated/setup.bash
|