[[SIGVerse.org:http://sigverse.org]] | [[SIGVerse Forum:http://sigverse.org/sigverse/forum/]] | [[SIGVerse Wiki (JP):http://www.sociointelligenesis.org/SIGVerse/]] | [[SIGVerse Web:http://web.iir.nii.ac.jp/sigverse/web/]]

----
If you need English information, please see [[SIGVerse Web]] (English Verseion).

%%%''&size(24){SIGVerse Web};''%%%

#contents

----

* SIGVerse Web とは? [#v827625f]
SIGVerse Web は''SIGVerseアプリケーションを構築するためのウェブインタフェースシステム''です. SIGViewerと一緒に使う事で,Cygwinのようなターミナルコンソール経由でのコマンドラインでの開発環境を用いることなく開発を進めることができます.プログラムはウェブベースでの簡易テキストエディタで作成することになります.コンパイルや設定ファイルの配置,プログラム実行などがクリックするだけで実行できます.ブラウザがあれば,開発環境が整っていないPCからでも簡単に開発を進めることができるわけです.

SIGVerse Web の主な特徴は以下の通りです:
- ウェブベースでのプログラムエディタとコンパイラ
- SIGServerの遠隔操作(実行・停止・設定ファイルの整備など)
- クラウド上でのプログラム開発環境の提供

----

* セットアップ [#vd852cbc]
** Webuser アカウントの登録 [#z9349b00]
- トップパネルで SIGVerse Web の利用登録を行い,ログインして下さい.http://web.iir.nii.ac.jp/sigverse/web/login/index.php

&ref(SIGVerse Web/Register&Login.png,alt-title-Register & Login on Top Panel,80%);

** SIGVerse のインストール/アンインストール [#f18f6cb3]
- ログインの次に,あなたのワークスペースにSIGVerseサーバをインストールします.このSIGVerseサーバを修正・変更していくことで,あなたの実行したい実験の世界を作ることになります.別の言い方をすると,他人が作ったSIGVerseの世界を用いる場合には,このインストールは必要無い,という事になります.
- メインページの, '''Connect to Socio''' の所にSIGVerse Web のサーバーホスト名(socio2.iir.nii.ac.jp)が記載されている事を確認し,Connect ボタンを押します.ここでsocio2.iir.nii.ac.jp 以外のSIGVerse web サーバを使う場合には,そのホスト名を入力して下さい.また,Username : webuser は変更しないで下さい.
- 次に Install という項目にあるフィールドにインストールしたいSIGVerseバージョンを記入します.通所は最新版のバージョンが既に記載されているので,何もしなくて結構です.Install ボタンを押すことで,あなたのワークスペース上にSIGVerseサーバがインストールされます.
- ''*重要*'' '''Install''' ボタンをクリックした後,作業完了まで5分程度かかることがあります.ログが出力され,インストールが完了したことが確認できるまで,他のボタンを押さないでください.
- インストールの完了後,'''Go''' ボタンをクリックして, '''Workspace''' にアクセスして下さい.

&ref(SIGVerse Web/SetupPage.png,alt-title-Setup Page,90%);

** '''* NIIで運用するSIGVerseサーバー上のアカウント''' [#wb2d5aa3]
- 国立情報学研究所(NII)で運用しているSIGVerseサーバに接続するためには,サーバでのユーザアカウントが必要になります.
-- ※だたし創発システムシンポジウムにご参加の方はワークショップ当日に限り,アカウントをこちらで用意致します
- NIIで運用するサーバ上のアカウント発行には制約条件がありますので,稲邑(inamura@nii.ac.jp)までご連絡をお願い致します.
- もしくは,1ヶ月間の有効期限付き評価用アカウントの発行も可能です.評価用アカウントの利用方法は以下の通りです.

** 評価用アカウントの利用方法 [#j23b2e39]
- SIGVerse Web にログインした直後のメインページからSSH-Keyをダウンロードして下さい.ダウンロードしたファイルを展開をすると二つのファイル(id_rsa and id_rsa.pub) が得られるので,C:\Program Files\SIGViewer-<version>\SIGViewer\.ssh というディレクトリに置いて下さい.
- SSH接続に用いるパスフレーズ(passphrase)は,展開ファイルのうちの一つpassphrase.txtに記載されています.
- 評価用アカウントは毎月末に期限が切れます.月が新しくなったら再度上記のSSH-Keyをダウンロードして設定を行って下さい.
- SIGViewerの機能を用いたSSHによるサーバーへの接続方法は,(SSH Connection)を参照して下さい.

----

* 基本的な開発ガイド [#u57f6de6]
** ワークスペースの概要 [#w170fd18]

&ref(SIGVerse Web/Workspace.png,alt-title-Workspace,80%);

- プロジェクトディレクトリ
-- 左側のパネルでプロジェクトディレクトリに含まれているファイルを管理します.新しいプロジェクトディレクトリの作成や新しいファイルの作成,ファイルのアップロード,プロジェクトのインポートなどができます.(インポートについては '''Import''' を参照して下さい).

- 編集エリア
-- 中央の編集エリアでソースコードや設定ファイルを作成・修正します.検索や置換などの機能が使えます.プログラムの種類に応じたカラーハイライト機能も備えています.

- コントロールパネル
-- 下部のパネルはコントロールパネルと呼ばれ,ソースコードのコンパイルや実行を行います.
-- ''Make'' を押すことでいわゆるmakeコマンドを実行することになり,Makefileの内容に沿ってコントローラがコンパイルされます.なお,仕様によりMakefileには拡張子.txtが付くことになります.Makefile.txt のサンプルを下記に示しておきます.

Makefile.txt

#highlight(xml){{
#SIGVerseソースの場所指定
SIG_SRC  = ../sigverse-$(sigversion)/include/sigverse

#オブジェクトファイルの指定
OBJS     = Controller.so

all: $(OBJS)

#コンパイルを行います。
./%.so: ./%.cpp
	g++ -DCONTROLLER -DNDEBUG -DUSE_ODE -DdDOUBLE -I$(SIG_SRC) -I$(SIG_SRC)/comm/controller  -fPIC -shared -o $@   $<
}}

-- ''Build'' で,コンパイルしたバイナリや編集した世界ファイルなどを実行するための環境の準備を行います.具体的には各種ファイルを適切なディレクトリにコピーする作業が行われます.使用するSIGVerseのバージョンはコントロールパネルの右側で確認できます.
-- ''Import (.zip)'' で,zip ファイルで圧縮されているプロジェクト全体のデータをインポートすることができます.プロジェクトのインポートを行うには,まず,zipファイルをインポートしたいプロジェクトディレクトリにアップロードし,'''Import'''ボタンを押します.refreshをすることで,インポートしたファイルが見られるようになります.
-- ''Export'' で,現在のプロジェクトをzipファイルにエキスポートします.
-- ''Delete'' で,現在のプロジェクトを削除します.
-- [Admin] は管理者専用のボタンになります.

** SIGServer の実行 [#t214e637]
- ''Run'' で,SIGServer (./sigverse.sh) を実行します.
- ''Check'' で,実行に伴うログを表示します.
- ''Kill'' で,SIGServerを停止させます.

** SIGViewer を用いたSSH接続 [#wd9f6a66]
- SIGViewer.exe を実行します.
- 上部にある'''Setting''' メニューの中の'''SSH Connect'''を選択します.
- サーバのホストネームと,SSHアクセスするためのIDとパスフレーズを入力して下さい.

#ref(SSH接続/ssh_connect1.jpg)

-- Input the server host name (or IP address), user name and passphrase on the dialogue box.
-- For temporary access,
--- Server host name: socio2.iir.nii.ac.jp
-- SIGVerse web のサーバのホスト名またはIPアドレス, ユーザ名,パスフレーズをダイアログに入力して下さい.
-- 評価用アカウントを用いる際には以下の情報を入力して下さい.
--- Host: socio2.iir.nii.ac.jp
--- User name: testuser
--- Passphrase: (as written in passphrase.txt)
--- Passphrase: passphrase.txtに記載されているもの

#ref(SSH接続/ssh_connect2.jpg)

-- Check the '''Use RSA key to login'''.
-- Enable port forwarding (in most cases blocked by firewall) by the following steps.
-- Check '''Local port forwarding with login''' and input the following details:
--- Local port: Port on local machine
--- Listen host:  Listening machine(normally '''localhost''')
--- Remote port: Port on server
-- '''Use RSA key to login'''.にチェックを入れて下さい.
-- 以下の手順でポートフォワード機能を有効にして下さい.
-- '''Local port forwarding with login'''にチェックを入れ,以下の情報を入力して下さい.
--- Local port: localhost で用いるポート番号
--- Listen host:  '''localhost'''と入力
--- Remote port: サーバで用いるポート番号

#ref(SSH接続/ssh_connect3.jpg)

-- Check '''Remote port forwarding with login''' and input the following details:
--- Server port: Port on local machine
--- Listen host:  Listening machine(normally '''localhost''')
--- Local port: Port on server
-- '''Remote port forwarding with login'''にチェックを入れ,以下の情報を入力して下さい.
--- Local port: localhost で用いるポート番号
--- Listen host:  '''localhost'''と入力
--- Remote port: サーバで用いるポート番号


#ref(SSH接続/ssh_connect4jpg.jpg)

-- * In normal cases, please use 9001 and above for local port forwarding, and 8001 and above for remote port forwarding. If the port number is currently in used, please try other number.
-- Check '''Download shape file''' for automatically update shape files from server.
-- Press '''Connect''', the SSH connection is established if the message "SSH Authentication succeeded (server host name)" appears on the bottom left of SIGViewer.
-- *通常は,localhostの9001ポートを使う事をお薦めします.また,ポート番号は8001番以上が望ましいです.もし,If the port number is currently in used, please try other number.という表示が出たら,別の番号で再度接続をお願いします.
-- '''Download shape file'''にチェックを入れると,新しい物体形状ファイルが提供されている場合に,サーバからダウンロードを行います.
-- '''Connect'''ボタンを押すことで,SSH接続が確立します."SSH Authentication succeeded (server host name)"というメッセージが出たら成功です.

#ref(SSH接続/ssh_connect5.jpg)

----

* チュートリアル [#j1dec720]
** 最初のテスト (Tutorial01) [#x282fbcb]
- To simulate a falling object due to gravitational and external forces.
- ① 新しいプロジェクトの作成
-- Click the '''Add Folder''' icon on the top of the left Project Directory.
-- Insert "Tutorial01" and click SAVE.
-- A new folder named "Tutorial01" appears on the Project Directory.
-- 左側のプロジェクトディレクトリエリアの上部にある'''Add Folder'''アイコンをクリックします
-- "Tutorial01"と入力し,'''SAVE'''します.
-- "Tutorial01"という新しいディレクトリが表示されます.

- ② エージェントコントローラの作成
-- An agent is an autonomous object controlled by a controller.
-- Click into "Tutorial01" and click '''Add File''' to create the controller source code.
-- Insert "MoveController" and select "cpp" as the file type.
-- Insert the following codes into the Editor Area and click SAVE.
-- エージェントの動作を定義するエージェントコントローラを作成します
-- "Tutorial01"を移動してディレクトリの中に居る状態で,'''Add File'''をクリックします.
-- "MoveController"と入力し,拡張子"cpp"を選択します.
-- 編集エリア(Editor Area)に以下の内容を記入(コピー)し,'''SAVE'''をクリックします.

MoveController.cpp
 
#highlight(cpp){{
 #include "Controller.h"
 #include "Logger.h"
 
 //ControllerのサブクラスMoveControllerの宣言します。
 class MoveController : public Controller {
 public:
 
   //定期的な処理を行うonActionの利用を宣言します。
   double onAction(ActionEvent&);
 };
 
 
 double MoveController::onAction(ActionEvent &evt) {
   return 5.0;      //次にonActionが呼ばれるまでの時間を返します。
 }
 
 //自身のインスタンスをSIGVerseに返します。
 extern "C" Controller * createController() {
      return new MoveController;
 }
}}

-- The above controller codes do nothing except execute "onAction" on every 5 s.

- ③ コントローラー·コードのコンパイル
-- Create a file named "Makefile" with "txt" file type.
-- Insert the following codes into the Editor Area and click SAVE.
-- 上記と同様の操作で,"Makefile"というファイル名,拡張子"txt"で新しいファイルを追加して下さい.
-- 編集エリア(Editor Area)に以下の内容を記入(コピー)し,'''SAVE'''をクリックします.

Makefile.txt

#highlight(xml){{
#SIGVerseソースの場所指定
SIG_SRC  = ../sigverse-$(sigversion)/include/sigverse

#オブジェクトファイルの指定
OBJS     = MoveController.so

all: $(OBJS)

#コンパイルを行います。
./%.so: ./%.cpp
	g++ -DCONTROLLER -DNDEBUG -DUSE_ODE -DdDOUBLE -I$(SIG_SRC) -I$(SIG_SRC)/comm/controller  -fPIC -shared -o $@   $<
}}

-- In the Control Panel, insert the project name "Tutorial01" for '''work/''' and click '''Make'''. Refresh the Project Directory to ensure the creation of "MoveController.so" file. If "MoveController.so" file is not created, means there is a compilation error during Make. Check your programming codes. Also, in the Makefile.txt, ensure that there is no any extra space in front and behind the lines, and the spacing in front of the last line (...g++) is a tab and not multiple space bar.
-- コントロールパネルの'''work/'''の部分にプロジェクト名"Tutorial01"を入力し,'''Make'''をクリックします."MoveController.so"ファイルが作成されたかどうかを確認するため,プロジェクトディレクトリをRefreshアイコンで再表示して下さい.もし,"MoveController.so"が作成されていなければ,コンパイル時にエラーが出たことを意味しますので,ソースコードを確認・編集して下さい.また,Makefile.txtでタブ記号の部分がスペースになっていないかの確認もして下さい.

- ④ エージェントと仮想世界の作成
-- Create a new file named "NewWorld" with "xml" file type.
-- Insert the following codes into the Editor Area and click SAVE.
-- 上記と同様の操作で,"NewWorld"というファイル名,拡張子"xml"で新しいファイルを追加して下さい.
-- 編集エリア(Editor Area)に以下の内容を記入(コピー)し,'''SAVE'''をクリックします.

NewWorld.xml

#highlight(xml){{

<?xml version="1.0" encoding="utf8"?>
 <world name="myworld">
 
 <!--重力の設定-->
   <gravity x="0.0" y="-9.8" z="0.0"/>  
  
 <!--エージェントToy_Dのインスタンス作成-->
   <instanciate class="seToy_D.xml">
 
 <!--エージェント名-->
         <set-attr-value name="name" value="Toy_D"/>  
 
 <!--C++言語の指定-->
         <set-attr-value name="language" value="c++"/> 
 
 <!--作成したコントローラの指定-->
         <set-attr-value name="implementation" value="./MoveController.so"/>
 
 <!--動力学演算フラグ-->
         <set-attr-value name="dynamics" value="true"/>
  
 <!--エージェントの最初の位置(x,y,z)-->
         <set-attr-value name="x" value="0.0"/>
         <set-attr-value name="y" value="18.0"/>
         <set-attr-value name="z" value="5.0"/>
 
 <!--エージェントの質量設定-->
         <set-attr-value name="mass" value="1.0"/>
 
  </instanciate>
</world>
}}

-- The above codes create a virtual world named "myworld".
-- In the world, an agent named "Toy_D" using the instance of "seToy_D.xml" is created.
-- The "implementation" attribute attaches "MoveController.so" as the controller of the agent.
-- With the "dynamics" attribute value set to "true", the agent is subjected to dynamics simulation.
-- The initial position (x,y,z) and mass are set.
-- 上記のファイルでは,新しい仮想世界ファイル"myworld"を定義しています.
-- この世界では,"Toy_D"という名前のエージェントが"seToy_D.xml"という定義ファイルに従って生成されます.
-- "implementation"属性で,このエージェントに"MoveController.so"というコントローラが割り当てられる事が定義されます.
-- "dynamics"属性の値を"true"とすることで,このエージェントはODEに基づく物理シミュレーションが適用されます.
-- 初期状態は,position (x,y,z) やmassで設定されます.

- ⑤ シミュレーションの実行
-- On the Control Panel, build the project by using '''Build'''.
-- Set "Port" to 9001 and "World" to "NewWorld.xml"
-- Click '''Run''' to execute SIGVerse.
-- Click '''Check''' to check the last line of the output is " Java VM start ok" for successful execution.
-- If you see "cannot bind socket: Address already in use", just try another port number other than 9001.
Try bigger number, e.g. 9002, 9003, 9004, ... There are various reasons why the port is temporary being used.
-- Run SIGViewer. Establish SSH connection under Setting. Set host name as "localhost" and port no. to "9001". Click '''Connect to SimServer'''.
-- An agent in a virtual world appears as follows.
-- * View controls for SIGViewer:
-- コントロールパネル(Control Panel)の'''Build'''を押して,設定したファイルやコンパイルしたコントローラを実行する準備を行います.
-- "Port"に適切な値(例えば9001),"World" に "NewWorld.xml"と入力します.
-- '''Run'''をクリックし,SIGVerseを実行させます.
-- '''Check'''をクリックするとサーバのログが表示されます,最終行に" Java VM start ok" と表示されていれば,無事に動作ができていることが確認できます.
-- もし,"cannot bind socket: Address already in use"という表示が出た場合には,別のポート番号を使って再接続して下さい.
-- SIGViewerを立ち上げて,必要に応じてSSH接続を行って下さい.(創発シンポでのチュートリアルの際にはSSH接続は必要ありません) 
-- SSH接続をしている場合:host name に"localhost",ポート番号に"9001"などの使用している番号を入力して下さい
-- SSH接続をしない場合(NII内部からの接続又は創発シンポチュートリアルの場合):host name に指定されたサーバ名,ポート番号に自分が用いるポート番号を入力して下さい
-- '''Connect to SimServer'''をクリックすると,以下の図のようなエージェントが表示されます.
-- SIGViewer上にて視点を変えるには以下のコマンドを使います
--- Turn around - Right click
--- Zoom - Ctrl + Right click
--- Pan - Shift + Right click

#ref(動力学シミュレーションのサンプル/toy_1.jpg)

-- Click '''Send''' under SIM_CTRL_CMD (START) to start the simulation.
-- The agent falls straight down the ground.
-- '''Disconnect SimServer''' in SIGViewer and '''Kill''' in the Control Panel to terminate the simulation.
-- SIM_CTRL_CMD (START)の下にある'''Send'''をクリックするとシミュレーションが開始されます.
-- エージェントが下に自由落下する様子が見えたら成功です.
-- SIGViewer で'''Disconnect SimServer'''をクリックし,SIGVerse web のコントロールパネルで'''Kill'''をクリックすれば,シミュレーションが終了します.

- ⑥ 外力の加える
-- To apply an external force to the agent, edit the agent controller as follows:
-- ここでは,コントローラのソースコード改変して,エージェントに外力を与えてみます.
-- 以下のように,コントローラのソースコードを編集します

MoveController.cpp

#highlight(cpp:firstline[13]){{
 double MoveController::onAction(ActionEvent &evt) {
   return 5.0;      //次にonActionが呼ばれるまでの時間を返します。
 }
}}

                 ↓

#highlight(cpp:firstline[13]){{
 double MoveController::onAction(ActionEvent &evt) {
   SimObj *obj = getObj(myname());  //自分自身の取得
   obj->setForce(0,0,300);         //z軸方向に300[N]の力を加える
   return 5.0;      //次にonActionが呼ばれるまでの時間を返します。
 }
}}

-- '''Make''', '''Build''' and '''Run''' the simulation as above.
-- The agent moves forward as below.
-- '''Make''', '''Build''','''Run'''の順序でシミュレーションを開始します.
-- エージェントが前方に向かって進んで行くのが見えれば成功です.

#ref(動力学シミュレーションのサンプル/toy_3.jpg)

** チュートリアルプロジェクトファイル [#u6078d14]
上記のファイルをウェブブラウザからコピペしても良いですし,以下のファイルをダウンロードして,SIGVerse web にアップロードする形でもソースコードや設定ファイルを作成できます.
- Tutorial01 - &ref(SIGVerse Web/Tutorial01.zip);
- Tutorial02 - 
- Tutorial03 - 
- Tutorial04 - 
- Tutorial05 - 
- Tutorial06 - 
- Tutorial07 - 
- Tutorial08 - 
- Tutorial09 - 
- Tutorial10 - 


** SIGVerse Web と一般的な開発の違い [#r45b397b]

SIGVerse Web is developed with the aim to ease and reduce learning curve for novice users (who are not familiar to Linux environment) to begin with SIGVerse development. The development process explained above is slightly different to manual programming developments illustrated in the rest of the tutorials in this wiki.
SIGVerse Web はLinux環境によるプログラム開発に慣れていない人のための簡易開発環境であるため,通常のLinux開発環境によるアプリケーション開発と大きく異なる点がいくつか存在します.特に,このwikiの[[Tutorial]]に記載されている内容と異なる点がありますのでご注意下さい.

- The files system in SIGVerse Web is organized based on "Project". You can develop all related files (.cpp, .so, .xml, .wrl, .x3d, etc.) under the same project folder. By using "Build", SIGVerse Web will automatically build all the files into the respective folders of the current SIGVerse version that you are working on. This files system will provide a better files organization and enables "Import" and "Export" of projects for backup and sharing purposes.
- SIGVerse Web でのファイルシステムは,"Project"という概念で整理されています.あるアプリケーションに必要なファイル (.cpp, .so, .xml, .wrl, .x3d, など)は,同じプロジェクトディレクトリの下で管理されます."Build"を用いることで,SIGVerse Webは自動的にこれらの必要なファイルをSIGVerseのバージョン番号などに従って,実際に必要なディレクトリに自動的に転送(コピー)します. これによって,"Import"や"Export"がより簡単にできるようになっています.

- ''*違い*'' In World files (.xml), the path to the controller's shared object file (.so) is always at the current directory, example:

- ''*違い*'' SIGVerse Web では,仮想世界を記述するファイル (.xml)の文法として,以下に示す通り,エージェントコントローラの置き場所は通常カレントディレクトリをも用います.しかし,通常の開発環境(例えば[[Tutorial]])では,プロジェクトディレクトリの下に置くような文法になっています.この点を注意して,Tutorial に記載されている表記をSIGVerse Web の表記に直して使って下さい.
-- SIGVerse Web での記法
#highlight(xml){{
<set-attr-value name="implementation" value="./MoveController.so"/>
}}
-- [[Tutorial]]で説明されている開発環境での記法
#highlight(xml){{
<set-attr-value name="implementation" value="./Tutorial1/MoveController.so"/>
}}

