文章

Docker + ROS2 开发环境搭建指南

Docker + ROS2 开发环境搭建指南

概述

本文介绍了如何使用 Docker 容器化技术搭建 ROS2 开发环境,包括官方镜像资源、相关学习资源、实践案例以及问题及解决方案等内容。通过容器化部署,可以实现环境隔离、快速部署和跨平台兼容,大大提升 ROS2 开发效率。

本文重点在于 Docker 和 ROS2 结合使用这一场景,着重说明遇到的几个案例及相关的配置文件,对于 Docker 本身的使用指南建议查阅 Docker 使用指南,关于 Docker 的安装和配置请查看其中的 相应章节

关于在 Windows 上搭建 ROS 环境的建议:

如果你想搭建过程比较简单,那么建议你使用 WSL,WSL 支持安装多个 Ubuntu 版本,包括 20.04、22.04、24.04等,这对于安装不同 ROS 版本是非常友好的。

如果你相比简单性,更看重可移植性(比如你换了个电脑)和移植的快速性,那么建议你结合 WSL 使用 Docker。

至于安装 VMware 虚拟机 或 VirtualBox 虚拟机,这是过时的方法,这种方式启动速度慢,GUI 也较卡,且无法使用硬件加速,更无法使用 GPU 进行深度学习和训练等。

运行环境 vs 开发环境:

运行环境:

  • 仅 Docker 配置文件(由 Dockerfile、docker-compose.yaml、.env 等文件定义)
  • 通常精简化,只包含运行时依赖
  • 专注于应用程序的运行和部署

开发环境:

  • Dev Container + Docker 配置文件的组合
  • 包含开发工具、调试器、代码编辑器插件等
  • 提供完整的开发体验

本文后续的实践案例中,既包括开发环境,也包括运行环境。

ROS 官方镜像资源

ROS 提供了不同用途的官方 Docker 镜像:

其他相关资源:

学习资源

ROS2 官方文档

Docker 官方文档

下面将罗列一些实践案例。

官方示例:Talker/Listener

这是 ROS2 官方教程的经典示例,适合学习和测试。

参考文档: ROS2 官方容器化指南

docker-compose.yaml

1
2
3
4
5
6
7
8
9
services:
  talker:
    build: .
    command: ros2 run demo_nodes_cpp talker
  listener:
    build: .
    command: ros2 run demo_nodes_cpp listener
    depends_on:
      - talker

Dockerfile

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# Select the base image, such as humble or jazzy
FROM ros:humble

#ENV SHELL=/bin/bash

RUN apt update && apt install ros-humble-demo-nodes-cpp -y

# ********************************************************
# * Anything else you want to do like clean up goes here *
# ********************************************************

# Use my profile repository to set up the environment
# git clone https://github.com/wsxq2/profile.git ~/.MyProfile && cd ~/.MyProfile && ./deploy.sh $HTTP_PROXY_HOST

# [Optional] Set the default user. Omit if you want to keep the default as root.

ROS1/ROS2 桥接

⚠️ 注意: ROS1 Bridge 已逐步被弃用,仅在早期 ROS2 版本(如 Galactic)中支持,Humble 及以后版本不再提供支持。

主要限制:

  • 要求系统同时安装 ROS1 和 ROS2 环境
  • 配置复杂,兼容性问题较多
  • 建议: 新项目直接使用 ROS2,避免使用桥接

参考文档:Docker中部署ROS1和ROS2并实现互通

docker-compose.yaml

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
services:
  ros1:
    build:
      context: .
      dockerfile: ros1.Dockerfile
    networks:
      - rosnetwork
    command: rosrun roscpp_tutorials talker

  ros2:
    build:
      context: .
      dockerfile: ros2.Dockerfile
    networks:
      - rosnetwork
    environment:
      - ROS_DOMAIN_ID=1
    command: ros2 run demo_nodes_cpp listener

  bridge:
    build:
      context: .
      dockerfile: bridge.Dockerfile
    command: ros2 run ros1_bridge dynamic_bridge
    environment:
      - ROS_MASTER_URI=http://172.19.0.1:11311
      - ROS_DOMAIN_ID=1
    networks:
      - rosnetwork

networks:
  rosnetwork:

ros1.Dockerfile

1
2
3
4
5
6
7
8
9
ARG ROS_DISTRO=noetic

FROM ros:$ROS_DISTRO

