ROS交流群
ROS Group
产品服务
Product Service
开源代码库
Github
官网
Official website
技术交流
Technological exchanges
激光雷达
LIDAR
ROS教程
ROS Tourials
深度学习
Deep Learning
机器视觉
Computer Vision

如何优雅的从源码安装ros软件包


  • administrators

    当我们从源码安装ROS软件包时经常会遇到一个问题 xxxx-config.cmake没有找到。这是由于这个软件包依赖于其他软件包,但是被依赖的软件包没有安装。一般就要根据xxx-config去推测到底是哪个包没有安装。由于系统版本不一样,软件包推测起来有时也比较困难。而且安装完一个再编译一次,出错再安装,效率非常低。实际上ROS可以自动处理这些问题。下面以velodyne雷达驱动为例说明一下安装方法。

    官方的velodyne只发布到了kinetic版本,melodic版本需要从源码编译。

    首先下载源码到工作空间的src文件夹

    cd [你的工作空间]/src
    git clone https://github.com/ros-drivers/velodyne
    

    使用rosdep自动安装依赖

    cd ..
    rosdep install --from-paths src --ignore-src -r -y
    

    根据提示输入管理员密码,程序开始自动安装依赖。正常终端会如下输出。可以看到rosdep自动安装了libpcap0.8-dev这个包。

    shunya@hikey970:~/ros$ rosdep install --from-paths src --ignore-src -r -y
    executing command [sudo -H apt-get install -y libpcap0.8-dev]
    [sudo] password for shunya:
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    The following additional packages will be installed:
      libpcap0.8
    The following NEW packages will be installed:
      libpcap0.8 libpcap0.8-dev
    0 upgraded, 2 newly installed, 0 to remove and 16 not upgraded.
    Need to get 348 kB of archives.
    After this operation, 967 kB of additional disk space will be used.
    Get:1 http://cdn-fastly.deb.debian.org/debian stretch/main arm64 libpcap0.8 arm64 1.8.1-3 [123 kB]
    Get:2 http://cdn-fastly.deb.debian.org/debian stretch/main arm64 libpcap0.8-dev arm64 1.8.1-3 [224 kB]
    Fetched 348 kB in 6s (53.5 kB/s)
    Selecting previously unselected package libpcap0.8:arm64.
    (Reading database ... 143487 files and directories currently installed.)
    Preparing to unpack .../libpcap0.8_1.8.1-3_arm64.deb ...
    Unpacking libpcap0.8:arm64 (1.8.1-3) ...
    Selecting previously unselected package libpcap0.8-dev.
    Preparing to unpack .../libpcap0.8-dev_1.8.1-3_arm64.deb ...
    Unpacking libpcap0.8-dev (1.8.1-3) ...
    Processing triggers for libc-bin (2.24-11+deb9u3) ...
    Processing triggers for man-db (2.7.6.1-2) ...
    Setting up libpcap0.8:arm64 (1.8.1-3) ...
    Setting up libpcap0.8-dev (1.8.1-3) ...
    Processing triggers for libc-bin (2.24-11+deb9u3) ...
    #All required rosdeps installed successfully
    
    

    这时候就可以开始编译了

    catkin_make
    

    等待编译完成就可以了。