- In SIGVerse Web, you can install and execute all available versions of SIGVerse servers in the same development environment. Because of the independent files system, the same project codes can be executed in different SIGVerse versions based on your selection when you enter the workspace.
- SIGVerse Webでは,SIGVerse サーバのバージョンに依存せず,同じ設定ファイルを共有することができます.

- ''*違い*'' To make sure the Makefile indicates the current SIGVerse version in your workspace during compilation, please make sure the first line of the Makefile.txt is as follows:
- ''*違い*'' Makefile の作成時には,SIGVerse バージョン番号を以下のように指定する必要があります.もしSIGVerseのバージョンがアップデートされた場合などには,以下の部分を書き換えて使う必要がありますので,ご注意下さい.

#highlight(xml){{
SIG_SRC  = ../sigverse-$(sigversion)/include/sigverse
}}

----

* ライブラリー [#rc33b193]
- Object Gallery

- World Gallery
-- Living Room (Small)
-- Living Room (Big)
-- Kitchen

- Controller Collection
-- Mobile Robot
-- Humanoid

- User Interface Systems
-- Kinect
-- Webcam

----

For any inquiry, suggestion, and feedback, please kindly contact Jeffrey [jeffrey@nii.ac.jp].
SIGVerse Web システムは国立情報学研究所のJeffrey TAN が担当しています.もしご質問等があれば,[jeffrey@nii.ac.jp]までご連絡下さい.

#highlight(end)



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