# 安装ROS包
RUN apt-get update && apt-get install -y \
      ros-${ROS_DISTRO}-ros-tutorials \
      ros-${ROS_DISTRO}-common-tutorials && \
    rm -rf /var/lib/apt/lists/*

ros2.Dockerfile

1
2
3
4
5
6
7
8
ARG ROS_DISTRO=humble

FROM ros:${ROS_DISTRO}

# 安装ROS包
RUN apt-get update && apt-get install -y \
      ros-${ROS_DISTRO}-demo-nodes-cpp && \
    rm -rf /var/lib/apt/lists/*

bridge.Dockerfile

1
2
3
4
5
FROM ros:galactic-ros1-bridge

# 设置环境变量
ENV ROS_HOSTNAME=bridge
ENV ROS_MASTER_URI=http://ros1:11311

使用总结

在同一主机上,Docker 容器 ros1 + ros2 + bridge 的组合能成功,但其中的 ros1 如果使用主机的 ros1 则会失败。

由于 bridge 只是 ROS2 发展前期的过渡产品,仅前几个 ROS 版本支持(humble 就已经不支持了),它要求较高,系统中必须同时安装 ROS1 和 ROS2 的环境(如 bridge 容器中就是如此),所以现在尽量不要使用它

RQT 图形化开发环境

用于开发 RQT 插件和图形化调试工具:

特点:

  • 基于 osrf/ros:humble-desktop 镜像
  • 集成完整的 GUI 开发环境
  • 支持 X11 转发

VNC方式可参考:docker-ros2-desktop-vnc

Dockerfile

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
FROM osrf/ros:humble-desktop

# Set proxy host and port
ARG HTTP_PROXY_HOST=host.docker.internal
ARG HTTP_PROXY_PORT=7890

# Replace with your proxy host and port or comment out if not needed
ENV http_proxy=http://$HTTP_PROXY_HOST:$HTTP_PROXY_PORT
ENV https_proxy=$http_proxy

# Set the timezone to Shanghai
RUN echo 'Asia/Shanghai' > /etc/timezone && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

# Update the apt sources to use Tsinghua University's mirror
RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak
RUN <<EOF cat > /etc/apt/sources.list
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse
EOF

# Add ROS 2 apt repository
RUN apt-get install curl gnupg2 -y && curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
RUN mv /etc/apt/sources.list.d/ros2.sources /etc/apt/sources.list.d/ros2.sources.bak && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] https://mirrors.tuna.tsinghua.edu.cn/ros2/ubuntu jammy main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null

# 安装 rqt 及 Python 依赖
RUN apt-get update && \
    apt-get install -y python3-pip ros-humble-rqt unzip && \
    rm -rf /var/lib/apt/lists/*

# 安装最新版本的 clangd
RUN CLANGD_VERSION=$(curl -s https://api.github.com/repos/clangd/clangd/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') && \
    curl -L -o /tmp/clangd-linux.zip "https://github.com/clangd/clangd/releases/download/${CLANGD_VERSION}/clangd-linux-${CLANGD_VERSION}.zip" && \
    unzip /tmp/clangd-linux.zip -d /tmp/ && \
    find /tmp -name "clangd" -type f -executable -exec cp {} /usr/local/bin/clangd \; && \
    chmod +x /usr/local/bin/clangd && \
    rm -rf /tmp/clangd-linux.zip /tmp/clangd_*

# 手动模拟 rosdep init
RUN mkdir -p /etc/ros/rosdep/sources.list.d/ && curl -o /etc/ros/rosdep/sources.list.d/20-default.list -L https://mirrors.tuna.tsinghua.edu.cn/github-raw/ros/rosdistro/master/rosdep/sources.list.d/20-default.list

# set rosdep mirror to Tsinghua University
ENV ROSDISTRO_INDEX_URL=https://mirrors.tuna.tsinghua.edu.cn/rosdistro/index-v4.yaml

docker-compose.yaml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
services:
  ros2-gui:
    build: .
    container_name: ros2-gui
    ports:
      - "7400-7600:7400-7600/udp" # ROS2 DDS 互通端口
    volumes:
      - .:/workspace
      #- /tmp/.X11-unix:/tmp/.X11-unix # 挂载 X11 socket(Linux 下)
    environment:
      - DISPLAY=host.docker.internal:0.0 # Windows 下 X11,或根据你的 X server 设置调整
      - ROS_DOMAIN_ID=30
      - ROS_LOCALHOST_ONLY=0
      #- FASTRTPS_DEFAULT_PROFILES_FILE=/workspace/ros2_config.xml
    networks:
      - rosnet
    tty: true
    stdin_open: true
    #working_dir: /workspace

networks:
  rosnet:
    external: true

devcontainer.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
{
    "name": "ROS2 Humble rqt GUI",
    "dockerComposeFile": "../docker-compose.yml",
    "service": "ros2-gui",
    "workspaceFolder": "/workspace",
    "customizations": {
        "vscode": {
            "settings": {
                "terminal.integrated.shell.linux": "/bin/bash",
                "clangd.path": "/usr/local/bin/clangd"
            },
            "extensions": [
                "donjayamanne.python-extension-pack",
                "ms-ros.ros",
                "llvm-vs-code-extensions.vscode-clangd",
                "seanwu.vscode-qt-for-python"
            ]
        }
    },
    "postCreateCommand": "rosdep update && rosdep install --from-paths src --ignore-src -r -y"
}

Cartographer SLAM

APT 安装方式(推荐)

Cartographer 是 Google 开源的 2D/3D SLAM 解决方案。在 ROS2 中可通过包管理器一键安装:

1
sudo apt install ros-$ROS_DISTRO-cartographer-ros

特点:

  • 依赖包较多,安装耗时较长
  • 是生产环境推荐的安装方式
  • 官方仓库:ros2/cartographer_ros

这种方式下,Docker 相关配置就比较简单了。后续相关内容参考自:husarion/cartographer-docker

docker-compose.yaml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
services:
  cartographer:
    build: .
    volumes:
        - ./config/diffbot_lds_2d.lua:/pr2.lua
    command: >
      ros2 run cartographer_ros cartographer_node
        -configuration_directory /
        -configuration_basename pr2.lua

  cartographer-occ:
    build: .
    command: >
      ros2 run cartographer_ros cartographer_occupancy_grid_node
        -resolution 0.05
        -publish_period_sec 1.0

其中的 ./config/diffbot_lds_2d.lua 是 cartographer 的核心配置文件,由于它和具体的使用场景相关,需要手动调节,这里就不展开了。

Dockerfile

1
2
3
4
5
6
7
8
9
10
FROM ros:humble

ARG ROS_DISTRO=humble

RUN apt update && \
    apt install -y ros-$ROS_DISTRO-cartographer-ros && \
    # clean to make the image smaller
    apt autoremove -y && \
    apt clean && \
    rm -rf /var/lib/apt/lists/*

源码编译方式

适用于需要自定义功能的场景,例如添加全局重定位功能。

参考资源:

Dockerfile

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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Select the base image, such as humble or jazzy
FROM ros:humble

# Replace with your username
ARG USERNAME=wsxq2
ARG HTTP_PROXY_HOST=wsxq2
ARG USER_UID=1000
ARG USER_GID=$USER_UID

# Set proxy host and port
ARG HTTP_PROXY_HOST=192.168.56.200
ARG HTTP_PROXY_PORT=7890

# Replace with your proxy host and port or comment out if not needed
ENV http_proxy=http://$HTTP_PROXY_HOST:$HTTP_PROXY_PORT
ENV https_proxy=$http_proxy

# Set the timezone to Shanghai
RUN echo 'Asia/Shanghai' > /etc/timezone && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

# This allows sudo commands to inherit the proxy environment variables
RUN sed -i '/Defaults\s*env_reset/a Defaults env_keep = "http_proxy https_proxy ftp_proxy no_proxy DISPLAY XAUTHORITY"' /etc/sudoers

# Update the apt sources to use Tsinghua University's mirror
RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak
RUN <<EOF cat > /etc/apt/sources.list
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse
EOF

# Add ROS 2 apt repository
RUN apt-get install curl gnupg2 -y && curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
RUN mv /etc/apt/sources.list.d/ros2.sources /etc/apt/sources.list.d/ros2.sources.bak && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] https://mirrors.tuna.tsinghua.edu.cn/ros2/ubuntu jammy main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null

# Update the apt package index.
RUN apt-get update

# Install basic utilities and tools. Use while loop to ensure it retries on failure
RUN /bin/bash -c 'while true; do if apt-get install -y python3-pip command-not-found vim x11-apps; then break; fi; done'

# Delete user if it exists in container (e.g Ubuntu Noble: ubuntu)
RUN if id -u $USER_UID ; then userdel `id -un $USER_UID` ; fi

# Create the user
RUN groupadd --gid $USER_GID $USERNAME \
    && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
    #
    # [Optional] Add sudo support. Omit if you don't need to install software after connecting.
    && apt-get update \
    && apt-get install -y sudo \
    && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
    && chmod 0440 /etc/sudoers.d/$USERNAME

ENV SHELL /bin/bash

# ********************************************************
# * Anything else you want to do like clean up goes here *
# ********************************************************

# Use my profile repository to set up the environment
# git clone https://github.com/wsxq2/profile.git ~/.MyProfile && cd ~/.MyProfile && ./deploy.sh $HTTP_PROXY_HOST

# [Optional] Set the default user. Omit if you want to keep the default as root.
USER $USERNAME
CMD ["/bin/bash"]

devcontainer.json

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
{
    "name": "ROS 2 Development Container",
    "privileged": true,
    "remoteUser": "wsxq2",
    "build": {
        "dockerfile": "Dockerfile",
        "args": {
            "USERNAME": "wsxq2"
        }
    },
    "workspaceFolder": "/home/ws",
    "workspaceMount": "source=${localWorkspaceFolder},target=/home/ws,type=bind",
    "customizations": {
        "vscode": {
            "extensions":[
                "ms-vscode.cpptools",
                "ms-vscode.cpptools-themes",
                "twxs.cmake",
                "donjayamanne.python-extension-pack",
                "eamodio.gitlens",
                "ms-iot.vscode-ros",
                "llvm-vs-code-extensions.vscode-clangd"
            ]
        }
    },
    "containerEnv": {
        "DISPLAY": "192.168.56.200:0.0",
        "ROS_LOCALHOST_ONLY": "1",
        "ROS_DOMAIN_ID": "42"
    },
    "runArgs": [
        "--net=host",
        "--pid=host",
        "--ipc=host",
        "-e", "DISPLAY=${env:DISPLAY}"
    ],
    "mounts": [
       //"source=/tmp/.X11-unix,target=/tmp/.X11-unix,type=bind,consistency=cached",
       //"source=/dev/dri,target=/dev/dri,type=bind,consistency=cached"
    ],

    "postCreateCommand": "rosdep update && rosdep install --from-paths src --ignore-src -y && sudo chown -R $(whoami) /home/ws/"
}

在 Docker 中运行 RTABMAP

本部分展示了如何在 Docker 中的 ROS2 中运行 RTABMAP

Dockerfile

1
2
3
FROM introlab3it/rtabmap_ros:humble

RUN apt-get update && apt-get install ros-humble-image-transport-plugins -y && rm -rf /var/lib/apt/lists/

docker-compose.yaml

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
version: '3.8'

services:
  rtabmap:
    image: wsxq2/rtabmap_ros:humble
    container_name: rtabmap_mapping
    privileged: true
    stdin_open: true
    tty: true
    network_mode: host
    ipc: host
    environment:
      - DISPLAY
      - QT_X11_NO_MITSHM=1
      - ROS_HOME=/tmp/.ros
      - OMP_WAIT_POLICY=passive
    volumes:
      - ~/.ros:/tmp/.ros
      - /tmp/.X11-unix:/tmp/.X11-unix
    command: >
      ros2 launch rtabmap_demos robot_mapping_demo.launch.py 
      rtabmap_viz:=true 
      rviz:=true

  bag_player:
    image: introlab3it/rtabmap_ros:humble
    container_name: rtabmap_bag_player
    stdin_open: true
    tty: true
    network_mode: host
    ipc: host
    environment:
      - OMP_WAIT_POLICY=passive
      - ROS_HOME=/tmp/.ros
    volumes:
      - ~/.ros:/tmp/.ros
      - /tmp/.X11-unix:/tmp/.X11-unix
      - ./demo_mapping_bag:/tmp/demo_mapping_bag
    command: >
      /bin/bash -c "ros2 bag play /tmp/demo_mapping_bag/demo_mapping.db3 --clock"
    depends_on:
      - rtabmap

使用方法

使用前,需要安装并配置 Docker

完成后,从 Google Drive 下载 bag 文件并解压,解压后要保证目录结构如下所示:

1
2
3
4
5
6
7
./
├── demo_mapping_bag/
│   ├── demo_mapping.db3
│   └── metadata.yaml
├── docker-compose.yaml
├── Dockerfile
└── README.md

然后执行以下命令即可:

1
docker compose up

FAST-LIVO2 编译与运行及开发环境

这部分说明了四种情形:ROS1 Noetic、ROS1 Noetic + Docker、ROS2 Humble、ROS2 Humble + Docker。第一、三种情形仅描述了如何在已有的 ROS1 和 ROS2 环境中编译并运行 FAST-LIVO2,而第二、四种则在此基础上利用 Docker 搭建了一致的开发环境。

FAST-LIVO2 官方支持的是 ROS1 ,包括 Melodic、Noetic 这两个版本。FAST-LIVO2 中主要有两个组件,FAST-LIVO2 本身和 rpg_vikit,官方的 GitHub 链接如下:

对于 ROS2,有网友做了相应的移植,且有两个版本可供参考:

  1. https://github.com/integralrobotics/FAST-LIVO2
  2. https://github.com/Robotic-Developer-Road/FAST-LIVO2/tree/humble

其中对于第 2 个版本,由于没有公开 rpg_vikit 的源码,所以无法使用,因此使用第 1 个版本。其对应的 rpg_vikit 源码为 https://github.com/integralrobotics/rpg_vikit

虽然我们的目标是在 ROS2 humble 中使用,但对于官方 ROS1 版本的运行和测试也有一定的价值,比如:假如实际使用时,在 ROS2 humble 中遇到了问题,找不到解决思路时,可以回到 ROS1 版本中测试看该问题是否同样存在,以排除移植到 ROS2 中改动代码造成的影响。因此,下面先说 ROS1 的情况,再说 ROS2 中的情况。

ROS1 Noetic

如果你有该环境(无论是使用 WSL 还是 Linux主机),那么使用起来会非常简单,按照官方教程走即可,不过有个地方需要注意:在 Noetic 中,Sophus 编译不通过,报错:so2.cpp:32:26: error: lvalue required as left operand of assignment,这时需要手动改下代码,改动如下所示:

1
2
3
4
5
6
7
8
9
10
namespace Sophus
{

SO2::SO2()
{
-  unit_complex_.real() = 1.;
-  unit_complex_.imag() = 0.;
+  unit_complex_.real(1.);
+  unit_complex_.imag(0.);
}

另外,PCL、Eigen、OpenCV 这些依赖可以直接使用 apt 安装:

1
apt install libpcl-dev libeigen3-dev libopencv-dev -y

ROS1 Noetic + Docker

ROS1 noetic 是 FAST-LIVO2 官方支持的版本,本次实践目录结构如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
.
├── .devcontainer/
│   └── devcontainer.json
├── .vscode/
├── build/
├── data/ # bag 数据文件
├── devel/
├── docker/ # docker 相关文件
│   ├── .dockerignore
│   ├── .env
│   ├── Dockerfile
│   └── docker-compose.yml
├── src/ # FAST-LIVO2 源码文件
│   ├── FAST-LIVO2/
│   ├── rpg_vikit/
└── README.md

关键的几个文件下面逐一展示。

Dockerfile

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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# FAST-LIVO2 Development Docker Image
# Based on ROS Noetic (Ubuntu 20.04)

FROM osrf/ros:noetic-desktop-full

# Accept build arguments for proxy settings
ARG PROXY_HOST=host.docker.internal
ARG PROXY_PORT=7890

# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive
ENV ROS_DISTRO=noetic
ENV CATKIN_WS=/home/developer/workspace

# Set proxy environment variables if provided
ENV https_proxy=http://${PROXY_HOST}:${PROXY_PORT}
ENV http_proxy=$https_proxy
ENV no_proxy=localhost,127.0.0.1,::1,192.168.0.0/16

RUN echo 'Asia/Shanghai' > /etc/timezone && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

# Update the apt sources to use Tsinghua University's mirror
RUN <<EOF cat > /etc/apt/sources.list
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
EOF
# Add ROS 1 apt repository
RUN rm -rf /etc/apt/sources.list.d/ros1-snapshots.list && echo "deb https://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ focal main" | tee /etc/apt/sources.list.d/ros-latest.list > /dev/null && apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

# 手动模拟 rosdep init
RUN mkdir -p /etc/ros/rosdep/sources.list.d/ && curl -o /etc/ros/rosdep/sources.list.d/20-default.list -L https://mirrors.tuna.tsinghua.edu.cn/github-raw/ros/rosdistro/master/rosdep/sources.list.d/20-default.list

# set rosdep mirror to Tsinghua University
ENV ROSDISTRO_INDEX_URL=https://mirrors.tuna.tsinghua.edu.cn/rosdistro/index-v4.yaml

# Install system dependencies
RUN apt-get update && apt-get install -y \
    git \
    cmake \
    build-essential \
    libeigen3-dev \
    libpcl-dev \
    libopencv-dev \
    python3-catkin-tools \
    python3-rosdep \
    python3-rosinstall \
    python3-rosinstall-generator \
    python3-wstool \
    unzip \
    wget \
    nano \
    vim \
    htop \
    tmux \
    && rm -rf /var/lib/apt/lists/*

SHELL ["/bin/bash", "-c"]

# 安装最新版本的 clangd
RUN CLANGD_VERSION=$(curl -s https://api.github.com/repos/clangd/clangd/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') && \
    curl -L -o /tmp/clangd-linux.zip "https://github.com/clangd/clangd/releases/download/${CLANGD_VERSION}/clangd-linux-${CLANGD_VERSION}.zip" && \
    unzip /tmp/clangd-linux.zip -d /tmp/clangd-linux && \
    cp -r /tmp/clangd-linux/*/{bin,lib} /usr/local && \
    chmod +x /usr/local/bin/clangd && \
    rm -rf /tmp/clangd-linux.zip /tmp/clangd-linux
    
