pseudowire

調べたことを書き残す

Docker環境上でROS2 Humble+TB3のGazeboシミュレーションする

まだ検証中なので、参考サイトやメモを残すだけ。 あとで内容をまとめるつもり。

Troubleshooting_1

mkdir -p ~/turtlebot3_ws/src
cd ~/turtlebot3_ws/src/
git clone -b humble-devel https://github.com/ROBOTIS-GIT/DynamixelSDK.git
git clone -b humble-devel https://github.com/ROBOTIS-GIT/turtlebot3_msgs.git
git clone -b humble-jp-devel https://github.com/ROBOTIS-JAPAN-GIT/turtlebot3_jp_custom.git
cd ~/turtlebot3_ws
colcon build --symlink-install

ここでエラー発生。

root@1d491d21ae70:~/turtlebot3_ws# colcon build --symlink-install
Starting >>> dynamixel_sdk
Starting >>> turtlebot3_msgs
--- stderr: dynamixel_sdk                                                                     
CMake Error at CMakeLists.txt:18 (find_package):
  By not providing "Findament_cmake.cmake" in CMAKE_MODULE_PATH this project
  has asked CMake to find a package configuration file provided by
  "ament_cmake", but CMake did not find one.

  Could not find a package configuration file provided by "ament_cmake" with
  any of the following names:

    ament_cmakeConfig.cmake
    ament_cmake-config.cmake

  Add the installation prefix of "ament_cmake" to CMAKE_PREFIX_PATH or set
  "ament_cmake_DIR" to a directory containing one of the above files.  If
  "ament_cmake" provides a separate development package or SDK, be sure it
  has been installed.


---
Failed   <<< dynamixel_sdk [0.33s, exited with code 1]
Aborted  <<< turtlebot3_msgs [0.27s]

Summary: 0 packages finished [1.04s]
  1 package failed: dynamixel_sdk
  1 package aborted: turtlebot3_msgs
  2 packages had stderr output: dynamixel_sdk turtlebot3_msgs
  10 packages not processed

以下を参考にして、ひとまず解決。 https://github.com/ros2/ros2/issues/710

source /opt/ros/humble/setup.bash 

Troubleshooting_2

