当前位置:   article > 正文

ubuntu 22.04源码装ros1 noetic_22.04安装ros1-noetic

22.04安装ros1-noetic

ubuntu 22.04源码装ros1 noetic


参考链接

https://gist.github.com/Meltwin/fe2c15a5d7e6a8795911907f627255e0

1. 安装依赖

sudo apt-get install python3-rosdep python3-rosinstall-generator python3-vcstools python3-vcstool build-essential

  • 1
  • 2

2. 更换rosdep相关的rep链接

参考:https://blog.csdn.net/zyh821351004/article/details/135519444?spm=1001.2014.3001.5501

mkdir -p ~/.ros/rosdep
cd ~/.ros/rosdep
~/.ros/rosdep$ git clone git@github.com:ros/rosdistro.git 

cat rosdep/sources.list.d/20-default.list
yaml file:///home/robot/.ros/rosdep/rosdistro/rosdep/osx-homebrew.yaml osx

# generic
yaml file:///home/robot/.ros/rosdep/rosdistro/rosdep/base.yaml
yaml file:///home/robot/.ros/rosdep/rosdistro/rosdep/python.yaml
yaml file:///home/robot/.ros/rosdep/rosdistro/rosdep/ruby.yaml
gbpdistro file:///home/robot/.ros/rosdep/rosdistro/releases/fuerte.yaml fuerte
 
# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

sudo gedit /etc/ros/rosdep/sources.list.d/20-default.list

 
yaml file:///home/robot/.ros/rosdep/rosdistro/rosdep/osx-homebrew.yaml osx

# generic
yaml file:///home/robot/.ros/rosdep/rosdistro/rosdep/base.yaml
yaml file:///home/robot/.ros/rosdep/rosdistro/rosdep/python.yaml
yaml file:///home/robot/.ros/rosdep/rosdistro/rosdep/ruby.yaml
gbpdistro file:///home/robot/.ros/rosdep/rosdistro/releases/fuerte.yaml fuerte
 
# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

sudo gedit /usr/lib/python3/dist-packages/rosdep2/sources_list.py

#DEFAULT_SOURCES_LIST_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list'
DEFAULT_SOURCES_LIST_URL = 'file:///home/robot/.ros/rosdep/rosdistro/rosdep/sources.list.d/20-default.list'
  • 1
  • 2

sudo gedit /usr/lib/python3/dist-packages/rosdep2/rep3.py

#REP3_TARGETS_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/releases/targets.yaml'
REP3_TARGETS_URL = 'file:///home/robot/.ros/rosdep/rosdistro/releases/targets.yaml'
  • 1
  • 2

sudo gedit /usr/lib/python3/dist-packages/rosdistro/init.py

#DEFAULT_INDEX_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml'
DEFAULT_INDEX_URL = 'file:///home/robot/.ros/rosdep/rosdistro/index-v4.yaml'
  • 1
  • 2
sudo rm /etc/ros/rosdep/sources.list.d/20-default.list 
sudo rosdep init
rosdep update

  • 1
  • 2
  • 3
  • 4

3. 安装 rosdep

sudo rosdep init
rosdep update
  • 1
  • 2

4. 创建工作空间下载源码并安装

mkdir ./noetic_ws
cd ./noetic_ws
rosinstall_generator desktop --rosdistro noetic --deps --tar > noetic-desktop.rosinstall
mkdir ./src
vcs import --input noetic-desktop.rosinstall ./src


rosdep install --from-paths ./src --ignore-packages-from-source --rosdistro noetic -y
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

等待下载完成
备份打包源码 csdn_下载

noetic-desktop.rosinstall  noetic-base.rosinstall
  • 1
noetic-desktop.rosinstall   737行

类似:
- tar:
    local-name: actionlib/actionlib
    uri: https://github.com/ros-gbp/actionlib-release/archive/release/noetic/actionlib/1.14.0-1.tar.gz
    version: actionlib-release-release-noetic-actionlib-1.14.0-1
- tar:
    local-name: angles
    uri: https://github.com/ros-gbp/geometry_angles_utils-release/archive/release/noetic/angles/1.9.13-1.tar.gz
    version: geometry_angles_utils-release-release-noetic-angles-1.9.13-1
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
/opt/ros/noetic_ws/src$ ls
actionlib              metapackages           rqt_moveit
angles                 navigation_msgs        rqt_msg
bond_core              nodelet_core           rqt_nav_view
catkin                 pluginlib              rqt_plot
class_loader           python_qt_binding      rqt_pose_view
cmake_modules          qt_gui_core            rqt_publisher
common_msgs            qwt_dependency         rqt_py_console
common_tutorials       resource_retriever     rqt_reconfigure
control_msgs           robot_state_publisher  rqt_robot_dashboard
diagnostics            ros                    rqt_robot_monitor
dynamic_reconfigure    rosbag_migration_rule  rqt_robot_plugins
executive_smach        ros_comm               rqt_robot_steering
filters                ros_comm_msgs          rqt_runtime_monitor
gencpp                 rosconsole             rqt_rviz
geneus                 rosconsole_bridge      rqt_service_caller
genlisp                roscpp_core            rqt_shell
genmsg                 ros_environment        rqt_srv
gennodejs              roslint                rqt_tf_tree
genpy                  roslisp                rqt_top
geometry               rospack                rqt_topic
geometry2              ros_tutorials          rqt_web
geometry_tutorials     rqt                    rviz
gl_dependency          rqt_action             std_msgs
image_common           rqt_bag                urdf
interactive_markers    rqt_common_plugins     urdf_tutorial
joint_state_publisher  rqt_console            vision_opencv
kdl_parser             rqt_dep                visualization_tutorials
laser_geometry         rqt_graph              webkit_dependency
media_export           rqt_image_view         xacro
message_generation     rqt_launch
message_runtime        rqt_logger_level

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33