# Create a non-root user
RUN useradd -m -s /bin/bash developer && \
    echo "developer:developer" | chpasswd && \
    usermod -aG sudo developer && \
    echo developer ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/developer && \
    chmod 0440 /etc/sudoers.d/developer

# Switch to developer user
USER developer
WORKDIR /home/developer

# Initialize rosdep
RUN rosdep update

# Create catkin workspace
RUN mkdir -p ${CATKIN_WS}/src
WORKDIR ${CATKIN_WS}

# Install Sophus (specific version for FAST-LIVO2)
RUN cd /tmp && \
    curl -OL https://github.com/strasdat/Sophus/archive/a621ff2e56c56c839a6c40418d42c3c254424b5c.zip && \
    unzip a621ff2e56c56c839a6c40418d42c3c254424b5c.zip && \
    cd Sophus-* && \
    sed -i -E \
    -e 's/unit_complex_\.real\(\) = ([0-9.]+);/unit_complex_.real(\1);/' \
    -e 's/unit_complex_\.imag\(\) = ([0-9.]+);/unit_complex_.imag(\1);/' \
    ./sophus/so2.cpp && \
    mkdir build && cd build && \
    cmake .. && \
    make -j$(nproc) && \
    sudo make install && \
    rm -rf /tmp/Sophus