Finished <<< turtlebot3_navigation2 [1.41s]                                                                          
Starting >>> turtlebot3_teleop
--- stderr: turtlebot3_teleop                                                                             
/usr/lib/python3/dist-packages/setuptools/command/easy_install.py:158: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
/usr/lib/python3/dist-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
/usr/lib/python3/dist-packages/pkg_resources/__init__.py:116: PkgResourcesDeprecationWarning: 1.16.0-unknown is an invalid version and will not be supported in a future release
  warnings.warn(
/usr/lib/python3/dist-packages/pkg_resources/__init__.py:116: PkgResourcesDeprecationWarning: 1.1build1 is an invalid version and will not be supported in a future release
  warnings.warn(
---
Finished <<< turtlebot3_teleop [10.6s]
Starting >>> turtlebot3_example                                   
--- stderr: turtlebot3_example                                                                             
/usr/lib/python3/dist-packages/setuptools/command/easy_install.py:158: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
/usr/lib/python3/dist-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
/usr/lib/python3/dist-packages/pkg_resources/__init__.py:116: PkgResourcesDeprecationWarning: 1.16.0-unknown is an invalid version and will not be supported in a future release
  warnings.warn(
/usr/lib/python3/dist-packages/pkg_resources/__init__.py:116: PkgResourcesDeprecationWarning: 1.1build1 is an invalid version and will not be supported in a future release
  warnings.warn(
---
Finished <<< turtlebot3_example [13.3s]

これで解決。 https://zenn.dev/tasada038/articles/f2f5b500cdc36a

pip install setuptools==58.2.0

Troubleshooting_3

cd ~/turtlebot3_ws/src/
git clone -b humble-jp-devel https://github.com/ROBOTIS-JAPAN-GIT/turtlebot3_simulations_jp_custom
git clone https://github.com/robotics-upo/lightsfm
cd lightsfm
make
sudo make install
cd ~/turtlebot3_ws
colcon build --symlink-install

これをやったらこうなった。

[Processing: turtlebot3_gazebo]                                         
[Processing: turtlebot3_gazebo]                                         
--- stderr: turtlebot3_gazebo                                            
CMake Warning (dev) at /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (PkgConfig)
  does not match the name of the calling package (gazebo).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  /usr/share/cmake-3.22/Modules/FindPkgConfig.cmake:99 (find_package_handle_standard_args)
  /usr/lib/x86_64-linux-gnu/cmake/gazebo/gazebo-config.cmake:72 (include)
  CMakeLists.txt:23 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

/root/turtlebot3_ws/src/turtlebot3_simulations_jp_custom/turtlebot3_gazebo/src/infinite_corridor_sfm_plugin.cpp: In member function ‘virtual void gazebo::InfiniteCorridorSFMPlugin::Reset()’:
/root/turtlebot3_ws/src/turtlebot3_simulations_jp_custom/turtlebot3_gazebo/src/infinite_corridor_sfm_plugin.cpp:283:23: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<ignition::math::v6::Vector3<double> >::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
  283 |     for (int i = 0; i < goals.size(); i++) {
      |                     ~~^~~~~~~~~~~~~~
---
Finished <<< turtlebot3_gazebo [7min 21s]
Starting >>> turtlebot3_simulations
Finished <<< turtlebot3_simulations [5.17s]                          
                             
Summary: 19 packages finished [7min 50s]
  1 package had stderr output: turtlebot3_gazebo
root@1d491d21ae70:~/turtlebot3_ws# 

こちらを参考に修正。 https://memoteki.net/archives/7187

vi /root/turtlebot3_ws/src/turtlebot3_simulations_jp_custom/turtlebot3_gazebo/CMakeLists.txt 

-find_package(gazebo REQUIRED)
+find_package(gazebo_ros REQUIRED)

Troubleshooting_4

今回利用させていただいたDockerイメージでは、VNCからターミナルを開くとRootでログインできない。 また、ROSのワークスペースが /root配下にあるため、source ~/turtlebot3_ws/install/setup.bash を実行できない。 VSCodeでこのDockerにShellをアタッチするとRootでログインできるので、ここでRootパスワードを変更した。

sudo passwd root

Troubleshooting_5

ros2 launch turtlebot3_gazebo turtlebot3_world.launch.py

これをやったら、こうなった。

root@1d491d21ae70:~# ros2 launch turtlebot3_gazebo turtlebot3_world.launch.py
[INFO] [launch]: All log files can be found below /root/.ros/log/2023-08-02-00-58-41-294663-1d491d21ae70-4888
[INFO] [launch]: Default logging verbosity is set to INFO
urdf_file_name : turtlebot3_big_wheel.urdf.xacro
urdf_file_name : turtlebot3_big_wheel.urdf.xacro
[ERROR] [launch]: Caught exception in launch (see debug for traceback): 
executed command failed. Command: xacro /root/turtlebot3_ws/install/turtlebot3_description/share/turtlebot3_description/urdf/turtlebot3_big_wheel.urdf.xacro
Captured stderr output: error: environment variable 'LDS_MODEL' is not set 
when evaluating expression 'lds_model=='LDS-01''
when processing file: /root/turtlebot3_ws/install/turtlebot3_description/share/turtlebot3_description/urdf/turtlebot3_big_wheel.gazebo.xacro
included from: /root/turtlebot3_ws/install/turtlebot3_description/share/turtlebot3_description/urdf/turtlebot3_big_wheel.urdf.xacro

こちらを参考に解決。

https://blog.csdn.net/weixin_45365549/article/details/127225258

export LDS_MODEL=LDS-01

Troubleshooting_6

ubuntu@1d491d21ae70:/$ gazebo
ALSA lib confmisc.c:855:(parse_card) cannot find card '0'
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_card_inum returned error: No such file or directory
ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1334:(snd_func_refer) error evaluating name
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5701:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM default
AL lib: (EE) ALCplaybackAlsa_open: Could not open playback device 'default': No such file or directory

これで解決。 https://waregawa-log.hatenablog.com/entry/2020/10/10/234148

root@1d491d21ae70:/# vi /usr/share/alsa/alsa.conf

pcm.!default {
    type plug
    slave.pcm "null"
}

Troubleshooting_7

root@1d491d21ae70:~# ros2 launch turtlebot3_gazebo turtlebot3_world.launch.py
[ERROR] [gzclient-2]: process has died [pid 18100, exit code -6, cmd 'gzclient'].

権限の問題っぽいので、

chmod 777 /root 

をしたうえで、Rootを抜けて一般ユーザでturtlebot3_wsに移動して、

export TURTLEBOT3_MODEL=burger
source /root/turtlebot3_ws/install/setup.bash

をやってからリトライしたら正常にGazeboが起動した。 同様の手順をほかのTerminalでも実行したところ、正常にTeleopできた。

Ref

memoteki.net

note.com

zenn.dev

qiita.com

answers.ros.org