├── _config.yml ├── auto-submission ├── aws-deepracer.cf.sample ├── aws-listTracks ├── http_header.txt ├── aws-listLeaderboards ├── aws-getAccountResources ├── aws-listModels ├── aws-listPrivateLeaderboards ├── aws-listSubscribedPrivateLeaderboards ├── aws-execCurl ├── aws-getModel ├── aws-getRankedUserSubmission ├── aws-getLatestUserSubmission ├── aws-createLeaderboardSubmission ├── aws-listLeaderboardSubmissions ├── aws-authenticate ├── aws-submitModel └── README.md ├── README.md ├── gamepad ├── README.md └── gamepad.py ├── LICENSE └── .gitignore /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-midnight -------------------------------------------------------------------------------- /auto-submission/aws-deepracer.cf.sample: -------------------------------------------------------------------------------- 1 | ACCOUNTID="123456789012" 2 | USERNAME="AWS-IAM-username" 3 | PASSWORD="" 4 | EMAIL="my-username@example.com" 5 | SUBMISSION_MAX=30 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DeepRacer Tools 2 | Some tools for AWS DeepRacer 3 | 4 | ## Auto Submission 5 | [An automated resubmission](auto-submission) of a DeepRacer model every 30 minutes. 6 | 7 | 8 | ## Gamepad 9 | Driving the DeepRacer using PS4 [Gamepad](gamepad) 10 | -------------------------------------------------------------------------------- /auto-submission/aws-listTracks: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | DATA='{"headers":{"X-Amz-User-Agent":"aws-sdk-js/2.324.0 promise","Content-Type":"application/x-amz-json-1.1","X-Amz-Target":"AwsSilverstoneCloudService.ListTracks"},"path":"/","method":"POST","region":"us-east-1","params":{},"contentString":"{\"MaxResults\":100}","operation":"listTracks"}' 4 | export DATA 5 | 6 | ./aws-execCurl | jq '.' 7 | -------------------------------------------------------------------------------- /auto-submission/http_header.txt: -------------------------------------------------------------------------------- 1 | User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36 2 | Accept-Encoding: gzip, deflate, br 3 | Sec-Fetch-Mode: cors 4 | Sec-Fetch-Site: same-origin 5 | Accept-Encoding: gzip, deflate, br 6 | Accept-Language: en-US,en;q=0.9,de;q=0.8,id;q=0.7,ms;q=0.6 7 | Accept: */* 8 | Connection: keep-alive 9 | -------------------------------------------------------------------------------- /auto-submission/aws-listLeaderboards: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | DATA='{"headers":{"X-Amz-User-Agent":"aws-sdk-js/2.324.0 promise","Content-Type":"application/x-amz-json-1.1","X-Amz-Target":"AwsSilverstoneCloudService.ListLeaderboards"},"path":"/","method":"POST","region":"us-east-1","params":{},"contentString":"{\"MaxResults\":100}","operation":"listLeaderboards"}' 4 | export DATA 5 | 6 | ./aws-execCurl | jq '.' 7 | -------------------------------------------------------------------------------- /auto-submission/aws-getAccountResources: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | DATA='{"headers":{"X-Amz-User-Agent":"aws-sdk-js/2.324.0 promise","Content-Type":"application/x-amz-json-1.1","X-Amz-Target":"AwsSilverstoneCloudService.GetAccountResources"},"path":"/","method":"POST","region":"us-east-1","params":{},"contentString":"{\"MaxResults\":100}","operation":"getAccountResources"}' 4 | export DATA 5 | 6 | ./aws-execCurl | jq '.' 7 | -------------------------------------------------------------------------------- /auto-submission/aws-listModels: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | DATA='{"headers":{"X-Amz-User-Agent":"aws-sdk-js/2.324.0 promise","Content-Type":"application/x-amz-json-1.1","X-Amz-Target":"AwsSilverstoneCloudService.ListModels"},"path":"/","method":"POST","region":"us-east-1","params":{},"contentString":"{\"ModelType\":\"REINFORCEMENT_LEARNING\",\"MaxResults\":100}","operation":"listModels"}' 4 | export DATA 5 | 6 | ./aws-execCurl | jq '.' 7 | -------------------------------------------------------------------------------- /auto-submission/aws-listPrivateLeaderboards: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | DATA='{"headers":{"X-Amz-User-Agent":"aws-sdk-js/2.324.0 promise","Content-Type":"application/x-amz-json-1.1","X-Amz-Target":"AwsSilverstoneCloudService.ListPrivateLeaderboards"},"path":"/","method":"POST","region":"us-east-1","params":{},"contentString":"{\"MaxResults\":100}","operation":"listPrivateLeaderboards"}' 4 | export DATA 5 | 6 | ./aws-execCurl | jq '.' 7 | -------------------------------------------------------------------------------- /auto-submission/aws-listSubscribedPrivateLeaderboards: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | DATA='{"headers":{"X-Amz-User-Agent":"aws-sdk-js/2.324.0 promise","Content-Type":"application/x-amz-json-1.1","X-Amz-Target":"AwsSilverstoneCloudService.ListSubscribedPrivateLeaderboards"},"path":"/","method":"POST","region":"us-east-1","params":{},"contentString":"{\"MaxResults\":100}","operation":"listSubscribedPrivateLeaderboards"}' 4 | export DATA 5 | 6 | ./aws-execCurl | jq '.' 7 | -------------------------------------------------------------------------------- /auto-submission/aws-execCurl: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | curl 'https://console.aws.amazon.com/deepracer/api/awssilverstonecloudservice' \ 4 | -H 'Origin: https://console.aws.amazon.com' \ 5 | -H 'Referer: https://console.aws.amazon.com/deepracer/home?region=us-east-1' \ 6 | -H 'Content-Type: application/json' \ 7 | -H "X-CSRF-TOKEN: ${X_CSRF_TOKEN}" \ 8 | -H "Cookie: ${AWS_COOKIE}" \ 9 | -H @http_header.txt \ 10 | --data-binary "$DATA" \ 11 | --compressed -sS 12 | 13 | -------------------------------------------------------------------------------- /gamepad/README.md: -------------------------------------------------------------------------------- 1 | # PS4 Gamepad 2 | It's a DRAFT 3 | ## Requirements 4 | - deepracer obviously 5 | - PS4 gamepad 6 | - bluetooth usb controller 7 | - python module evdev 8 | ## Installation and Setup 9 | Following steps have to be done in the deepracer after you login using ssh. 10 | ### 11 | ``` 12 | # pip install evdev 13 | # bluetoothctl 14 | # power on 15 | # scan on 16 | # pair 17 | # trust 18 | # connect 19 | ``` 20 | - Test the bluetooth device: 21 | 22 | ``` 23 | % /usr/bin/evtest 24 | ``` 25 | 26 | - Clone the deepracer-tools repository 27 | 28 | ``` 29 | % git clone https://github.com/cahya-wirawan/deepracer-tools.git 30 | % cd deepracer-tools/gamepad 31 | % python gamepad.py 32 | ``` 33 | ## ToDo List 34 | - Add more gamepads (XBox, ...) if I can get access to it 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Cahya Wirawan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /auto-submission/aws-getModel: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -z $1 ]; then 4 | echo "Usage: $0 " 5 | echo " is mandatory" 6 | echo " is optional" 7 | exit 1 8 | fi 9 | if [ -z $2 ]; then 10 | DESTDIR="." 11 | else 12 | DESTDIR="$2" 13 | fi 14 | 15 | MODELNAME=$1 16 | CONFIGFILE="aws-deepracer.cf" 17 | 18 | if [ -f $CONFIGFILE ]; then 19 | ACCOUNTID=$(grep -i ACCOUNTID $CONFIGFILE | awk -F= '{gsub(/"/, "", $2); print $2}') 20 | else 21 | echo "The config file $CONFIGFILE is not found" 22 | exit 1 23 | fi 24 | 25 | DATA='{"headers":{"X-Amz-User-Agent":"aws-sdk-js/2.324.0 promise","Content-Type":"application/x-amz-json-1.1","X-Amz-Target":"AwsSilverstoneCloudService.GetModel"},"path":"/","method":"POST","region":"us-east-1","params":{},"contentString":"{\"ModelArn\":\"arn:aws:deepracer:us-east-1:' 26 | DATA+=$ACCOUNTID 27 | DATA+=':model/reinforcement_learning/' 28 | DATA+=$MODELNAME 29 | DATA+='\"}","operation":"getModel"}' 30 | export DATA 31 | 32 | ./aws-execCurl > .curl.result 33 | 34 | errorMessage=$(jq '.error[0]' .curl.result) 35 | if [ "$errorMessage" != 'null' ]; then 36 | echo "$errorMessage" 37 | exit 1 38 | fi 39 | DRMODEL=$(jq '.Model.ModelArtifactS3Location' .curl.result | awk '{gsub("\"", "", $1); print $1}') 40 | rm -f .curl.result 41 | 42 | if [ $DRMODEL != 'null' ]; then 43 | aws s3 cp "$DRMODEL" "$DESTDIR" 44 | else 45 | echo "$MODELNAME is not found" 46 | exit 1 47 | fi 48 | 49 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | MANIFEST 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .pytest_cache/ 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | local_settings.py 57 | db.sqlite3 58 | 59 | # Flask stuff: 60 | instance/ 61 | .webassets-cache 62 | 63 | # Scrapy stuff: 64 | .scrapy 65 | 66 | # Sphinx documentation 67 | docs/_build/ 68 | 69 | # PyBuilder 70 | target/ 71 | 72 | # Jupyter Notebook 73 | .ipynb_checkpoints 74 | 75 | # pyenv 76 | .python-version 77 | 78 | # celery beat schedule file 79 | celerybeat-schedule 80 | 81 | # SageMath parsed files 82 | *.sage.py 83 | 84 | # Environments 85 | .env 86 | .venv 87 | env/ 88 | venv/ 89 | ENV/ 90 | env.bak/ 91 | venv.bak/ 92 | 93 | # Spyder project settings 94 | .spyderproject 95 | .spyproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | # mkdocs documentation 101 | /site 102 | 103 | # mypy 104 | .mypy_cache/ 105 | 106 | aws-deepracer.cf 107 | -------------------------------------------------------------------------------- /auto-submission/aws-getRankedUserSubmission: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -z $1 ]; then 4 | SEASON="season-$(date +%Y-%m)" 5 | else 6 | SEASON="season-$1" 7 | fi 8 | 9 | SEASON="season-$(date +%Y-%m)" 10 | DATASEASON='{"headers":{"X-Amz-User-Agent":"aws-sdk-js/2.324.0 promise","Content-Type":"application/x-amz-json-1.1","X-Amz-Target":"AwsSilverstoneCloudService.GetRankedUserSubmission"},"path":"/","method":"POST","region":"us-east-1","params":{},"contentString":"{\"LeaderboardArn\":\"' 11 | 12 | c_flag=0 13 | while getopts "cs:" opt; do 14 | case "$opt" in 15 | c) 16 | c_flag=1 17 | ;; 18 | s) 19 | SEASONX=(${OPTARG//-/ }) 20 | if [ "${SEASONX[0]}" -eq "${SEASONX[0]}" ] 2>/dev/null 21 | then 22 | SEASON="season-$OPTARG" 23 | else 24 | SEASON="$OPTARG" 25 | fi 26 | ;; 27 | \?) 28 | echo "Usage: `basename $0` -s [season-yyyy-mm|community race name] -c" 29 | echo "-c is optional for community race" 30 | exit 31 | ;; 32 | esac 33 | done 34 | 35 | if [ $c_flag -eq 1 ]; then 36 | LEADERBOARDS=$(./aws-listSubscribedPrivateLeaderboards) 37 | echo $LEADERBOARDS | jq '.error[0]' | grep authenticate > /dev/null 38 | if [ $? == 0 ]; then 39 | echo $LEADERBOARDS 40 | exit 1 41 | fi 42 | ARN=$(echo $LEADERBOARDS | jq '.PrivateLeaderboards[]|select(.Arn|test("'$SEASON'$"))|.Arn'|sed 's/"//g') 43 | else 44 | LEADERBOARDS=$(./aws-listLeaderboards) 45 | echo $LEADERBOARDS | jq '.error[0]' | grep authenticate > /dev/null 46 | if [ $? == 0 ]; then 47 | echo $LEADERBOARDS 48 | exit 1 49 | fi 50 | ARN=$(echo $LEADERBOARDS | jq '.Leaderboards[]|select(.Arn|test("'$SEASON'$"))|.Arn'|sed 's/"//g') 51 | fi 52 | 53 | if [ -z "$ARN" ]; then 54 | echo '{ "error": [ "'$SEASON' does not exist" ] }' 55 | exit 1 56 | fi 57 | 58 | DATASEASON="$DATASEASON$ARN" 59 | DATA=$DATASEASON'\"}","operation":"getRankedUserSubmission"}' 60 | export DATA 61 | 62 | ./aws-execCurl | jq '.' 63 | -------------------------------------------------------------------------------- /auto-submission/aws-getLatestUserSubmission: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SEASON="season-$(date +%Y-%m)" 4 | DATASEASON='{"headers":{"X-Amz-User-Agent":"aws-sdk-js/2.324.0 promise","Content-Type":"application/x-amz-json-1.1","X-Amz-Target":"AwsSilverstoneCloudService.GetLatestUserSubmission"},"path":"/","method":"POST","region":"us-east-1","params":{},"contentString":"{\"LeaderboardArn\":\"' 5 | 6 | function usage { 7 | echo "Usage: `basename $0` -s [season-yyyy-mm|community race name] -c" 8 | echo "-s if it is not used, the race name is set to season--" 9 | echo "-c is optional for community race" 10 | } 11 | 12 | c_flag=0 13 | while getopts "cs:" opt; do 14 | case "$opt" in 15 | c) 16 | c_flag=1 17 | ;; 18 | s) 19 | SEASONX=(${OPTARG//-/ }) 20 | if [ "${SEASONX[0]}" -eq "${SEASONX[0]}" ] 2>/dev/null 21 | then 22 | SEASON="season-$OPTARG" 23 | else 24 | SEASON="$OPTARG" 25 | fi 26 | ;; 27 | \?) 28 | usage 29 | exit 30 | ;; 31 | esac 32 | done 33 | 34 | if [ $c_flag -eq 1 ]; then 35 | LEADERBOARDS=$(./aws-listSubscribedPrivateLeaderboards) 36 | echo $LEADERBOARDS | jq '.error[0]' | grep authenticate > /dev/null 37 | if [ $? == 0 ]; then 38 | echo $LEADERBOARDS 39 | exit 1 40 | fi 41 | ARN=$(echo $LEADERBOARDS | jq '.PrivateLeaderboards[]|select(.Arn|test("'$SEASON'$"))|.Arn'|sed 's/"//g') 42 | else 43 | LEADERBOARDS=$(./aws-listLeaderboards) 44 | echo $LEADERBOARDS | jq '.error[0]' | grep authenticate > /dev/null 45 | if [ $? == 0 ]; then 46 | echo $LEADERBOARDS 47 | exit 1 48 | fi 49 | ARN=$(echo $LEADERBOARDS | jq '.Leaderboards[]|select(.Arn|test("'$SEASON'$"))|.Arn'|sed 's/"//g') 50 | fi 51 | 52 | if [ -z "$ARN" ]; then 53 | echo '{ "error": [ "'$SEASON' does not exist" ] }' 54 | exit 1 55 | fi 56 | 57 | DATASEASON="$DATASEASON$ARN" 58 | 59 | DATA=$DATASEASON'\"}","operation":"getLatestUserSubmission"}' 60 | export DATA 61 | 62 | ./aws-execCurl | jq '.' 63 | -------------------------------------------------------------------------------- /auto-submission/aws-createLeaderboardSubmission: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | function usage { 4 | echo "Usage: `basename $0` -m modelname -s [season-yyyy-mm|community race name] -c" 5 | echo "-m is mandatory" 6 | echo "-s if it is not used, the race name is set to season--" 7 | echo "-c is optional for community race" 8 | } 9 | 10 | MODELNAME="" 11 | CONFIGFILE="aws-deepracer.cf" 12 | 13 | if [ -f $CONFIGFILE ]; then 14 | ACCOUNTID=$(grep -i ACCOUNTID $CONFIGFILE | awk -F= '{gsub(/"/, "", $2); print $2}') 15 | else 16 | echo "The config file $CONFIGFILE is not found" 17 | exit 1 18 | fi 19 | 20 | SEASON="season-$(date +%Y-%m)" 21 | DATASEASON='{"headers":{"X-Amz-User-Agent":"aws-sdk-js/2.324.0 promise","Content-Type":"application/x-amz-json-1.1","X-Amz-Target":"AwsSilverstoneCloudService.CreateLeaderboardSubmission"},"path":"/","method":"POST","region":"us-east-1","params":{},"contentString":"{\"LeaderboardArn\":\"' 22 | 23 | m_flag=0 24 | c_flag=0 25 | while getopts "m:cs:" opt; do 26 | case "$opt" in 27 | m) 28 | MODELNAME="$OPTARG" 29 | m_flag=1 30 | ;; 31 | c) 32 | c_flag=1 33 | ;; 34 | s) 35 | SEASONX=(${OPTARG//-/ }) 36 | if [ "${SEASONX[0]}" -eq "${SEASONX[0]}" ] 2>/dev/null 37 | then 38 | SEASON="season-$OPTARG" 39 | else 40 | SEASON="$OPTARG" 41 | fi 42 | ;; 43 | \?) 44 | usage 45 | exit 46 | ;; 47 | esac 48 | done 49 | 50 | if [ $m_flag -eq 0 ]; then 51 | usage 52 | exit 53 | fi 54 | 55 | 56 | if [ $c_flag -eq 1 ]; then 57 | LEADERBOARDS=$(./aws-listSubscribedPrivateLeaderboards) 58 | echo $LEADERBOARDS | jq '.error[0]' | grep authenticate > /dev/null 59 | if [ $? == 0 ]; then 60 | echo $LEADERBOARDS 61 | exit 1 62 | fi 63 | ARN=$(echo $LEADERBOARDS | jq '.PrivateLeaderboards[]|select(.Arn|test("'$SEASON'$"))|.Arn'|sed 's/"//g') 64 | else 65 | LEADERBOARDS=$(./aws-listLeaderboards) 66 | echo $LEADERBOARDS | jq '.error[0]' | grep authenticate > /dev/null 67 | if [ $? == 0 ]; then 68 | echo $LEADERBOARDS 69 | exit 1 70 | fi 71 | ARN=$(echo $LEADERBOARDS | jq '.Leaderboards[]|select(.Arn|test("'$SEASON'$"))|.Arn'|sed 's/"//g') 72 | fi 73 | 74 | if [ -z "$ARN" ]; then 75 | echo '{ "error": [ "'$SEASON' does not exist" ] }' 76 | exit 1 77 | fi 78 | 79 | DATASEASON="$DATASEASON$ARN" 80 | DATA=$DATASEASON'\",\"ModelArn\":\"arn:aws:deepracer:us-east-1:' 81 | DATA+=$ACCOUNTID 82 | DATA+=':model/reinforcement_learning/' 83 | DATA+=$MODELNAME 84 | DATA+='\"}","operation":"createLeaderboardSubmission"}' 85 | export DATA 86 | 87 | ./aws-execCurl | jq '.' 88 | -------------------------------------------------------------------------------- /auto-submission/aws-listLeaderboardSubmissions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SEASON="season-$(date +%Y-%m)" 4 | DRUSER="" 5 | DATASEASON='{"headers":{"X-Amz-User-Agent":"aws-sdk-js/2.324.0 promise","Content-Type":"application/x-amz-json-1.1","X-Amz-Target":"AwsSilverstoneCloudService.ListLeaderboardSubmissions"},"path":"/","method":"POST","region":"us-east-1","params":{},"contentString":"{\"LeaderboardArn\":\"' 6 | 7 | function usage { 8 | echo "Usage: `basename $0` -s [season-yyyy-mm|community race name] -u username -c" 9 | echo "-s if it is not used, the race name is set to season--" 10 | echo "-c is optional for community race" 11 | } 12 | 13 | c_flag=0 14 | while getopts "cs:u:" opt; do 15 | case "$opt" in 16 | c) 17 | c_flag=1 18 | ;; 19 | s) 20 | SEASONX=(${OPTARG//-/ }) 21 | if [ "${SEASONX[0]}" -eq "${SEASONX[0]}" ] 2>/dev/null 22 | then 23 | SEASON="season-$OPTARG" 24 | else 25 | SEASON="$OPTARG" 26 | fi 27 | ;; 28 | u) DRUSER=$OPTARG 29 | ;; 30 | \?) 31 | usage 32 | exit 33 | ;; 34 | esac 35 | done 36 | 37 | if [ $c_flag -eq 1 ]; then 38 | LEADERBOARDS=$(./aws-listSubscribedPrivateLeaderboards) 39 | echo $LEADERBOARDS | jq '.error[0]' | grep authenticate > /dev/null 40 | if [ $? == 0 ]; then 41 | echo $LEADERBOARDS 42 | exit 1 43 | fi 44 | ARN=$(echo $LEADERBOARDS | jq '.PrivateLeaderboards[]|select(.Arn|test("'$SEASON'$"))|.Arn'|sed 's/"//g') 45 | if [ -z "$ARN" ]; then 46 | LEADERBOARDS=$(./aws-listPrivateLeaderboards) 47 | ARN=$(echo $LEADERBOARDS | jq '.PrivateLeaderboards[]|select(.Arn|test("'$SEASON'$"))|.Arn'|sed 's/"//g') 48 | fi 49 | else 50 | LEADERBOARDS=$(./aws-listLeaderboards) 51 | echo $LEADERBOARDS | jq '.error[0]' | grep authenticate > /dev/null 52 | if [ $? == 0 ]; then 53 | echo $LEADERBOARDS 54 | exit 1 55 | fi 56 | ARN=$(echo $LEADERBOARDS | jq '.Leaderboards[]|select(.Arn|test("'$SEASON'$"))|.Arn'|sed 's/"//g') 57 | fi 58 | 59 | if [ -z "$ARN" ]; then 60 | echo '{ "error": [ "'$SEASON' does not exist" ] }' 61 | exit 1 62 | fi 63 | 64 | DATASEASON="$DATASEASON$ARN" 65 | DATA=$DATASEASON'\",\"MaxResults\":100}","operation":"listLeaderboardSubmissions"}' 66 | export DATA 67 | 68 | counter=0 69 | ./aws-execCurl | jq '.' > .curl.result.$counter 70 | NextToken=$(jq '.NextToken' .curl.result.$counter | sed 's/"/\\"/g') 71 | LeaderBoard=$(jq '.LeaderboardSubmissions' .curl.result.$counter) 72 | while [ $NextToken != 'null' ]; do 73 | DATA=$DATASEASON'\",\"MaxResults\":100,\"NextToken\":'$NextToken'}","operation":"listLeaderboardSubmissions"}' 74 | export DATA 75 | counter=$(( $counter+1 )) 76 | ./aws-execCurl | jq '.' > .curl.result.$counter 77 | NextToken=$(jq '.NextToken' .curl.result.$counter | sed 's/"/\\"/g') 78 | LeaderBoard="$LeaderBoard $(jq '.LeaderboardSubmissions' .curl.result.$counter)" 79 | done 80 | 81 | rm .curl.result.* 82 | if [ -z $DRUSER ]; then 83 | echo $LeaderBoard | jq -s add 84 | else 85 | echo $LeaderBoard | jq -s 'add[]|select(.Alias == "'$DRUSER'")' 86 | fi 87 | -------------------------------------------------------------------------------- /auto-submission/aws-authenticate: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [[ $0 == *"aws-authenticate"* ]]; then 4 | echo "Please use 'source ./aws-authenticate'" 5 | exit 1 6 | fi 7 | 8 | CONFIGFILE="aws-deepracer.cf" 9 | 10 | if [ ! -z "$AWS_COOKIE" ]; then 11 | ./aws-getLatestUserSubmission | jq '.error[0]' | grep authenticate > /dev/null 12 | if [ $? == 1 ]; then 13 | return 0 14 | fi 15 | fi 16 | 17 | if [ -f $CONFIGFILE ]; then 18 | ACCOUNTID=$(grep -i ACCOUNTID $CONFIGFILE | awk -F= '{gsub(/"/, "", $2); print $2}') 19 | USERNAME=$(grep -i USERNAME $CONFIGFILE | awk -F= '{gsub(/"/, "", $2); print $2}') 20 | PASSWORD=$(grep -i PASSWORD $CONFIGFILE | awk -F= '{gsub(/"/, "", $2); print $2}') 21 | else 22 | echo "The config file $CONFIGFILE is not found" 23 | return 1 24 | fi 25 | 26 | if [ -z $ACCOUNTID ]; then 27 | read -p 'Account ID: ' ACCOUNTID 28 | fi 29 | if [ -z $USERNAME ]; then 30 | read -p 'Username: ' USERNAME 31 | fi 32 | if [ -z $PASSWORD ]; then 33 | read -sp 'Password: ' PASSWORD 34 | echo 35 | fi 36 | 37 | curl -i -s -k -X $'POST' \ 38 | -m 5 \ 39 | -H @http_header.txt \ 40 | -H 'Accept: application/json, text/plain, */*' \ 41 | -H 'Content-Type: application/x-www-form-urlencoded' \ 42 | -H 'Referer: https://us-east-1.signin.aws.amazon.com/oauth?SignatureVersion=4' \ 43 | --data-binary "action=iam-user-authentication&account=${ACCOUNTID}&username=${USERNAME}&password=${PASSWORD}&redirect_uri=https%3A%2F%2Fconsole.aws.amazon.com%2Fdeepracer%2Fhome%3Fregion%3Dus-east-1%26state%3DhashArgs%2523leaderboard%26isauthcode%3Dtrue&client_id=arn%3Aaws%3Aiam%3A%3A015428540659%3Auser%2Fsilverstone" \ 44 | 'https://us-east-1.signin.aws.amazon.com/authenticate' > .curl.result 45 | 46 | if [ $? != 0 ]; then 47 | echo "Can't authenticate" 48 | return 1 49 | fi 50 | STATE=$(grep state .curl.result | jq '.state' | awk '{gsub("\"", "", $1); print $1}') 51 | if [ $STATE != 'SUCCESS' ]; then 52 | echo "Failed to authenticate" 53 | return 1 54 | fi 55 | 56 | USERINFO=$(grep userInfo .curl.result |awk -F'[=;]' '{print $2}') 57 | REDIRECTURL=$(grep SUCCESS .curl.result | jq '.properties.redirectUrl' | awk '{print substr($1, 2, length($1)-2)}') 58 | 59 | curl -i -s -k -X $'GET' \ 60 | -H @http_header.txt \ 61 | -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' \ 62 | -H 'Referer: https://us-east-1.signin.aws.amazon.com/oauth?SignatureVersion=4' \ 63 | -H "Cookie: aws-userInfo=${USERINFO}" \ 64 | -b "aws-userInfo=${USERINFO}" \ 65 | "$REDIRECTURL" > .curl.result 66 | 67 | USERCREDS=$(grep 'aws-creds' .curl.result | awk -F'[;=]' '{print $2}') 68 | 69 | curl -i -s -k -X $'GET' \ 70 | --compressed \ 71 | -H @http_header.txt \ 72 | -H $'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' \ 73 | -H $"Cookie: aws-userInfo=${USERINFO}; aws-creds=${USERCREDS}" \ 74 | -b $"aws-userInfo=${USERINFO}; aws-creds=${USERCREDS}" \ 75 | $'https://console.aws.amazon.com/deepracer/home?region=us-east-1' > .curl.result 76 | 77 | X_CSRF_TOKEN=$(grep awsc-csrf-token .curl.result |awk -F'[=>]' '{gsub(/"/, "", $3); print $3}') 78 | AWS_COOKIE="aws-userInfo=$USERINFO; aws-creds=$USERCREDS" 79 | 80 | export X_CSRF_TOKEN 81 | export AWS_COOKIE 82 | 83 | rm -f .curl.result 84 | -------------------------------------------------------------------------------- /auto-submission/aws-submitModel: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | function usage { 4 | echo "Usage: `basename $0` -m modelname -s [season-yyyy-mm|community race name] -t -c" 5 | echo "-m is mandatory" 6 | echo "-s [season-yyyy-mm|community race name] if it is not used, the race name is set to season--" 7 | echo "-c is optional for community race" 8 | echo "-t is optional" 9 | } 10 | 11 | SEASON="season-$(date +%Y-%m)" 12 | TIME=0 13 | m_flag=0 14 | c_flag=0 15 | while getopts "m:cs:t:" opt; do 16 | case "$opt" in 17 | m) 18 | MODELNAME="$OPTARG" 19 | m_flag=1 20 | ;; 21 | c) 22 | c_flag=1 23 | ;; 24 | s) 25 | SEASONX=(${OPTARG//-/ }) 26 | if [ "${SEASONX[0]}" -eq "${SEASONX[0]}" ] 2>/dev/null 27 | then 28 | SEASON="season-$OPTARG" 29 | else 30 | SEASON="$OPTARG" 31 | fi 32 | ;; 33 | t) 34 | TIME="$OPTARG" 35 | ;; 36 | \?) 37 | usage 38 | exit 39 | ;; 40 | esac 41 | done 42 | 43 | if [ $m_flag -eq 0 ]; then 44 | usage 45 | exit 46 | fi 47 | 48 | CONFIGFILE="aws-deepracer.cf" 49 | 50 | if [ -f "$CONFIGFILE" ]; then 51 | EMAIL=$(grep -i EMAIL "$CONFIGFILE" | awk -F= '{gsub(/"/, "", $2); print $2}') 52 | SUBMISSION_MAX=$(grep -i SUBMISSION_MAX $CONFIGFILE | awk -F= '{gsub(/"/, "", $2); print $2}') 53 | else 54 | echo "The config file "$CONFIGFILE" is not found" 55 | exit 1 56 | fi 57 | 58 | if [ -z "$EMAIL" ]; then 59 | read -p 'Email: ' EMAIL 60 | fi 61 | if [ -z "$SUBMISSION_MAX" ]; then 62 | SUBMISSION_MAX=20 63 | fi 64 | 65 | sleep $TIME 66 | submissionCounter=0 67 | waitingTime=0 68 | while [ $submissionCounter -lt $SUBMISSION_MAX ]; 69 | do 70 | sleep $waitingTime 71 | date 72 | if [ $c_flag -eq 0 ]; then 73 | submissionReport=$(./aws-createLeaderboardSubmission -m "$MODELNAME" -s "$SEASON") 74 | else 75 | submissionReport=$(./aws-createLeaderboardSubmission -m "$MODELNAME" -s "$SEASON" -c) 76 | fi 77 | submissionLength=$(echo "$submissionReport" | jq 'length') 78 | if [ "$submissionLength" != 0 ] 79 | then 80 | report=$(echo "$submissionReport" | jq '.Message') 81 | if [ "$report" == "null" ]; then 82 | report=$(echo "$submissionReport" | jq '.error[0]') 83 | if [[ $report == *auth* ]]; then 84 | source ./aws-authenticate 85 | continue 86 | elif [ "$report" == "null" ]; then 87 | report="Unknown problem" 88 | fi 89 | fi 90 | echo "$report" 91 | echo "$report" | mailx -s "Deepracer Submission" "$EMAIL" 92 | exit 1 93 | fi 94 | submissionCounter=$(( $submissionCounter + 1 )) 95 | sleep 300 96 | latestStatus='"RUNNING"' 97 | waitingCounter=0 98 | while [ "$latestStatus" == '"RUNNING"' ] 99 | do 100 | if [ $c_flag -eq 0 ]; then 101 | latestUserSubmission=$(./aws-getLatestUserSubmission -s "$SEASON") 102 | else 103 | latestUserSubmission=$(./aws-getLatestUserSubmission -s "$SEASON" -c) 104 | fi 105 | latestStatus=$(echo "$latestUserSubmission" | jq '.LeaderboardSubmission.LeaderboardSubmissionStatusType') 106 | lapTime=$(echo "$latestUserSubmission" | jq '.LeaderboardSubmission.AvgLapTime') 107 | echo "$latestStatus $lapTime" 108 | waitingCounter=$(( $waitingCounter + 1 )) 109 | sleep 10 110 | done 111 | echo "$latestStatus: $lapTime" | mailx -s "Deepracer Submission" $EMAIL 112 | waitingTime=$(( 30*60 - 300 - 10*$waitingCounter )) 113 | done 114 | 115 | echo "End of Submission" | mailx -s "Deepracer Submission" $EMAIL 116 | 117 | -------------------------------------------------------------------------------- /gamepad/gamepad.py: -------------------------------------------------------------------------------- 1 | from time import time, sleep 2 | import math 3 | import os.path 4 | from select import select 5 | import evdev 6 | import rospy 7 | from ctrl_pkg.msg import ServoCtrlMsg 8 | from ctrl_pkg.srv import (ActiveStateSrv, 9 | EnableStateSrv, 10 | NavThrottleSrv) 11 | 12 | DEVICE = "/dev/input/event6" 13 | ROS_RATE = 20 # 20hz 14 | TIME_DIFF = 1.0/ROS_RATE 15 | TIME_TO_STOP = 1.0 # 1 seconds to stop the motor 16 | X_AXIS_THRESHOLD = 0.85 17 | throttle_max = 0.6 18 | motor_state = True 19 | 20 | def scale(val, src, dst): 21 | return (float(val - src[0]) / (src[1] - src[0])) * (dst[1] - dst[0]) + dst[0] 22 | 23 | 24 | def scale_stick(value): 25 | return scale(value, (0, 255), (-1.0, 1.0)) 26 | 27 | 28 | if __name__ == '__main__': 29 | rospy.init_node('gamepad_node', disable_signals=True) 30 | pub_manual_drive = rospy.Publisher('manual_drive', ServoCtrlMsg, queue_size=10) 31 | enable_state_req = rospy.ServiceProxy('enable_state', EnableStateSrv) 32 | msg = ServoCtrlMsg() 33 | 34 | while True: 35 | if not os.path.exists(DEVICE): 36 | print("sleep!") 37 | sleep(1.0) 38 | continue 39 | try: 40 | gamepad = evdev.InputDevice(DEVICE) 41 | rospy.loginfo(gamepad) 42 | last_time = time() - TIME_DIFF 43 | angle = 0.0 44 | throttle = 0.0 45 | x_axis = 0.0 46 | y_axis = 0.0 47 | start_stop_state = False 48 | 49 | while True: 50 | # print(evdev.categorize(event)) 51 | r, w, x = select([gamepad.fd], [], [], TIME_TO_STOP) 52 | if r: 53 | for event in gamepad.read(): 54 | now = time() 55 | if event.type == 1: # Right Button 56 | if event.code == 304 and event.value == 1: #BTN_SOUTH 57 | motor_state = not motor_state 58 | start_stop_state = not start_stop_state 59 | enable_state_req(start_stop_state) 60 | rospy.loginfo("###### START/STOP: " + str(start_stop_state) + ":" + str(motor_state)) 61 | elif event.code == 307 and event.value == 1: #BTN_NORTH 62 | throttle_max = min(1.0, throttle_max + 0.1) 63 | rospy.loginfo("###### throttle_max: " + str(throttle_max)) 64 | elif event.code == 308 and event.value == 1: #BTN_WEST 65 | throttle_max = max(0.3, throttle_max - 0.1) 66 | rospy.loginfo("###### throttle_max: " + str(throttle_max)) 67 | if event.type == 3 and (event.code == 0 or event.code == 1): # Analog stick 68 | if now - last_time < TIME_DIFF: 69 | continue 70 | if event.code == 0: # X axis 71 | x_axis = scale_stick(event.value) 72 | angle = - x_axis 73 | if event.code == 1: # Y axis 74 | y_axis = scale_stick(event.value) 75 | throttle = min(1.0, math.sqrt(y_axis*y_axis + x_axis*x_axis)) 76 | throttle = - math.copysign(throttle, y_axis) 77 | # Reduce the throttle if abs(x_axis) near 1 so throttle doesn't make big change abruptly 78 | # when +y_axis switch to -y_axis 79 | if abs(x_axis) > X_AXIS_THRESHOLD: 80 | throttle_scale = (1.0 - abs(x_axis)) / (1.0 - X_AXIS_THRESHOLD) 81 | throttle = throttle_scale * throttle 82 | if motor_state and not start_stop_state and abs(angle) >= 0.1 and abs(throttle) >= 0.1: 83 | start_stop_state = True 84 | enable_state_req(start_stop_state) 85 | rospy.loginfo("###### START") 86 | if event.code == 0 or event.code == 1: 87 | if start_stop_state: 88 | try: 89 | if not rospy.is_shutdown(): 90 | msg.angle = angle 91 | msg.throttle = throttle_max * throttle 92 | pub_manual_drive.publish(msg) 93 | # rospy.loginfo(msg) 94 | last_time = now 95 | except rospy.ROSInterruptException: 96 | print("ROS exit") 97 | exit(0) 98 | else: 99 | if start_stop_state: 100 | start_stop_state = False 101 | enable_state_req(start_stop_state) 102 | rospy.loginfo("###### STOP") 103 | 104 | except IOError: 105 | print("IOError") 106 | pass 107 | -------------------------------------------------------------------------------- /auto-submission/README.md: -------------------------------------------------------------------------------- 1 | # Auto Submission 2 | 3 | AWS DeepRacer provides a virtual circuit where we can submit our model. The 4 | same model can get different lap time for every submission, therefore 5 | people resubmit it several times to get the fastest possible lap time. 6 | There is currently no restriction on how often we can submit our model, 7 | however, we have to wait 30 minutes between submission. All of these 8 | submissions have been done using a web browser since there is currently 9 | no DeepRacer capability in AWS CLI. Some people use the Selenium web 10 | browser plugin to automate this task. 11 | 12 | The aim of this DeepRacer Auto Submission Tool is, as the title says, to 13 | resubmit automatically a DeepRacer model every 30 minutes using only the 14 | command-line interface. It consists of several shell scripts and requires 15 | only curl, a command-line tool for data transfer, and jq, a lightweight 16 | command-line JSON processor. This approach uses very minimal resources 17 | (memory, CPU, network traffic) comparing to the solution with a full-blown 18 | web browser and its plugin/macro. This auto submitter sends only the 19 | necessary HTTP requests to AWS without many other HTTP requests normally 20 | communicated between a browser and a web server. The authentication process 21 | needs only 3 HTTP requests to get the necessary tokens (auth-userInfo, 22 | auth-creds, and x-csrf-token). 23 | 24 | ## Usage 25 | 1. First Install the requirements (curl is normally already installed on your machine): 26 | ``` 27 | $ sudo apt install curl jq 28 | ``` 29 | 2. Then you have to clone this repository: 30 | ``` 31 | $ git clone https://github.com/cahya-wirawan/deepracer-tools.git 32 | ``` 33 | 3. Change to the tool directory: 34 | ``` 35 | $ cd deepracer-tools/auto-submission 36 | ``` 37 | 4. Copy the configuration template, and update it with your AWS IAM 38 | credential: 39 | ``` 40 | $ cp aws-deepracer.cf.sample aws-deepracer.cf 41 | $ cat aws-deepracer.cf 42 | ACCOUNTID="123456789012" 43 | USERNAME="my-username" 44 | PASSWORD="" 45 | EMAIL="my-username@example.com" 46 | ``` 47 | If the password is empty, the script will ask you for it. The email address is used to inform you when the result of 48 | the submission is arrive or if there is any issue with the submission. 49 | 5. Login to the AWS 50 | ``` 51 | $ source ./aws-authenticate 52 | ``` 53 | This authentication process will save the authentication tokens (aws-userInfo and aws-creds) and CSRF token in your 54 | environment variables for further usage, so you don't need to authenticate for every scripts you run next time 55 | until they are expire. The tokens will be valid for around 10 hours, after expired, you need to reauthenticate again 56 | using the script above. 57 | 6. Run the Auto Submission script and wait for email notification :-) It assumes that you have already uploaded your 58 | model trained locally or the model has been trained in the AWS cloud. 59 | ``` 60 | $ ./aws-submitModel -m "Your deepracer model name" 61 | ``` 62 | 63 | ## List of the tools 64 | The tool has not only the main script to auto resubmit the model, but include also some other scripts. Following is 65 | the complete list of the scripts: 66 | 1. aws-authenticate 67 | 68 | This is the first script to be executed before you can use other scripts. 69 | Run it as follow: 70 | ``` 71 | $ source ./aws-authenticate 72 | ``` 73 | 2. aws-createLeaderboardSubmission 74 | 75 | The script submit a model. An example to run it and its output if you have submitted a model in the last 30 minutes: 76 | ``` 77 | $ ./aws-createLeaderboardSubmission -m DR-Local 78 | { 79 | "__type": "TooManyRequestsException", 80 | "Message": "You have exceeded the number leaderboard submission requests allowed on your account." 81 | } 82 | ``` 83 | Submit a model for a specific official deepracer race: 84 | ``` 85 | $ ./aws-createLeaderboardSubmission -m DR-Local -s season-2020-02 86 | ``` 87 | Submit a model for a specific community race : 88 | ``` 89 | $ ./aws-createLeaderboardSubmission -m DR-Local -s AWSDeepRacerCommunityContest3 -c 90 | ``` 91 | 3. aws-getLatestUserSubmission 92 | 93 | The script retrieves the status of the latest user submission. The status can RUNNING, FAILED or SUCCESS. 94 | It includes the average lap time in second if the status is success. 95 | ``` 96 | $ ./aws-getLatestUserSubmission 97 | { 98 | "LeaderboardSubmission": { 99 | "Alias": "DodolGarut", 100 | "AvgLapTime": 0, 101 | "JobName": "sim-9jk8hj5zmjlm", 102 | "LapCount": 0, 103 | "LeaderboardSubmissionStatusType": "RUNNING", 104 | "ModelArn": "arn:aws:deepracer:us-east-1:123456789012:model/reinforcement_learning/DR-Local", 105 | "SubmissionTime": 1571232665626 106 | } 107 | } 108 | ``` 109 | Get the latest user submission on community race: 110 | ``` 111 | $ ./aws-getLatestUserSubmission -s AWSDeepRacerCommunityContest3 -c 112 | ``` 113 | 4. aws-getRankedUserSubmission 114 | 115 | The script retrieves the user ranking in the league in the current race or on a specific month. 116 | ``` 117 | $ ./aws-getRankedUserSubmission 118 | { 119 | "LeaderboardSubmission": { 120 | "Alias": "DodolGarut", 121 | "AvgLapTime": 10254, 122 | "LeaderboardSubmissionStatusType": "SUCCESS", 123 | "ModelArn": "arn:aws:deepracer:us-east-1:123456789012:model/reinforcement_learning/DR-Local", 124 | "Rank": 50, 125 | "SubmissionTime": 1571226412408 126 | } 127 | } 128 | $ ./aws-getRankedUserSubmission -s season-2019-08 129 | { 130 | "LeaderboardSubmission": { 131 | "Alias": "DodolGarut", 132 | "AvgLapTime": 13256, 133 | "LeaderboardSubmissionStatusType": "SUCCESS", 134 | "ModelArn": "arn:aws:deepracer:us-east-1:123456789012:model/reinforcement_learning/DR-Local", 135 | "Rank": 155, 136 | "SubmissionTime": 1566847602947 137 | } 138 | } 139 | $ ./aws-getRankedUserSubmission -s AWSDeepRacerCommunityContest3 -c 140 | { 141 | "LeaderboardSubmission": { 142 | "Alias": "DodolGarut", 143 | "AvgLapTime": 33493, 144 | "LeaderboardSubmissionStatusType": "SUCCESS", 145 | "ModelArn": "arn:aws:deepracer:us-east-1:123456789012:model/reinforcement_learning/Avalon", 146 | "Rank": 16, 147 | "SubmissionTime": 1578323183740 148 | } 149 | } 150 | 151 | ``` 152 | 5. aws-listLeaderboardSubmissions 153 | ``` 154 | $ ./aws-listLeaderboardSubmissions 155 | [ 156 | { 157 | "Alias": "Karl-NAB", 158 | "AvgLapTime": 7555, 159 | "LeaderboardSubmissionStatusType": "SUCCESS", 160 | "Rank": 1, 161 | "SubmissionTime": 1571051009345 162 | }, 163 | { 164 | "Alias": "JJ", 165 | "AvgLapTime": 7745, 166 | "LeaderboardSubmissionStatusType": "SUCCESS", 167 | "Rank": 2, 168 | "SubmissionTime": 1571195290542 169 | }, 170 | { 171 | "Alias": "D4D-test", 172 | "AvgLapTime": 8305, 173 | "LeaderboardSubmissionStatusType": "SUCCESS", 174 | "Rank": 3, 175 | "SubmissionTime": 1571128249473 176 | }, 177 | .... 178 | { 179 | "Alias": "Shendy", 180 | "AvgLapTime": 11476, 181 | "LeaderboardSubmissionStatusType": "SUCCESS", 182 | "Rank": 99, 183 | "SubmissionTime": 1570583780470 184 | }, 185 | { 186 | "Alias": "PolishThunder", 187 | "AvgLapTime": 11506, 188 | "LeaderboardSubmissionStatusType": "SUCCESS", 189 | "Rank": 100, 190 | "SubmissionTime": 1571107235595 191 | } 192 | ] 193 | $ ./aws-listLeaderboardSubmissions -s AWSDeepRacerCommunityContest3 -c 194 | [ 195 | { 196 | "Alias": "JJ", 197 | "AvgLapTime": 9197, 198 | "LeaderboardSubmissionStatusType": "SUCCESS", 199 | "Rank": 1, 200 | "SubmissionTime": 1578347651808 201 | }, 202 | { 203 | "Alias": "MattCamp", 204 | "AvgLapTime": 10132, 205 | "LeaderboardSubmissionStatusType": "SUCCESS", 206 | "Rank": 2, 207 | "SubmissionTime": 1578420291352 208 | }, 209 | ... 210 | ] 211 | 212 | ``` 213 | 6. aws-listLeaderboards 214 | ``` 215 | $ ./aws-listLeaderboards 216 | { 217 | "Leaderboards": [ 218 | { 219 | "Arn": "arn:aws:deepracer:us-east-1::leaderboard/season-2019-08", 220 | "CloseTime": 1567295999000, 221 | "Description": "The August race is now open and is the fourth stop on the Virtual Circuit World Tour. Create and train a model to master the Shanghai Sudu track and submit your model for a chance to win an all-expenses paid trip to Las Vegas, NV, to compete for the Championship Cup at re:Invent 2019!", 222 | "ImageUrl": "https://deepracer-managed-resources-us-east-1.s3.amazonaws.com/leaderboard-resources/china_leaderboard.svg", 223 | "LaunchTime": 1564642800000, 224 | "MinimumLaps": 1, 225 | "Name": "Shanghai Sudu", 226 | "ParticipantCount": 1375, 227 | "Status": "CLOSED", 228 | "TrackArn": "arn:aws:deepracer:us-east-1::track/ChinaAlt_track", 229 | "TrackImageUrl": "https://deepracer-managed-resources-us-east-1.s3.amazonaws.com/track-resources/chinaalt_track.svg" 230 | }, 231 | { 232 | "Arn": "arn:aws:deepracer:us-east-1::leaderboard/season-2019-06", 233 | "CloseTime": 1561964399000, 234 | "Description": "Continue racing and building up League points in the Kumo Torakku, the second stop in the Virtual Circuit World Tour. The race winner and season top point getters will win an expenses paid trip to compete for the Championship Cup at re:Invent 2019.", 235 | "ImageUrl": "https://deepracer-managed-resources-us-east-1.s3.amazonaws.com/leaderboard-resources/japan_leaderboard.svg", 236 | "LaunchTime": 1559595600000, 237 | "MinimumLaps": 1, 238 | "Name": "Kumo Torakku", 239 | "ParticipantCount": 572, 240 | "Status": "CLOSED", 241 | "TrackArn": "arn:aws:deepracer:us-east-1::track/Tokyo_Racing_track", 242 | "TrackImageUrl": "https://deepracer-managed-resources-us-east-1.s3.amazonaws.com/track-resources/tokyo_racing_track.svg" 243 | }, 244 | ... 245 | } 246 | ``` 247 | 7. aws-listSubscribedPrivateLeaderboards 248 | 249 | List all private leaderboards (community races) that the user has subscribed. 250 | ``` 251 | $ ./aws-listSubscribedPrivateLeaderboards 252 | { 253 | "PrivateLeaderboards": [ 254 | { 255 | "Arn": "arn:aws:deepracer::324010867108:leaderboard/AWS-DeepRacer-Innovate-Challenge", 256 | "Description": "Official AWS Innovate AI/ML Edition AWS DeepRacer Challenge in Feb 2020.", 257 | "EndTime": 1582934400000, 258 | "LeaderboardImage": "LeaderboardImage6", 259 | "MinimumLaps": 1, 260 | "Name": "AWS-DeepRacer-Innovate-Challenge", 261 | "ParticipantCount": 33, 262 | "StartTime": 1577836800000, 263 | "Status": "OPEN", 264 | "TotalLaps": 3, 265 | "TrackArn": "arn:aws:deepracer:us-east-1::track/reInvent2019_track" 266 | }, 267 | { 268 | "Arn": "arn:aws:deepracer::579906027743:leaderboard/AWSDeepRacerCommunityContest3", 269 | "Description": "DeepRacer Community Contest #3! This is an endurance race where the aim is to complete 3/3 laps. Prizes of AWS credits for the top 10. To qualify, you must also register for the contest at https://contest.deepracing.io", 270 | "EndTime": 1579305600000, 271 | "LeaderboardImage": "LeaderboardImage5", 272 | "MinimumLaps": 3, 273 | "Name": "AWSDeepRacerCommunityContest3", 274 | "ParticipantCount": 21, 275 | "StartTime": 1578096000000, 276 | "Status": "OPEN", 277 | "TotalLaps": 3, 278 | "TrackArn": "arn:aws:deepracer:us-east-1::track/Vegas_track" 279 | } 280 | ] 281 | } 282 | ``` 283 | 8. aws-submitModel 284 | ``` 285 | $ ./aws-submitModel -m DR-Local 286 | ... 287 | Mi Okt 16 13:15:05 CEST 2019 288 | "RUNNING" 0 289 | "RUNNING" 0 290 | "RUNNING" 0 291 | "SUCCESS" 10802 292 | Mi Okt 16 14:48:15 CEST 2019 293 | "RUNNING" 0 294 | "RUNNING" 0 295 | "RUNNING" 0 296 | "RUNNING" 0 297 | "SUCCESS" 10254 298 | ... 299 | $ ./aws-submitModel -m DR-Local -s AWSDeepRacerCommunityContest3 -c 300 | 301 | ``` 302 | 9. aws-getModel 303 | 304 | The script download a model from AWS as compressed tar file. It requires additional AWS cli. 305 | ``` 306 | ./aws-getModel DR-Local 307 | Completed 16.0 MiB/20.5 MiB (3.6 MiB/s) with 1 file(s) remaining 308 | ``` 309 | 310 | 10. aws-execCurl 311 | 312 | The script is only used inside other scripts, should not run directly. 313 | 314 | ## TODO List 315 | * Code Refactoring and move from shell script to Python. 316 | * Gradually increase the speed in action space and resubmit until the model doesn't get any laps time improvement. 317 | This approach could get the best out of the model without retraining it. 318 | * ~~Re-authenticate automatically after the tokens expire~~ 319 | * Upload automatically the latest model from local training before submission. 320 | --------------------------------------------------------------------------------