5. 编译代码

./src/catkin/bin/catkin_make_isolated -DCMAKE_BUILD_TYPE=Release
  • 1

会遇到一些列报错:

5.1 修复rosconsole* log相关问题error

rosconsole_log4cxx.cpp里面的代码全部替换源代码src/rosconsole/src/rosconsole/impl/rosconsole_log4cxx.cpp

替代rosconsole_log4cxx.cpp
https://gist.github.com/kintzhao/3947142d3161e11e5a0c326b79e9ebdb### 5.2 qt5库相关的安装

sudo apt install  libqt5widgets5  qtcreator qtbase5-dev qt5-qmake cmake
  • 1

5.3 python-sip配置相关

sudo apt install  sip-dev python3-sip-dev python3-pyqt5.sip
sudo apt install  python3-pyqt5.sip python3-pyqt5 pyqt5-dev 
  • 1
  • 2

5.4 std::share_mutex 相关 c++11 与c++17

下载 change_cpp.py 文件到ws路径下,change_cpp.py

import os
from colorama import Fore, Style

WANTED_WIDTH = 100
DISPLAY_WIDTH = min(WANTED_WIDTH, os.get_terminal_size().columns - 2)
print("┏" + "".center(DISPLAY_WIDTH, "━") + "┓")
print(f"┃{Fore.RED}" + "CMakeLists to C++17 Utils".center(DISPLAY_WIDTH, " ") + f"{Style.RESET_ALL}┃")
print(f"┃{Style.BRIGHT+ Fore.BLACK}" + "Meltwin - 2023".center(DISPLAY_WIDTH, " ") + f"{Style.RESET_ALL}┃")
print("┗" + "".center(DISPLAY_WIDTH, "━") + "┛")
print()

REPLACE_FILTER = {
    "-std=c++11":"-std=c++17",
    "COMPILER_SUPPORTS_CXX11": "COMPILER_SUPPORTS_CXX17",
    "CMAKE_CXX_STANDARD 11": "CMAKE_CXX_STANDARD 17",
    "CMAKE_CXX_STANDARD 14": "CMAKE_CXX_STANDARD 17"
}

def fix_cmakelist(cmakelist_path: str) -> None:
    print(f"{Fore.YELLOW}{Fore.RESET}Found {Fore.RED}{cmakelist_path}{Fore.RESET}", end=" ")
    with open(cmakelist_path, "r") as handle:
        data = handle.read()

    # Replacing
    changed = False
    for key, value in REPLACE_FILTER.items():
        if data.find(key) != -1:
            data = data.replace(key, value)
            changed = True

    if changed:
        with open(cmakelist_path, "w") as handle:
            handle.write(data)
    print(f"{Fore.GREEN}Fixed !" if changed else f"{Fore.BLUE}Nothing to change")

def walk_dir(dir: str, depth = 0) -> None:
    if depth >=2:
        return
    for d in os.listdir(dir):
        cmakelist_path = f"{dir}/{d}/CMakeLists.txt"
        if not os.path.isfile(cmakelist_path):
            walk_dir(f"{dir}/{d}", depth+1)
        else :
            fix_cmakelist(cmakelist_path)

if __name__ == "__main__":
    # Get all the CMakeLists.txt
    walk_dir("./src")
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48

将当前src目录下工程cmake中c++17方式的调整为c++11

  python3 change_cpp.py
  • 1

5.5 opencv库的安装

 sudo apt install  libopencv-dev
  • 1

5.6 assimp 库安装

 sudo apt install  libassimp-dev python3-pyassimp
  • 1

5.7 ogre库的安装

sudo apt install  libogre-1.12-dev
sudo apt install  libogre1.12.10
  • 1
  • 2

5.8 ogre库中class Vector3 传统问题,

注释掉文件plant_flag_tool.h imu_visual.h 中的class Vector3 定义

gedit /opt/ros/noetic_ws/src/visualization_tutorials/rviz_plugin_tutorials/src/plant_flag_tool.h

namespace Ogre
{
class SceneNode;
//class Vector3;
}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
gedit /opt/ros/noetic_ws/src/visualization_tutorials/rviz_plugin_tutorials/src/imu_visual.h

namespace Ogre
{
//class Vector3;
class Quaternion;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

编译基本就可以通过了,一共184个包

<== Finished processing package [184 of 184]: 'xacro'

  • 1
  • 2

6. 安装版

当前路径安装 或 指定路径安装

./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release
  • 1
sudo ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release --install-space /opt/ros/noetic
  • 1

=================================

24.04

sudo apt install libqt5widgets5 qtcreator qtbase5-dev qt5-qmake cmake
sudo apt install sip-dev python3-sip-dev python3-pyqt5.sip
sudo apt install python3-pyqt5.sip python3-pyqt5 pyqt5-dev
sudo apt install gedit
sudo apt install libogre-1.12-dev
sudo apt install libogre1.12.10
sudo apt install libboost-dev libboost-thread-dev libpoco-dev libboost-filesystem-dev libboost-prog libboost-program-options-dev libboost-regex-dev liblog4cxx-dev libtinyxml-dev python3-nose liburdfdom-dev libgpgme-dev libboost-timer-dev libboost-python-dev

logger->forcedLog(g_level_lookup[level], str, log4cxx::spi::LocationInfo(file, file, function, line));

https://github.com/votca/votca/pull/1083/commits/f4703be55622bb69bb2dcc49c3f50fdb920b7614
//#include <boost/progress.hpp>
#include <boost/timer/progress_display.hpp>

boost::scoped_ptr<boost::timer::progress_display> progress;
  • 1
本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/小桥流水78/article/detail/1011239
推荐阅读
相关标签
  

闽ICP备14008679号