2020年12月31日木曜日

ultra96v2+ros2 eloquentでorb_slam2を動かしてみた話

ultra96v2向けにORB_SLAM2をビルドした話。 ORB_SLAM2のビルドにはPangolinとimage_commonが必要だったので、レシピを作成する。
上記以外の必要なものはmeta-rosに含まれていたものでOKだった。

準備

環境は前に作成したものと同じ。以下に示すレシピもmeta-ultra96v2に追加済なのでそのままビルドすれば実行できる。

Pangolinのビルド

recipetoolを使用してPangolinのレシピを作成してビルドしてみる。

{class="prettyprint lang-sh} recipetool create -o pangolin_git.bb https://github.com/stevenlovegrove/Pangolin.git mv pangolin_git.bb ../sources/meta-ultra96v2/recipes-graphics/pangolin MACHINE=ultra96v2-zynqmp bitbake pangolin

そのままのビルドではエラーが出た。 内容はdo_package_qa: QA Issue: pangolin-dev package contains non-symlink .so ここを参考にして、 パッケージするファイルを選択すると解消する。合ってるかどうかはいまいち自信がない。

あと、ライセンスも修正しておく。

レシピは以下の通り。

LICENSE = "MIT & BSD-3-Clause"
LIC_FILES_CHKSUM = "file://LICENCE;md5=37611e574d0acc5cc68f827d28a9ce8a \
                    file://include/pangolin/utils/xml/license.txt;md5=d63ab70ba21ca0544b03284958324301 \
                    file://external/pybind11/LICENSE;md5=beb87117af69fd10fbf9fb14c22a2e62 \
                    file://external/pybind11/tools/clang/LICENSE.TXT;md5=dfabea443c6c16b6321441a8c8c19705"

SRC_URI = "gitsm://github.com/stevenlovegrove/Pangolin.git;protocol=https"

# Modify these as desired
PV = "1.0+git${SRCPV}"
SRCREV = "86eb4975fc4fc8b5d92148c2e370045ae9bf9f5d"

S = "${WORKDIR}/git"


# NOTE: unable to map the following CMake package dependencies: Pangolin Eigen
inherit cmake
inherit python3native

DEPENDS = "libeigen glew virtual/libgl"

FILES_SOLIBSDEV = ""

FILES_${PN} += " ${libdir}/libpangolin.so"
FILES_${PN} += " ${bindir}/*"
FILES_${PN}-dev += " ${includedir}/*"


# Specify any options you want to pass to cmake using EXTRA_OECMAKE:
EXTRA_OECMAKE = ""

image-commonのビルド

recipetoolを使うとエラーが出てしまったので他のrosレシピを参考に手動で作成。 inherit ros_distro_eloquentと、inherit ros_superflore_generated、 ROS_BUILD_TYPE = “ament_cmake”、inherit ros_${ROS_BUILD_TYPE}を設定すれば良い。 ROS_CNはパッケージ名、ROS_BPNにはイメージ名を記載する。 buld_dependsなどはpackage.xmlに記載された設定と同じにする。 image-commonのパッケージからは4つイメージをビルドする必要があるので、 camera-calibration-parsers,camera-info-manager,image-common,image-transportの4つのレシピを作成する。 次はimage-commonの場合。レシピ名はimage-common_git.bbとしている。

LICENSE = "BSD"
#LIC_FILES_CHKSUM = "file://"

SRC_URI = "git://github.com/ros-perception/image_common.git;protocol=https;branch=ros2"

# Modify these as desired
PV = "1.0+git${SRCPV}"
SRCREV = "4c5053ecf703a58c25a712d1d4a80012f5076a1f"

S = "${WORKDIR}/git"

inherit ros_distro_eloquent
inherit ros_superflore_generated

DESCRIPTION = ""
AUTHOR = "Patrick Mihelich and James Bowman"
ROS_AUTHOR = ""
HOMEPAGE = "https://wiki.ros.org/image_common"
SECTION = "devel"

ROS_CN = "image-common"
ROS_BPN = "image-common"

ROS_BUILD_DEPENDS = ""

ROS_BUILDTOOL_DEPENDS = " \
    ament-cmake-native \
"

ROS_EXPORT_DEPENDS = ""

ROS_BUILDTOOL_EXPORT_DEPENDS = ""

ROS_EXEC_DEPENDS = " \
    camera-calibration-parsers \
    camera-info-manager \
    image-transport \
"

# Currently informational only -- see http://www.ros.org/reps/rep-0149.html#dependency-tags.
ROS_TEST_DEPENDS = " \
    ament-lint-auto \
    ament-lint-common \
"

DEPENDS = "${ROS_BUILD_DEPENDS} ${ROS_BUILDTOOL_DEPENDS}"
# Bitbake doesn't support the "export" concept, so build them as if we needed them to build this package (even though we actually
# don't) so that they're guaranteed to have been staged should this package appear in another's DEPENDS.
DEPENDS += "${ROS_EXPORT_DEPENDS} ${ROS_BUILDTOOL_EXPORT_DEPENDS}"

RDEPENDS_${PN} += "${ROS_EXEC_DEPENDS}"

ROS_BUILD_TYPE = "ament_cmake"

inherit ros_${ROS_BUILD_TYPE}

orb-slam2のビルド

pangolinとcamera-calibration-parsers,camera-info-manager,image-common,image-transportが必要。 これは準備したので、レシピを作成する。

recipetoolを使用してPangolinのレシピを作成してビルドしてみる。 が、meta-ros向けのレシピはうまく作ってくれないので手作業。 package.xmlから以下の通り生成する。 superfloreなんかを使うとこの辺はうまくやってくれるのだと思う。

レシピ名はorb-slam2_git.bbとした。

LICENSE = "GPLv3 & BSD-3-Clause"
LIC_FILES_CHKSUM = "file://License-gpl.txt;md5=d32239bcb673463ab874e80d47fae504 \
                    file://LICENSE.txt;md5=9f7421fb91aef33332dbdfab7e243c01 \
                    file://orb_slam2/Thirdparty/DBoW2/LICENSE.txt;md5=b91b90de616800c44c9ebba46c143a70 \
                    file://orb_slam2/Thirdparty/g2o/license-bsd.txt;md5=9c0c0561478261cb090e64115139d923"

SRC_URI = "git://github.com/appliedAI-Initiative/orb_slam_2_ros.git;protocol=https;branch=ros2"

# Modify these as desired
PV = "1.0+git${SRCPV}"
SRCREV = "0f964c618a2e0b7715c1c6fc49e6b70b2ba2c904"

S = "${WORKDIR}/git"

inherit ros_distro_eloquent
inherit ros_superflore_generated

DESCRIPTION = ""
AUTHOR = "Raul Mur-Artal, Juan D. Tardos, J. M. M. Montiel and Dorian Galvez-Lopez (DBoW2)."
ROS_AUTHOR = ""
HOMEPAGE = ""
SECTION = "devel"

ROS_CN = "orb-slam2"
ROS_BPN = "orb-slam2"

ROS_BUILD_DEPENDS = " \
    rclcpp \
    std-msgs \
    geometry-msgs \
    tf2-geometry-msgs \
    cv-bridge \
    image-common \
    image-transport \
    tf2-ros \
    sensor-msgs \
    rosidl-default-generators \
"

ROS_BUILDTOOL_DEPENDS = " \
    ament-cmake-native \
    rosidl-default-generators-native \
"

ROS_EXPORT_DEPENDS = " \
    boost \
    cairo \
    ceres-solver \
    gflags \
    glog \
    libeigen \
    lua \
    protobuf \
"

ROS_BUILDTOOL_EXPORT_DEPENDS = ""

ROS_EXEC_DEPENDS = " \
    rclcpp \
    std-msgs \
    geometry-msgs \
    cv-bridge \
    image-transport \
    tf2-ros \
    sensor-msgs \
    rosidl-default-runtime \
"

# Currently informational only -- see http://www.ros.org/reps/rep-0149.html#dependency-tags.
ROS_TEST_DEPENDS = " \
    ament-lint-auto \
    ament-lint-common \
"

DEPENDS = "${ROS_BUILD_DEPENDS} ${ROS_BUILDTOOL_DEPENDS}"
# Bitbake doesn't support the "export" concept, so build them as if we needed them to build this package (even though we actually
# don't) so that they're guaranteed to have been staged should this package appear in another's DEPENDS.
DEPENDS += "${ROS_EXPORT_DEPENDS} ${ROS_BUILDTOOL_EXPORT_DEPENDS}"

RDEPENDS_${PN} += "${ROS_EXEC_DEPENDS}"

FILES_${PN} += "*"

ROS_BUILD_TYPE = "ament_cmake"

inherit ros_${ROS_BUILD_TYPE}

動作確認

hostでrviz2を起動し、point_cloudをAddする。 debug_imageは追加してもカクカクなので見ない。

  • window1
source /opt/ros/foxy/setup.sh
rviz2

テスト用にTUM1のbagファイルを再生する。

  • window2
source /opt/ros/noetic/setup.sh
source /opt/ros/foxy/setup.sh
ros2 bag play -s rosbag_v2 rgbd_dataset_freiburg1_xyz.bag --read-ahead-queue-size 1000000

bagファイルの再生には時間がかかるので、 その間にultra96v2にsshでログインしてorb_slam2を起動させる。

  • window3
root@ultra96v2-zynqmp:~# source ros_setup.sh
root@ultra96v2-zynqmp:~# ros2 launch orb_slam2_ros TUM1_mono_launch.py
[INFO] [launch]: All log files can be found below /home/root/.ros/log/2020-12-28-21-11-00-749497-ultra96v2-zynqmp-1140
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [orb_slam2_ros_mono-1]: process started with pid [1149]
[orb_slam2_ros_mono-1] [INFO] [orb_slam2_mono]: Camera info received.
[orb_slam2_ros_mono-1]
[orb_slam2_ros_mono-1] ORB-SLAM2 Copyright (C) 2014-2016 Raul Mur-Artal, University of Zaragoza.
[orb_slam2_ros_mono-1] This program comes with ABSOLUTELY NO WARRANTY;
[orb_slam2_ros_mono-1] This is free software, and you are welcome to redistribute it
[orb_slam2_ros_mono-1] under certain conditions. See LICENSE.txt.
[orb_slam2_ros_mono-1]
[orb_slam2_ros_mono-1] OpenCV version : 3.4.3
[orb_slam2_ros_mono-1] Major version : 3
[orb_slam2_ros_mono-1] Minor version : 4
[orb_slam2_ros_mono-1] Subminor version : 3
[orb_slam2_ros_mono-1] Input sensor was set to: Monocular
[orb_slam2_ros_mono-1]
[orb_slam2_ros_mono-1] Loading ORB Vocabulary.
[orb_slam2_ros_mono-1] Vocabulary loaded!
[orb_slam2_ros_mono-1]
[orb_slam2_ros_mono-1]
[orb_slam2_ros_mono-1] Camera Parameters:
[orb_slam2_ros_mono-1] - fx: 525
[orb_slam2_ros_mono-1] - fy: 525
[orb_slam2_ros_mono-1] - cx: 319.5
[orb_slam2_ros_mono-1] - cy: 239.5
[orb_slam2_ros_mono-1] - k1: 0
[orb_slam2_ros_mono-1] - k2: 0
[orb_slam2_ros_mono-1] - p1: 0
[orb_slam2_ros_mono-1] - p2: 0
[orb_slam2_ros_mono-1] - fps: 30
[orb_slam2_ros_mono-1] - bf: 0
[orb_slam2_ros_mono-1] - color order: RGB (ignored if grayscale)
[orb_slam2_ros_mono-1]
[orb_slam2_ros_mono-1] ORB Extractor Parameters:
[orb_slam2_ros_mono-1] - Number of Features: 2000
[orb_slam2_ros_mono-1] - Scale Levels: 8
[orb_slam2_ros_mono-1] - Scale Factor: 1.2
[orb_slam2_ros_mono-1] - Initial Fast Threshold: 20
[orb_slam2_ros_mono-1] - Minimum Fast Threshold: 7
[orb_slam2_ros_mono-1] [WARN] [orb_slam2_mono]: Map point vector is empty!
[orb_slam2_ros_mono-1] [WARN] [orb_slam2_mono]: Map point vector is empty!
[orb_slam2_ros_mono-1] [WARN] [orb_slam2_mono]: Map point vector is empty!
[orb_slam2_ros_mono-1] [WARN] [orb_slam2_mono]: Map point vector is empty!
[orb_slam2_ros_mono-1] [WARN] [orb_slam2_mono]: Map point vector is empty!
[orb_slam2_ros_mono-1] [WARN] [orb_slam2_mono]: Map point vector is empty!
[orb_slam2_ros_mono-1] [WARN] [orb_slam2_mono]: Map point vector is empty!
[orb_slam2_ros_mono-1] New Map created with 237 points
[ 1284.850620] NOHZ: local_softirq_pending 08

0 件のコメント:

コメントを投稿