201 views
# How to use RRS-AWS + Environment construction This page explains how to use RRS-AWS. RRS-AWS is a system or website for running simulations on AWS. ::: warning Please enable Javascript to use RRS-AWS. ::: ### Table of Contents [Build Environment](#Build-Environment) [Accounts](#Accounts) [Login and Logout](#LoginampLogout) [Agent Submission](#Agent-Submission) [Scenario](#Scenario) [Simulations](#Simulations) [Simulations Results](#Simulations-Results) [Batch Run](#Batch-Run) [Delete Environment](#Delete-Environment) ## Build Environment ### AWS ::: warning This is written based on the AWS as of October 2021. It may differ slightly with future updates. ::: ::: warning To build the environment, you need an Amazon Web Services account. For details, please refer to [ Setting up your AWS Environment](https://aws.amazon.com/getting-started/guides/setup-environment/module-one/). ::: ::: info In this tutorial, we will assume that the language is English and the region is set to us-east-1. You can change the language and region as needed. ::: 1. Download rrs-aws.yml ``` curl -LO https://maslab.aitech.ac.jp/~k19016kk/rrs-aws.yml ``` 2. Go to [Cloud Formation](https://console.aws.amazon.com/cloudformation/) 3. Click "Create stack" ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_574ca2cee222c7a6b5d9a68791b209ed.png) 4. Select "Upload a template file" under Template source in Specify template ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_aec5f0d56a9aee6d1b60a70b3a3873b9.png) 5. Select the appropriate template file from Choose file (in this case, rrs-aws.yml) ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_bb84090cef878ca1d6ad5fadb52bc0f9.png) 6. Click "Next" ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_55cd6a5b5342e2efe67b93cdad1f2c8d.png) 7. Enter a free string in Stack name and click "Next". The name can be anything you want. (In this case, enter rrs-aws) ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_ffe887653e0b201525918ebdaf2c72d8.png) 8. Click "Next" without setting anything. ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_cc18c7d829a749050fa73ff635ea562e.png) 9. Check "*I acknowledge that AWS CloudFormation might create IAM resources.*". ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_f0f46f9520d5529467da933d9d821846.png) 10. Verify that it is now CREATE_COMPLETE It will take a few minutes to become CREATE_COMPLETE. ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_345156be7ed8fd361e264a0db47d4073.png) 11. Download the server files with `git clone https://github.com/roborescue/rcrs-server` 12. Name the folder ``server`` and then compress it into a zip file 13. Go to [S3](https://console.aws.amazon.com/s3/) 14. Select the bucket whose prefix is the name you set in 6. ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_860f236c76716cc530ec6aabdf8ae5a7.png) 15. Click "Upload" ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_b7f6a5e3ebe85fead88fe09e4d75a8eb.png) 16. Drag and drop the file you just zipped, and click "Upload" ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_e5bcc6cb399b394a6de670129cb07e9e.png) 17. Confirm that `server.zip` has been uploaded ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_6d0bfd79e9a54c71cdf258b6e89dfda8.png) ### Start RRS-AWS ::: warning To build the environment, you will need Docker and Docker Compose. Please refer to [Get Started with Docker](https://docs.docker.com/get-started/) for details. If you are using Linux, you will also need to install Docker Compose separately. Please refer to [Install Docker Compose](https://docs.docker.com/compose/install/) for details. ::: 1. Download RRS-AWS After downloading, unzip it. ``` curl -LO https://maslab.aitech.ac.jp/~k19016kk/rrs-aws-ui-docker.zip ``` 2. Get the API key and URL 1. Go to [Cloud Formation](https://console.aws.amazon.com/cloudformation/) . 2. Select the Stack that you just created. ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_c479c843361787ac1a4f409ea0fb3a89.png) 3. Get the ApiGatewayUrl in the Output tab. ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_2c69580c01d5c295a71ceee49d971420.png) 4. Step on the link for the Physical ID of ApiGatewayApiKey in the Resources tab. ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_77a593b52a6040f3b4b020e12c490652.png) 5. Click "show API Key" to obtain the API key. ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_3b5a859905c089d68ed1c41969dc421d.png) 3. Set the API Key and URL Open the docker-compose.yml file in the rrs-aws-ui-docker folder. Enter the API URL and key in the API_URL and API_KEY sections at the bottom, respectively. 4. Change the database password Change the value of MYSQL_ROOT_PASSWORD in docker-compose.yml to your desired password. 5. Start the web server. ``` cd rrs-aws-ui-docker sudo docker-compose up -d ``` 6. (Optional) Check the logs ``` sudo docker-compose logs -t -f app ``` 7. Quit the web server ``` sudo docker-compose down ``` <!-- ## Accounts ### How to register a new account 新規アカウントは手動で登録する必要があります。 1. パスワードのハッシュ化 アカウントを作成するには作成したいアカウントのパスワードをハッシュ化する必要があります。 ``` cd rrs-aws-ui-docker/rrs-aws-ui/ node generate_password.js 作成するパスワード ``` 2. アカウント情報の書き込み 次に、rrs-aws-ui-docker内の`/db/initdb.d/init.sql`にアカウント情報を書き込みます。 RRS-AWSではファイル名の接頭辞を用いて各チームや各選手の権限を管理しています。権限は正規表現を用いて判定をしています。 以下のサンプルを参考にアカウントを作成してください。 ``` INSERT INTO `users` VALUES ( 'ait', //ユーザ名 '$2b$10$eQ/kxiTvOfC6hjmYOTPPuOjJLGLTBg9wuevR8T/Wlghrz4FrHkJ4S', //ハッシュ化されたパスワード 'AIT_', //所属チーム(ファイルの接頭辞) '^AIT_.*', //エージェントファイルの書き込み権限 '^AIT_.*', //エージェントファイルの読み込み権限 '$.', //シナリオファイルの書き込み権限 '.*', //シナリオファイルの読み込み権限 '^AIT_.*', //シミュレーションの実行権限 '^AIT_.*', //シミュレーション結果の閲覧権限 '$.', //バッチランの実行権限 '$.' //バッチラン結果の閲覧権限 ); INSERT INTO `credits` VALUES ( 'ait', //ユーザー名 5 //最大シミュレーション回数 ); ``` 基本的には以下の正規表現を用いて権限を変更します。 ```.*``` : 全て許可 ```$.``` : 全て拒否 ```^チーム名.*```:チームのファイルorチームが実行したシミュレーションのみ許可 :::spoiler とても詳しい説明 所属チーム(ファイルの接頭辞)はエージェントファイルやシナリオファイルをアップロードするとき、ファイルの接頭辞に名前が付きます。 このサンプルの場合、このアカウントの所属チームが```AIT_```となっており、例えば、```Agent.zip```をアップロードする場合、```AIT_Agent.zip```に名前変更された後、アップロードされます。 書き込み権限はファイルのアップロードもしくは削除するファイルを制限します。 このサンプルの場合、エージェントファイルの書き込み権限は```^AIT_.*```となっており、この正規表現に一致するファイルのみアップロードもしくは削除することができます。そのため、AIT_...という接頭辞に"AIT_"がついている名前のファイルのみアップロードもしくは削除ができます。 読み込み権限は各ファイルの表示を制限します。 このサンプルの場合、エージェントファイルの読み込み権限は```^AIT_.*```となっており、この正規表現に一致するファイルのみ表示されます。そのため、AIT_...という接頭辞に"AIT_"がついている名前のファイルのみアップロードもしくは削除ができます。 実行権限はシミュレーションの実行権限を制限します。 このサンプルの場合、シミュレーションの実行権限は```.*```となっており、実行できるようになっています。 ただし、バッチランの実行権限は```$.```となっており、実行できないようになっています。 結果閲覧権限はシミュレーションの結果閲覧権限を制限します。 このサンプルの場合、シミュレーション結果の閲覧権限は```^AIT_.*```となっており、自チームの結果のみ閲覧できるようになっています。 ::: すべて許可されている管理者用アカウント1つと競技者用アカウント必要分を作成してください。 Webサーバー起動中の権限変更方法は[権限変更](#権限変更)を参照してください。 3. アカウントの確認 これでアカウント作成が完了しました。[ログイン&ログアウト](#ログインampログアウト)を参考にログインができているか確認してください。 --> ## Login&Logout ### Login :::info In this case, use "admin" as the ID and "password" as the password. ::: When you access RRS-AWS, the login screen will be displayed first. Enter the ID and Password distributed to you by email, and click the Login button to log in. After one hour, the system will time out and you will need to log in again. ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_7a6d7ef255a75abe1dbca30d5739f82b.png) ### Logout If you want to log out, click on your account name in the upper right corner and then click Logout. ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_16512c19ede206cc069d24b7e3cd0100.png) ## Accounts ### Create Accounts 1. Click "Config" Button. Click on your account name in the upper right corner and then click Config. ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_9a56c46c9faec44cbf9149b32cf9563e.png) 2. Click the + button Click on the + button like in the red frame in the image. ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_d403df5a1d86ca128f9505c88cd69670.png) 3. Enter a new account information ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_a6ed898fc11bcc4c368ebf836df6f4e2.png) | Input field | Details | | --------------- | ----------------------------------------------------------------------------------------------------------- | | ID | This ID is required for login. The ID must be unique. | | Password | Password is required for login. | | Confim Password | Confim the password | | Role | There are two types of Role: ADMIN and USER.<br>ADMIN can create accounts, but USER cannot create accounts. | | Team name | Decide on a name for the team. | | Credit | Set the number of times the simulation can be run. | - Permissions - All Deny All will be denied. - Allow only my team - Upload The file name will be [my team]_[file name]. - Execute The simulation name will be [my team]_[file name]. - Delete Only files named [my team]_[file name] can be delete - Show Only files named [my team]_[file name] can be see - Download Only files named [my team]_[file name] can be download - All Allowed All will be allowed. 4. Click Submit Button ### Changes accounts 1. Change the items you want to change 2. Click "Save Changes" Button ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_1d413b54baaf37fd71593b57fc8b8104.png) ### Delete a account Click the trash can button to the left of the account you want to delete ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_25140fd14c678f83240ed5de4a4f7194.png) <!-- ## 権限変更 rrs-aws-ui-dockerが起動しているならば、各アカウントの権限をいつでも自由に変更することができます。 1. 任意のブラウザで <rrs-aws-ui-dockerのURL>:8080 にアクセス 2. ログイン ID:root PS:[環境構築](#環境構築)で変更したパスワード ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_38bf36d86a99e02b591ba88f4a0522b8.png) 3. データベースを選択 databaseを選択してください ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_e2d507086829faa84de7b045ed6c7961.png) 4. テーブルを選択 usersを選択してください ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_0e9a3f9cf105e3a6cfe11a19040b37a3.png) 5. データを選択 ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_88a9deafa2f346904ce1700653d4ed96.png) 6. データを編集 左上の修正をクリックして必要な部分を修正してください。 修正し終わったら左下の保存ボタンをクリックして修正部分を保存してください。 ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_0e3d9d874bfb020b477f324e03a3bfbe.png) --> ## Agent Submission You can go to the agent submission page by clicking Agent Teams in the navigation bar. ::: warning If more than one agent file has been uploaded, the last agent file uploaded will be used for the competition. ::: ### Uploading Agents 1. Check and zip the agent file Please make sure that your agent file contains at least the following files, and then zip it. ``` ex) [any name].zip . ├── config │ ├── module.cfg │ └── ... ├── data │ └── develop.json ├── library │ └── team │ └── ... └── src └── [any name] └── ... ``` ::: info You can name the zip file whatever you want. ::: 2. Click the + button Click on the + button like in the red frame in the image. ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_31ad8616e82d89e00ef766515b3cf897.png) 3. Select the agent file Click the "Select File" button and select the agent file you just zipped. ::: warning If an agent file with the same name has already been uploaded, it will be overwritten. ::: ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_db548b5c09b60afffeb7e7bbcc09f4ab.png) 4. Click the Submit button 5. Confirm the upload Make sure that your file has been uploaded correctly. ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_d25268f44f92b458c14952493c3ca534.png) ### Download the agent file Click on the download icon in the red frame in the image to download the agent file. ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_8bae40ce5ac76098519b05ca55a2f4f0.png) ### Deleting the agent file Click the trash can icon like in the red frame in the image to delete the agent file. ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_b40181f1e308af3dbcf8b874e57ff7f9.png) ## Scenario You can go to the Scenario Management page by clicking Scenario in the navigation bar. ### Uploading Scenarios 1. ZIP your scenario file After making sure that the necessary files are included, please zip the file. ``` 例) berlin.zip . ├── config │ ├── civilian.cfg │ ├── clear.cfg │ ├── collapse.cfg │ ├── common.cfg │ ├── comms │ │ ├── comms-01-full.cfg │ │ ├── comms-02-unreliable.cfg │ │ ├── comms-03-mixed.cfg │ │ ├── comms-04-many.cfg │ │ ├── comms-05-medium.cfg │ │ ├── comms-06-none.cfg │ │ └── very-limited.cfg │ ├── comms.cfg │ ├── generator.cfg │ ├── gis.cfg │ ├── ignition.cfg │ ├── kernel-inline.cfg │ ├── kernel.cfg │ ├── logviewer.cfg │ ├── misc.cfg │ ├── perception.cfg │ ├── resq-fire.cfg │ ├── sample-agents.cfg │ ├── score.cfg │ ├── traffic3.cfg │ ├── types.cfg │ └── viewer.cfg └── map ├── map.gml └── scenario.xml ``` ::: info You can name the zip file whatever you like, but since it will be shown to the competitors, we recommend that you use a name that is easy to understand, such as the name of the city. ::: 2. Click the + button Click the + button like in the red frame in the image. ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_33eed6dd42622ad64686df58a806962a.png) 3. Select a scenario file Click the Select File button and select the agent file you want to upload. ::: warning If a scenario file with the same name has already been uploaded, it will be overwritten. ::: ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_1ee205be0f913e496024d077a370a0f8.png) 4. Click the Submit button 5. Upload Confirmation Make sure that the scenario file has been uploaded correctly. ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_3ee2639b14204f33550e5e39e1349c7e.png) ### Download the scenario You can download the scenario file by clicking the download icon like in the red frame in the image. ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_20a050840cf65710ef2220791c0eb400.png) ### Deleting a Scenario You can delete the scenario file by clicking the trash icon like in the red frame in the image. ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_ebe8b92e67576d3473b6055eff088060.png) ## Simulations ### Run & Confirm simlation You can go to the simulation execution page by clicking Run in the navigation bar. 1. Click the + button Click on the + button like in the red frame in the image. ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_3dcdacc75f3818089563b77f6d37e954.png) 2. Select the agent and scenario you want to run The number to the right of the credit is the number of simulations you can currently use. (The number to the right of Credit is the number of simulations you can currently use (5 in the case of the image). ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_0db1de244870b42692728c91a11252dc.png) 3. Click the "Submit" button 4. Confirmation of simulation execution Please check if the simulation is executed correctly. (For more information about the status of the simulation, please check [Meaning of Status](#Meaning-of-Status). :::info Simulations usually take several tens of minutes. ::: ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_78a6dfa5c6596bd14e865fa455226521.png) #### Meaning of Status :::info Status is not updated, so please reload your browser manually. ::: | Status | Meaning | |:--------- |:------------------------------------------- | | SUBMITTED | Your simulation has been accepted | | PENDING | The simulation dependencies are being resolved | | RUNNABLE | Waiting for your turn to run the simulation | | STARTING | Simulation is initializing | | RUNNING | Simulation is running | | SUCCEEDED | Simulation is complete | | FAILED | Simulation has failed for some reason. | #### The instance - c5.4xlarge CPU : 1st or 2nd generation Intel Xeon Platinum 8000 series (Skylake-SP or Cascade Lake) processor Maximum CPU clock frequency : 3.6 GHz vCPU (number of cores): 16 Memory : 32GiB ### Canceling the simulation If you want to cancel the simulation, click on the x button like in the red frame in the image. ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_66f9f167f7a91783278811b6920c89b6.png) ## Simulations Results ### Viewing the results You can go to the result viewing page by clicking Results in the navigation bar. ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_6b23e37294b82bdcad54bae6ab56db4d.png) ### Downloading the results Click the download button in the red frame in the image to download the log file. ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_f237cd16ea7cfd75143092a5542ce8e0.png) ### Delete the results You can delete the results by clicking the trash button like in the red frame in the image. ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_7dd6ee1597e506d45d1775047ea99614.png) ## Batch Run Batch Run is a mode that allows you to run a simulation with multiple agents and scenarios simultaneously. ### Execute Batch Run Click Batch Run in the navigation bar to go to the Batch Run management page. 1. Click the + button Click the + button like in the red frame in the image. ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_06bdd216d8a003ae6e22fcfd8952a63a.png) 2. Select a name and the agent and scenario you want to run Enter a name of your choice in the Name input field. You can select Agent Teams and Scenario by holding down `Shift` and left-clicking on them. ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_31d2458fb784b23f2f3f781292654ce0.png) 3. Click the Submit button 4. Confirm the batch run Make sure that the batch run has been added correctly. You can also check the status of each simulation by clicking on Run. ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_5c4775c452bffee4a74b912978cbbcac.png) ### Viewing Batch Run Results Once the simulation is complete, the results will be displayed. ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_9a41220cff781b99ea3b88e4f3a374d5.png) You can click on the i button next to each simulation result to get more detailed information about that simulation. ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_d9fdb31aa5e701f6f530d784ae7cebaa.png) ## Delete Environment ### Terminate & delete the web server ``` cd rrs-aws-ui-docker sudo docker-compose down //Delete rrs-aws-ui-docker file if necessary cd .. rm -rf rrs-aws-ui-docker ``` ### AWS ::: warning This is written based on the AWS as of October 2021. It may be slightly different with future updates. ::: ::: info In this article, the language is set to English and the region is set to us-east-1. You can change the language and region if necessary. ::: Before deleting the cloudformation stack, it is necessary to delete unnecessary files (agent files, scenario files, etc.) in S3. Therefore, first delete the unnecessary files in S3. 1. Go to [S3](https://console.aws.amazon.com/s3/) 2. Select the appropriate Bucket Select the bucket whose prefix is the name you created in 6. of [Build Environment](#Build-Environment). ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_af5911fa27cef2fb2e97398ffc6a92de.png) 3. Check all the files and click "Delete" ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_c494e975cd7f67ad6770ce92d5a47127.png) 4. Enter *permanently delete* and click "Delete objects" ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_c1da23a065a83989b9c04bd48cb5a326.png) 5. Go to [Cloud Formation](https://console.aws.amazon.com/cloudformation/) 6. Select the appropriate Stack and click "Delete" in the upper right corner ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_574276d99cb7314991fd369fc86f1e29.png) 7. Click "Delete" ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_542d92e689958927614cdaaf82e42b01.png) 8. Wait a few minutes for the deletion to complete ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_45475ca052c90d189bb0430e3c7df7bb.png) 9. Confirm that the corresponding Stack has been deleted. ![](https://maslab.aitech.ac.jp/codimd/uploads/upload_c756e37b37d58b1b8f6fd30dd1346093.png)