RUN git clone https://github.com/wsxq2/profile.git ~/.MyProfile && cd ~/.MyProfile && ./deploy.sh ${PROXY_HOST}

# Set up environment
RUN echo "source /opt/ros/${ROS_DISTRO}/setup.bash" >> ~/.bashrc && \
    echo "source ${CATKIN_WS}/devel/setup.bash" >> ~/.bashrc && \
    echo "export ROS_PACKAGE_PATH=\$ROS_PACKAGE_PATH:${CATKIN_WS}" >> ~/.bashrc && \
    echo "export ROS_WORKSPACE=${CATKIN_WS}" >> ~/.bashrc && \
    echo "export DISABLE_ROS1_EOL_WARNINGS=1" >> ~/.bashrc

# Set working directory
WORKDIR ${CATKIN_WS}

# Expose common ROS ports
EXPOSE 11311

# Default command
CMD ["/bin/bash"]

docker-compose.yaml

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
services:
  fast-livo2-dev:
    build:
      context: .
      dockerfile: Dockerfile
      args:
        - PROXY_HOST=${PROXY_HOST:-host.docker.internal}
        - PROXY_PORT=${PROXY_PORT:-7890}
    image: fast-livo2:dev
    container_name: fast-livo2-development
    
    # Enable GUI applications (for RViz, etc.)
    environment:
      - DISPLAY=${DISPLAY}
      - QT_X11_NO_MITSHM=1
      - XAUTHORITY=/tmp/.docker.xauth
    
    volumes:
      # X11 forwarding for GUI applications
      - /tmp/.X11-unix:/tmp/.X11-unix:rw
      - /tmp/.docker.xauth:/tmp/.docker.xauth:rw
      
      # Mount your local development directory
      - ../:/home/developer/workspace:rw
      
    # Network mode for ROS communication
    network_mode: "host"
    
    # Keep container running
    stdin_open: true
    tty: true
    
    # Privileged mode for hardware access (if needed for sensors)
    privileged: true
    
    # Working directory
    working_dir: /home/developer/workspace
    
    # Default command
    command: /bin/bash

