-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_f1tenth.ps1
More file actions
70 lines (59 loc) · 2.23 KB
/
start_f1tenth.ps1
File metadata and controls
70 lines (59 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
param(
[int]$NumSessions = 3,
[int]$MaxLaps = 3
)
$imageName = "f1tenth_gym_ros"
$repoRoot = (Get-Location).Path
$resultsRoot = Join-Path $repoRoot "results"
Write-Host "[1/4] Creating results root..."
New-Item -ItemType Directory -Force -Path $resultsRoot | Out-Null
Write-Host "[2/4] Building Docker image..."
docker build -t $imageName .
Write-Host "[3/4] Removing old session containers if they exist..."
# combine with loop below
docker rm -f $(docker ps -aq --filter "name=f1tenth_session_") 2>$null
Write-Host "[4/4] Launching $NumSessions parallel simulation containers..."
for ($i = 1; $i -le $NumSessions; $i++) {
$containerName = "f1tenth_session_$i"
$novncName = "novnc_session_$i"
$vncPort = 8080 + $i
$sessionResults = Join-Path $resultsRoot "session_$i"
New-Item -ItemType Directory -Force -Path $sessionResults | Out-Null
Write-Host "Starting Session $i..."
# remove old containers
docker rm -f $novncName 2>$null | Out-Null
docker rm -f $containerName 2>$null | Out-Null
# launch no vnc with the according port address for the session id#
docker run -d `
--name $novncName `
-p "${vncPort}:8080" `
theasp/novnc:latest
# launch the sim
# get unique identifiers and domains for each
$rosDomainId = $i
$containerCmd = "/sim_ws/src/f1tenth_gym_ros/auto_run_sim.sh"
docker run -d `
--name $containerName `
--link "${novncName}:novnc" `
-e DISPLAY=novnc:0.0 `
-e SESSION_ID=$i `
-e ROS_DOMAIN_ID=$rosDomainId `
-e MAX_LAPS=$MaxLaps `
-e RESULTS_DIR="/sim_ws/results/session_$i" `
-e ATTACH_TMUX=0 `
-v "${repoRoot}:/sim_ws/src/f1tenth_gym_ros" `
-v "${sessionResults}:/sim_ws/results/session_$i" `
$imageName `
$containerCmd
}
Write-Host ""
Write-Host "All sessions launched."
Write-Host "Check running containers with:"
Write-Host " docker ps"
Write-Host ""
Write-Host "Check logs with:"
Write-Host " docker logs -f f1tenth_session_1"
Write-Host " docker logs -f f1tenth_session_2"
Write-Host " docker logs -f f1tenth_session_3"
Write-Host ""
Write-Host "Dashboard to view sessions: file://$($repoRoot.Replace('\', '/'))/dashboard.html" -ForegroundColor Cyan