[[Tutorial for ver.3]]

----

SIGVerse v3では、ROS(Robot Operating System)のプログラムを利用して仮想ロボットを制御することができます。

ここでは ROS を使用したサンプルプログラムについて説明します。
ROSを使用しないサンプルプログラムは[[こちらのページ>Tutorial for ver.3]]を参照してください。



#contents

* システム要件 [#SystemRequirements]

ROSを使用する際にはUbuntu環境を用意して、そこにROSをインストールします。~
そしてROSをインストールしたUbuntuと、UnityをインストールしたWindowsで通信を行います。~

Windows側の要件は[[こちらのページ>Tutorial for ver.3]]を参照してください。

ROS側の要件は、OSが ''Ubuntu 16.04'' 、ROSの[[ディストリビューション>http://wiki.ros.org/Distributions]]は ''Kinetic Kame'' とします。
ROS側の要件は、OSが ''Ubuntu 20.04'' 、ROSの[[ディストリビューション>http://wiki.ros.org/Distributions]]は ''Noetic Ninjemys'' とします。

#ref(RobotOperationUsingROS.png)


* 環境構築 [#vf01a3c9]
* Windows環境の構築 [#k2704bce]

** Windows環境の構築 [#k2704bce]

[[こちらのページ>Tutorial for ver.3#SystemRequirements]]を参照して、Windows環境の構築を行ってください。~
その後、以降の環境構築作業を行ってください。

** Ubuntu環境の構築 [#zddcd2d8]
* Ubuntu環境の構築 [#zddcd2d8]

以下のようにUbuntu環境を構築します。~

*** VMwareの使用 [#gc586877]
** VMwareの使用 [#gc586877]

Ubuntu PCを用意する代わりにWindows上にUbuntuの仮想マシンを構築して使用することもできます。~
但しこの場合、GPUを使用するチュートリアルは難しいです。
但しこの場合、GPUを使用するチュートリアルは難しいです。 ~
VMwareを使用すると多くの計算資源が必要になるので注意してください。~
またDockerはVMwareとの共存に問題があるかもしれません。ご注意ください。

VMwareを使用してUbuntu環境を構築する方法は次のような流れです。

+ Install VMware Workstation 15.5.0 Player for Windows 64-bit Operating Systems.~
https://my.vmware.com/jp/web/vmware/free#desktop_end_user_computing/vmware_workstation_player/15_0
+ Download Iso file of Ubuntu 16.04.6 LTS.~
http://releases.ubuntu.com/16.04/
+ Launch VMware Workstation Player.
+ Click [Create a New Virtual Machine].
+ Use [Installer disc image file(iso):] and select ubuntu-16.04.6-desktop-amd64.iso.
+ Recommend to check "Store virtual disk as a single file".
+ Please adjust Memory and Processors in [Edit virtual machine settings] after creating VM image.
+ VMware Workstation Playerをダウンロードします。~
https://my.vmware.com/jp/web/vmware/downloads/info/slug/desktop_end_user_computing/vmware_workstation_player/16_0
+ Ubuntu 20.04.4 LTSのISOファイルをダウンロードします。~
http://releases.ubuntu.com/focal/
+ VMware Workstation Playerを起動します。
+ [Create a New Virtual Machine]をクリックします。
+ [Installer disc image file(iso):]を使用し、ubuntu-20.04.4-desktop-amd64.isoを選択します。
+ Specify Disk Capacity画面で、"Store virtual disk as a single file"にチェックを入れることをお勧めします。
+ VMの作成が終わったら、VMware Workstation Playerの仮想マシン設定画面でメモリやCPU数を調整してください。~
また拡張キーボードを使用するよう設定してください。


** ROS Noetic Ninjemysのインストール [#dccef8ca]
[[ROSインストールページ>http://wiki.ros.org/noetic/Installation/Ubuntu]]を1.6節まで実行してROSをインストールします。~
その後、[[ROSのチュートリアル>http://wiki.ros.org/ROS/Tutorials/InstallingandConfiguringROSEnvironment]]の3章に従ってROSワークスペースの作成を行ってください。

*** ROS Kineticのインストール [#dccef8ca]
[[こちら>http://wiki.ros.org/kinetic/Installation/Ubuntu]]の手順に従って、ROSをインストールします。([[日本語版>http://wiki.ros.org/ja/kinetic/Installation/Ubuntu]])~
その後、[[ROSのチュートリアル>http://wiki.ros.org/ROS/Tutorials/InstallingandConfiguringROSEnvironment]]に従ってROSワークスペースの作成まで行ってください。

また以降のコマンド簡略化のため、~/catkin_ws/devel/setup.bash の実行を.bashrcに追記します。複数のROSワークスペースを管理している方は注意してください。
** 必要なライブラリのインストール(シェルスクリプト使用) [#i3fb7c9b]
シェルスクリプトを使用してライブラリを一括インストールする手順を示します。 ~
この手順を実行した場合、以降の手動インストール手順は不要です。 ~
ROS Noeticを標準インストールした場合で動作確認しています。 ~
そのためROSワークスペースの名前がcatkin_wsではない場合などは正常にインストールできません。 ~
注意して使用してください。
 $ wget https://raw.githubusercontent.com/SIGVerse/docker-ros/main/noetic/sigverse_setup.sh
 $ chmod +x sigverse_setup.sh
 $ ./sigverse_setup.sh
 $ source ~/.bashrc

** 必要なライブラリのインストール(手動) [#n300e515]

*** .bashrcへのコマンド追加 [#bceb6936]
コマンド簡略化のため、~/catkin_ws/devel/setup.bash の実行を.bashrcに追記します。~
複数のROSワークスペースを管理している方は注意してください。

 $ echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
 $ source ~/.bashrc


*** ROSBridge_suiteのインストール [#c3162771]
ターミナルを起動し、以下のコマンドを実行します。

 $ sudo apt-get install ros-kinetic-rosbridge-server
 $ sudo apt-get install ros-noetic-rosbridge-server


*** Mongo C driver インストール [#n65f2eba]
*** Mongo C driver のインストール [#n65f2eba]
ターミナルで、以下のコマンドを実行します。

 $ cd ~/Downloads (日本語設定の場合は cd ~/ダウンロード で実行してください。)
 $ cd ~/Downloads #(日本語設定の場合は cd ~/ダウンロード)
 $ wget https://github.com/mongodb/mongo-c-driver/releases/download/1.4.2/mongo-c-driver-1.4.2.tar.gz
 $ tar zxvf mongo-c-driver-1.4.2.tar.gz
 $ cd mongo-c-driver-1.4.2
 $ ./configure
 $ make
 $ sudo make install

*** Mongo C++ driver インストール [#lf0687e5]
*** Mongo C++ driver のインストール [#lf0687e5]
ターミナルで、以下のコマンドを実行します。

 $ cd ~/Downloads (日本語設定の場合は cd ~/ダウンロード で実行してください。)
 $ cd ~/Downloads #(日本語設定の場合は cd ~/ダウンロード)
 $ wget https://github.com/mongodb/mongo-cxx-driver/archive/r3.0.3.tar.gz
 $ tar zxvf r3.0.3.tar.gz
 $ cd mongo-cxx-driver-r3.0.3/build
 $ cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DLIBMONGOC_DIR=/usr/local -DLIBBSON_DIR=/usr/local ..
 $ sudo make EP_mnmlstc_core
 $ make
 $ sudo make install

*** sigverse_ros_bridgeの設定 [#n891675d]
*** gnome-terminal のインストール [#qee06a1a]
gnome-terminalがインストールされていない場合はインストールしてください。

 $ sudo apt install gnome-terminal

*** sigverse_ros_bridgeの設定 [#k80ec0b6]
ターミナルで、以下のコマンドを実行します。

 $ cd ~/catkin_ws/src
 $ git clone https://github.com/SIGVerse/sigverse_ros_package.git
 $ cd ..
 $ catkin_make


*** TurtleBot3パッケージのインストール [#c4f5154e]

*** Turtlebotパッケージのインストール [#c4f5154e]
[[TurtleBot3>http://wiki.ros.org/turtlebot3]]を利用するには関連するROSパッケージをインストールします。~

[[Turtlebot>http://wiki.ros.org/Robots/TurtleBot]]を利用するためにROSパッケージをインストールします。~
現状Indigoのページしかないので、コマンドをKinetic用に置き換えます。
 $ sudo apt install ros-noetic-rgbd-launch
 $ sudo apt install ros-noetic-gmapping
 $ sudo apt install ros-noetic-turtlebot3*
 
// $ cd ~/catkin_ws/src
// $ git clone https://github.com/ros-drivers/openni2_camera.git
// $ git clone -b legacy https://github.com/IntelRealSense/librealsense.git
// $ git clone -b indigo-devel https://github.com/IntelRealSense/realsense-ros.git
// $ sed -i 's/c++11/c++14/g' realsense-ros/realsense_camera/CMakeLists.txt
// 
// $ cd ~/catkin_ws
// $ catkin_make --pkg librealsense
// $ catkin_make
// 
// $ source ~/.bashrc

 $ sudo apt-get install ros-kinetic-turtlebot ros-kinetic-turtlebot-apps ros-kinetic-turtlebot-interactions ros-kinetic-turtlebot-simulator ros-kinetic-kobuki-ftdi ros-kinetic-ar-track-alvar-msgs

Kinetic用に変更してエラーが出た場合、レポートファイルを削除すればエラーメッセージは消えます。

 $ ls -la /var/crash
 $ sudo rm /var/crash/*

Kinetic Kameにインストールする場合は以下のページも参考にしてください。~
http://answers.ros.org/question/246015/installing-turtlebot-on-ros-kinetic/

 $ sudo apt-get install -y linux-headers-generic
 $ sudo sh -c 'echo "deb-src http://us.archive.ubuntu.com/ubuntu/ xenial main restricted
 deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
 deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
 deb-src http://security.ubuntu.com/ubuntu xenial-security main restricted" > \
   /etc/apt/sources.list.d/official-source-repositories.list'
 $ sudo apt-get update
 $ sudo apt-get install -y ros-kinetic-librealsense
 $ sudo apt-get install -y ros-kinetic-realsense-camera
 $ sudo apt-get install -y ros-kinetic-turtlebot

また以下もインストールすると便利だと思います。

 $ sudo apt-get install ros-kinetic-turtlebot*

そして、SIGVerse用の.launch XMLファイル(3dsensor)を配備します。

 $ cd ~/catkin_ws/
 $ sudo cp src/sigverse_ros_package/samples/turtlebot2/resources/asus_xtion_pro_sigverse.launch.xml /opt/ros/${ROS_DISTRO}/share/turtlebot_bringup/launch/includes/3dsensor

※本件に関してまして、[[産業技術総合研究所の原功 氏>http://hara.jpn.com/_default/ja/Topics/SIGVerse20Ver.3.html]]からファイルの提供と助言を頂きました。有難うございました。




*** PR2パッケージのインストール [#hf065135]

PR2のサンプルを使用する場合は、以下コマンドでPR2関連パッケージをインストールします。
PR2を利用するにはPR2関連パッケージをインストールします。

 $ sudo apt-get install ros-kinetic-pr2*
 $ sudo apt-get install ros-noetic-pr2*
 
 $ cd $ROS_ROOT/../prosilica_camera
 $ sudo mkdir plugins
 $ sudo cp nodelet_plugins.xml plugins/








* ROSを使用したサンプルプログラムの実行 [#o023aef1]

** Unityシーンの実行方法 [#open_scene]

Unityのサンプルシーンを実行する前に、ROSのIPアドレスをUnity側に設定する必要があります。

+Ubuntu環境のIPアドレスを確認します。~
IPアドレスはUbuntu環境で以下のコマンドを実行することで確認できます。
 $ ifconfig
 $ hostname -I
+ UnityでSIGVerse v3プロジェクトを開きます。
+ Unityメニューの[SIGVerse]-[SIGVerse Settings]をクリックして、SIGVerse設定画面を開きます。
+ ROS側のIPアドレスを[Config file Settings]-[Rosbridge IP]に入力します。~
(同様に[Rosbridge Port]や[SIGVeres Bridge Port]も変更できます。)

#ref(SIGVerseSettings.png)


Unityシーンの実行方法は次の通りです。
+ [Project]タブの[Assets/SIGVerse/SampleScenes/xxxxx/yyyyy(.unity)]をダブルクリックして対象シーンを開きます。
+ [Project]タブの[Assets/SIGVerse/ExampleScenes/xxxxx/yyyyy(.unity)]をダブルクリックして対象シーンを開きます。
+ Unity画面の上部中央にある再生ボタンをクリックしてシーンを再生します。




** サンプルシーン一覧 [#h9fc55dc]

- [[(Turtlebot2)人間を追従する]]
- [[(Turtlebot2)キーボードで操作する]]
// - [[(Turtlebot2)人間を追従する]]
// - [[(Turtlebot2)キーボードで操作する]]
- [[(TurtleBot3)把持する(キーボード操作)]]
- [[(TurtleBot3)把持する(自動把持)]]
- [[(TurtleBot3)把持する(自動把持)]] #darknet_ros(YOLO)
- [[(TurtleBot3)SLAMの実行]]
- [[(TurtleBot3)人間が指差す方向を認識する]]
- [[(PR2)キーボードで操作する]]
- [[(HSR)キーボードで操作する]]
- [[(HSR)Cleanupタスクの実行]]
- [[(HSR)クラウドとVRを使用したCleanupタスクの実行]]
- [[(HSR)クラウドとVRを使用したCleanupタスクの実行]] #Cloud, VR
- [[(HSR)クラウドとVRを使用したCleanupタスクの実行(記録・再生機能付き)]] #Cloud, VR
- [[(HSR)あれ取ってきて!(Bring that!)部屋の地図作成&自律移動(作成中)]]
- [[(TIAGo)キーボードで操作する]]
- [[(TIAGo)Cleanupタスクの実行]]




----

#counter


Front page   New List of pages Search Recent changes   Help   RSS of recent changes