.env

1
2
3
4
5
6
7
8
9
# Environment variables for Docker Compose
# You can modify these values according to your network configuration

# Proxy settings (uncomment and modify if you need to use a proxy)
PROXY_HOST=host.docker.internal
PROXY_PORT=7890

# Display settings for GUI applications
DISPLAY=host.docker.internal:0.0

devcontainer.json

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
{
    "name": "FAST-LIVO2 Development",
    "dockerComposeFile": ["../docker/docker-compose.yml"],
    "service": "fast-livo2-dev",
    "workspaceFolder": "/home/developer/workspace",
    
    // 基本扩展
    "customizations": {
        "vscode": {
            "extensions": [
                "ms-vscode.cmake-tools",
                "ms-iot.vscode-ros",
                "llvm-vs-code-extensions.vscode-clangd"
            ],
            "settings": {
                "http.proxy": "http://host.docker.internal:7890",
                "http.proxyStrictSSL": false,
                "clangd.path": "/usr/local/bin/clangd",
                "C_Cpp.intelliSenseEngine": "disabled",
                "terminal.integrated.defaultProfile.linux": "bash",
                "terminal.integrated.profiles.linux": {
                    "bash": {
                        "path": "/bin/bash",
                        "args": [
                            "-l"
                        ]
                    }
                }
            }
        }
    },
}

使用方法

使用前,需要安装并配置 Docker

完成后,需要从 fast-livo2-dataset - OneDrive 下载 bag 数据。建议下载最小的 Retail_Street.bag。解压并放置到 data/ 目录。

下载源码:

1
2
3
cd src
git clone https://github.com/hku-mars/FAST-LIVO2.git
git clone https://github.com/xuankuzcr/rpg_vikit.git 

此时检查下目录结构,确保目录结构如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
.
├── .devcontainer/
│   └── devcontainer.json
├── .vscode/
├── data/ # bag 数据文件
│   └── Retail_Street.bag
├── docker/ # docker 相关文件
│   ├── .dockerignore # 可选
│   ├── .env
│   ├── Dockerfile
│   └── docker-compose.yml
├── src/ # FAST-LIVO2 源码文件
│   ├── FAST-LIVO2/
│   ├── rpg_vikit/
└── README.md

根据实际情况调整下 .env 文件中的内容。其中有三个变量,均要正确配置:

  • PROXY_HOST:当前设置的是你的主机。这通常是正确的,因为容器一般运行在本地主机上。但你需要确保你开启了 clash 之类的 fq 工具,且需要启用“Allow LAN”相关设置。目前支持的是 HTTP 代理。
  • PROXY_PORT:当前设置是 7890。这是 clash 的默认端口。
  • DISPLAY:当前设置的是你的主机。这要求你在主机上安装 X11 服务器,例如 vcxsrv。如果没有正确设置此变量,会导致你无法启动 RVIZ 等 GUI 工具。

此外 devcontainer.json 中也需要配置代理变量,否则 vscode 拓展可能无法下载。该变量当前为:

1
"http.proxy": "http://host.docker.internal:7890",

如前所述,你需要根据自己的实际情况修改。

然后在 WSL 中使用code .命令运行 VS Code,然后点击左下角,选择“Reopen folder in container”,等待一段时间后即可自动完成环境搭建。完成后打开 VS Code 中的 Terminal,先进行编译操作和 source:

1
2
catkin_make
source ./devel/setup.bash

然后执行以下命令(打开两个 Teminal 分别执行):

1
2
roslaunch fast_livo mapping_avia.launch
rosbag play data/Retail_Street.bag

ROS2 Humble

这部分主要参考自 https://github.com/integralrobotics/FAST-LIVO2 中的 README.md 说明,但细节上有所完善和优化。

类似地,这里假设你有 ROS2 Humble 的环境,则可以按照以下步骤进行:

执行以下命令安装依赖并下载源码:

1
2
3
4
5
6
sudo apt install libpcl-dev libeigen3-dev libopencv-dev -y
sudo apt install ros-humble-sophus -y # 直接使用 apt 中提供的版本,而非手动编译特定版本并安装到系统
sudo apt install ros-humble-image-transport-plugins -y # 不安装这个会编译失败
cd fast_ws/src # 如果没有请自行创建此目录
git clone https://github.com/integralrobotics/FAST-LIVO2
git clone https://github.com/integralrobotics/rpg_vikit

参考 https://github.com/Livox-SDK/livox_ros_driver2 安装 livox_ros_driver2,这是移植到 ROS2 后新增的包。

此时目录结构如下:

1
2
3
4
5
./
└── src/
    ├── FAST-LIVO2/
    ├── livox_ros_driver2/
    └── rpg_vikit/

编译时执行以下命令:

1
2
cd src/livox_ros_driver2
./build.sh humble

这里由于 livox_ros_driver2 的设计问题,编译时建议这样编译,否则可能编译不通过。

运行前需要转换 bag 格式,将原本的 ROS1 格式转换为 ROS2 格式:

1
2
pip install rosbags
rosbags-convert --src Retail_Street.bag --dst Retail_Street

转换完成后需要修改消息类型,在 Retail_Street/metadata.yaml 中做出以下修改:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
rosbag2_bagfile_information:
  compression_format: ''
  compression_mode: ''
  custom_data: {}
  duration:
    nanoseconds: 135470252209
  files:
  - duration:
      nanoseconds: 135470252209
    message_count: 30157
    path: Retail_Street.db3
    ..............
    topic_metadata:
      name: /livox/lidar
      offered_qos_profiles: ''
      serialization_format: cdr
-     type: livox_ros_driver/msg/CustomMsg
+     type: livox_ros_driver2/msg/CustomMsg
      type_description_hash: RIHS01_94041b4794f52c1d81def2989107fc898a62dacb7a39d5dbe80d4b55e538bf6d

编译完成后在不同的 Terminal 中分别运行:

1
2
ros2 launch fast_livo mapping_aviz.launch.py use_rviz:=True
ros2 bag play -p --clock Retail_Street  # 启动后处于暂停状态,前者准备就绪后即可使用空格键开始 play

ROS2 Humble + Docker

ROS2 humble 不是 FAST-LIVO2 官方支持的版本,使用的是 网友移植的版本。目录结构和 前面 基本相同。

总体来说,这部分综合了 ROS1 Noetic + DockerROS2 Humble 的内容。

关键的几个文件下面逐一展示。

Dockerfile

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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# FAST-LIVO2 Development Docker Image
# Based on ROS Humble (Ubuntu 22.04)

FROM osrf/ros:humble-desktop

# Accept build arguments for proxy settings
ARG PROXY_HOST=host.docker.internal
ARG PROXY_PORT=7890

# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive
ENV ROS_DISTRO=humble
ENV LIVO2_WS=/home/developer/livo2_ws

# Set proxy environment variables if provided
ENV https_proxy=http://${PROXY_HOST}:${PROXY_PORT}
ENV http_proxy=$https_proxy
ENV no_proxy=localhost,127.0.0.1,::1,192.168.0.0/16

RUN echo 'Asia/Shanghai' > /etc/timezone && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

# Update the apt sources to use Tsinghua University's mirror
RUN <<EOF cat > /etc/apt/sources.list
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
EOF

# Add ROS 2 apt repository
RUN curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
RUN mv /etc/apt/sources.list.d/ros2.sources /etc/apt/sources.list.d/ros2.sources.bak && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] https://mirrors.tuna.tsinghua.edu.cn/ros2/ubuntu jammy main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null

# 手动模拟 rosdep init
RUN mkdir -p /etc/ros/rosdep/sources.list.d/ && curl -o /etc/ros/rosdep/sources.list.d/20-default.list -L https://mirrors.tuna.tsinghua.edu.cn/github-raw/ros/rosdistro/master/rosdep/sources.list.d/20-default.list

# set rosdep mirror to Tsinghua University
ENV ROSDISTRO_INDEX_URL=https://mirrors.tuna.tsinghua.edu.cn/rosdistro/index-v4.yaml

# Install system dependencies
RUN apt-get update && apt-get install -y \
    git \
    cmake \
    build-essential \
    libeigen3-dev \
    libpcl-dev \
    libopencv-dev \
    ros-${ROS_DISTRO}-sophus \
    ros-${ROS_DISTRO}-image-transport-plugins \
    ros-${ROS_DISTRO}-pcl-ros \
    python3-rosdep \
    unzip \
    vim \
    && rm -rf /var/lib/apt/lists/*

SHELL ["/bin/bash", "-c"]

# 安装最新版本的 clangd
RUN CLANGD_VERSION=$(curl -s https://api.github.com/repos/clangd/clangd/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') && \
    curl -L -o /tmp/clangd-linux.zip "https://github.com/clangd/clangd/releases/download/${CLANGD_VERSION}/clangd-linux-${CLANGD_VERSION}.zip" && \
    unzip /tmp/clangd-linux.zip -d /tmp/clangd-linux && \
    cp -r /tmp/clangd-linux/*/{bin,lib} /usr/local && \
    chmod +x /usr/local/bin/clangd && \
    rm -rf /tmp/clangd-linux.zip /tmp/clangd-linux
    
# Install Livox-SDK2
RUN <<EOF
cd /tmp
curl -OL https://github.com/Livox-SDK/Livox-SDK2/archive/refs/heads/master.zip
unzip master.zip
rm master.zip
cd ./Livox-SDK2-master
mkdir build
cd build
cmake .. && make -j
sudo make install
rm -rf /tmp/Livox-SDK2*
EOF

    
# Create a non-root user
RUN useradd -m -s /bin/bash developer && \
    echo "developer:developer" | chpasswd && \
    usermod -aG sudo developer && \
    echo developer ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/developer && \
    chmod 0440 /etc/sudoers.d/developer

# Switch to developer user
USER developer
WORKDIR /home/developer

# Initialize rosdep
RUN rosdep update

RUN mkdir -p ${LIVO2_WS}/src
WORKDIR ${LIVO2_WS}

RUN git clone https://github.com/wsxq2/profile.git ~/.MyProfile && cd ~/.MyProfile && ./deploy.sh ${PROXY_HOST}

# Set up environment
RUN echo "source /opt/ros/${ROS_DISTRO}/setup.bash" >> ~/.bashrc && \
    echo "source ${LIVO2_WS}/install/setup.bash" >> ~/.bashrc && \
    echo "export ROS_PACKAGE_PATH=\$ROS_PACKAGE_PATH:${LIVO2_WS}" >> ~/.bashrc && \
    echo "export ROS_WORKSPACE=${LIVO2_WS}" >> ~/.bashrc && \

# Set working directory
WORKDIR ${LIVO2_WS}

# Default command
CMD ["/bin/bash"]

docker-compose.yaml

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
services:
  fast-livo2-dev-humble:
    build:
      context: .
      dockerfile: Dockerfile
      args:
        - PROXY_HOST=${PROXY_HOST:-host.docker.internal}
        - PROXY_PORT=${PROXY_PORT:-7890}
    image: fast-livo2:humble
    container_name: fast-livo2-development-humble
    
    # Enable GUI applications (for RViz, etc.)
    environment:
      - DISPLAY=${DISPLAY}
      - QT_X11_NO_MITSHM=1
      - XAUTHORITY=/tmp/.docker.xauth
    
    volumes:
      # X11 forwarding for GUI applications
      - /tmp/.X11-unix:/tmp/.X11-unix:rw
      - /tmp/.docker.xauth:/tmp/.docker.xauth:rw
      
      # Mount your local development directory
      - ../:/home/developer/livo2_ws:rw
      
    # Network mode for ROS communication
    network_mode: "host"
    
    # Keep container running
    stdin_open: true
    tty: true
    
    # Privileged mode for hardware access (if needed for sensors)
    privileged: true

.env

1
2
3
4
5
6
7
8
9
# Environment variables for Docker Compose
# You can modify these values according to your network configuration

# Proxy settings (uncomment and modify if you need to use a proxy)
PROXY_HOST=host.docker.internal
PROXY_PORT=7890

# Display settings for GUI applications
DISPLAY=host.docker.internal:0.0

devcontainer.json

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
{
    "name": "FAST-LIVO2 Development For Humble",
    "dockerComposeFile": ["../docker/docker-compose.yml"],
    "service": "fast-livo2-dev-humble",
    "workspaceFolder": "/home/developer/livo2_ws",
    
    // 基本扩展
    "customizations": {
        "vscode": {
            "extensions": [
                "ms-vscode.cmake-tools",
                "ms-iot.vscode-ros",
                "llvm-vs-code-extensions.vscode-clangd"
            ],
            "settings": {
                "http.proxy": "http://host.docker.internal:7890",
                "http.proxyStrictSSL": false,
                "clangd.path": "/usr/local/bin/clangd",
                "C_Cpp.intelliSenseEngine": "disabled",
                "terminal.integrated.defaultProfile.linux": "bash",
                "terminal.integrated.profiles.linux": {
                    "bash": {
                        "path": "/bin/bash",
                        "args": [
                            "-l"
                        ]
                    }
                }
            }
        }
    },
}

使用方法

使用前,需要安装并配置 Docker

完成后,在 WSL 中执行以下命令安装依赖并下载源码:

1
2
3
4
cd ./src # 如果没有请自行创建此目录
git clone https://github.com/integralrobotics/FAST-LIVO2
git clone https://github.com/integralrobotics/rpg_vikit
git clone https://github.com/Livox-SDK/livox_ros_driver2

然后从 fast-livo2-dataset - OneDrive 下载 bag 数据。建议下载最小的 Retail_Street.bag。解压并放置到 data/ 目录。

新建前述文件并放置到正确目录,使目录结构如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
./
├── .devcontainer/
│   └── devcontainer.json
├── .vscode/
├── data/
│   └── Retail_Street.bag
├── docker/
│   ├── .env
│   ├── Dockerfile
│   └── docker-compose.yml
├── src/
│   ├── FAST-LIVO2/
│   ├── livox_ros_driver2/
│   └── rpg_vikit/
└── README.md

根据实际情况调整下 .env 文件中的内容。其中有三个变量,均要正确配置:

  • PROXY_HOST:当前设置的是你的主机。这通常是正确的,因为容器一般运行在本地主机上。但你需要确保你开启了 clash 之类的 fq 工具,且需要启用“Allow LAN”相关设置。目前支持的是 HTTP 代理。
  • PROXY_PORT:当前设置是 7890。这是 clash 的默认端口。
  • DISPLAY:当前设置的是你的主机。这要求你在主机上安装 X11 服务器,例如 vcxsrv。如果没有正确设置此变量,会导致你无法启动 RVIZ 等 GUI 工具。

此外 devcontainer.json 中也需要配置代理变量,否则 vscode 拓展可能无法下载。该变量当前为:

1
"http.proxy": "http://host.docker.internal:7890",

如前所述,你需要根据自己的实际情况修改。

然后在 WSL 中使用code .命令运行 VS Code,然后点击左下角,选择“Reopen folder in container”,等待一段时间后即可自动完成环境搭建。完成后打开 VS Code 中的 Terminal(这里打开的 Teminal 就不再是 WSL 了,而是在 Container 中,即 ROS2 Humble 的环境中),先进行编译操作和 source:

1
2
3
4
cd src/livox_ros_driver2
./build.sh humble
cd -
source ./install/setup.bash

这里由于 livox_ros_driver2 的设计问题,编译时建议这样编译,否则可能编译不通过。

运行前需要转换 bag 格式,将原本的 ROS1 格式转换为 ROS2 格式:

1
2
3
pip install rosbags
cd ./data/
rosbags-convert --src Retail_Street.bag --dst Retail_Street

转换完成后需要修改消息类型,在 data/Retail_Street/metadata.yaml 中做出以下修改:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
rosbag2_bagfile_information:
  compression_format: ''
  compression_mode: ''
  custom_data: {}
  duration:
    nanoseconds: 135470252209
  files:
  - duration:
      nanoseconds: 135470252209
    message_count: 30157
    path: Retail_Street.db3
    ..............
    topic_metadata:
      name: /livox/lidar
      offered_qos_profiles: ''
      serialization_format: cdr
-     type: livox_ros_driver/msg/CustomMsg
+     type: livox_ros_driver2/msg/CustomMsg
      type_description_hash: RIHS01_94041b4794f52c1d81def2989107fc898a62dacb7a39d5dbe80d4b55e538bf6d

编译完成后在不同的 Terminal 中分别运行:

1
2
ros2 launch fast_livo mapping_aviz.launch.py use_rviz:=True
ros2 bag play -p --clock ./data/Retail_Street  # 启动后处于暂停状态,前者准备就绪后即可使用空格键开始 play

遇到过的问题

X11 方式访问 RVIZ 经常发生错乱现象?

环境说明:Windows11 + Docker Desktop(使用 WSL2) + ROS humble desktop 镜像

尝试了以下步骤:

  1. 更新 vcxsrv:marchaesen/vcxsrv: Windows X-server based on the xorg git sources (like xming or cygwin’s xwin), but compiled with Visual Studio 2012 Community Edition.
  2. 更新显卡驱动:Drivers and Support for Processors and Graphics

然后目前暂未发现错乱现象,疑似解决了。

其他一些尝试:

本文由作者按照 CC BY 4.0 进行授权