-
Notifications
You must be signed in to change notification settings - Fork 8
/
ros2_humble.ps1
292 lines (260 loc) · 13 KB
/
ros2_humble.ps1
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
# Get Installer and import global functions
iex ((New-Object System.Net.WebClient).DownloadString('https://github.com/scottcandy34/ros2_windows_install/raw/main/installer.ps1'))
# Set version
$Version = "humble"
$Version_Title = "Humble"
function Standard-Install {
# Set Custom Chocolatey location
$env:ChocolateyInstall = "C:\dev\chocolatey"
$env:Path = "C:\dev\chocolatey\bin;" + $env:Path
# Install Python
Install-Python
$PythonPath = Python-Path
# Install Visual C++ Redistributables
choco install -y vcredist2013 vcredist140
# Install OpenSSL
choco install -y openssl
# Install Visual Studio Community
$CONFIG = '{
"version": "1.0",
"components": [
"Microsoft.VisualStudio.Component.CoreEditor",
"Microsoft.VisualStudio.Workload.CoreEditor",
"Microsoft.VisualStudio.Component.NuGet",
"Microsoft.VisualStudio.Component.Roslyn.Compiler",
"Microsoft.VisualStudio.Component.Roslyn.LanguageServices",
"Microsoft.VisualStudio.ComponentGroup.WebToolsExtensions",
"Microsoft.VisualStudio.Component.TypeScript.4.3",
"Microsoft.VisualStudio.Component.JavaScript.TypeScript",
"Microsoft.Component.MSBuild",
"Microsoft.VisualStudio.Component.TextTemplating",
"Microsoft.VisualStudio.Component.Debugger.JustInTime",
"Component.Microsoft.VisualStudio.LiveShare",
"Microsoft.VisualStudio.Component.IntelliCode",
"Microsoft.VisualStudio.Component.VC.CoreIde",
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
"Microsoft.VisualStudio.Component.Graphics.Tools",
"Microsoft.VisualStudio.Component.VC.DiagnosticTools",
"Microsoft.VisualStudio.Component.Windows10SDK.19041",
"Microsoft.VisualStudio.Component.VC.Redist.14.Latest",
"Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Core",
"Microsoft.VisualStudio.Component.VC.ATL",
"Microsoft.VisualStudio.Component.VC.TestAdapterForBoostTest",
"Microsoft.VisualStudio.Component.VC.TestAdapterForGoogleTest",
"Microsoft.VisualStudio.Component.VC.ASAN",
"Microsoft.VisualStudio.Workload.NativeDesktop"
]
}'
Set-Content -Path ($DownloadDir + "\vs_2019_ros2.vsconfig") -Value $CONFIG
if (Test-Path -Path "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community") {
Start-Process -FilePath 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installershell.exe' -ArgumentList ("modify --passive --norestart --force --installpath 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community' --config " + $DownloadDir + "\vs_2019_ros2.vsconfig --remove Microsoft.VisualStudio.ComponentGroup.WebToolsExtensions.CMake --remove Microsoft.VisualStudio.Component.VC.CMake.Project")
} else {
choco install -y visualstudio2019community --package-parameters ("--passive --config " + $DownloadDir + "\vs_2019_ros2.vsconfig")
}
# Install OpenCV
$URL = “https://github.com/ros2/ros2/releases/download/opencv-archives/opencv-3.4.6-vc16.VS2019.zip”
$FILE = ”opencv-3.4.6-vc16.VS2019.zip”
$OPENCV_DIR = "C:\"
Download-File -Uri $URL -OutFile $FILE
Extract-File -File $FILE -Dir $OPENCV_DIR -Folder "\opencv"
Set-Env -Name "OpenCV_DIR" -Value ($OPENCV_DIR + "opencv")
Set-Path -NewPath "C:\opencv\x64\vc16\bin"
# Install CMake
choco install -y cmake
Set-Path -NewPath "C:\Program Files\CMake\bin"
# Install Dependencies
$baseUri = 'https://github.com/ros2/choco-packages/releases/download/2022-03-15'
$files = @(
@{
Uri = "$baseUri/asio.1.12.1.nupkg"
OutFile = 'asio.1.12.1.nupkg'
},
@{
Uri = "$baseUri/bullet.3.17.nupkg"
OutFile = 'bullet.3.17.nupkg'
},
@{
Uri = "$baseUri/cunit.2.1.3.nupkg"
OutFile = 'cunit.2.1.3.nupkg'
},
@{
Uri = "$baseUri/eigen.3.3.4.nupkg"
OutFile = 'eigen.3.3.4.nupkg'
},
@{
Uri = "$baseUri/tinyxml-usestl.2.6.2.nupkg"
OutFile = 'tinyxml-usestl.2.6.2.nupkg'
},
@{
Uri = "$baseUri/tinyxml2.6.0.0.nupkg"
OutFile = 'tinyxml2.6.0.0.nupkg'
}
)
foreach ($file in $files) {
Download-File @file
}
choco install -y -s $DownloadDir asio cunit eigen tinyxml-usestl tinyxml2 bullet
py -3.8 -m pip install -U pip setuptools==59.6.0
py -3.8 -m pip install -U catkin_pkg cryptography empy importlib-metadata lark==1.1.1 lxml matplotlib netifaces numpy opencv-python PyQt5 pillow psutil pycairo pydot pyparsing==2.4.7 pyyaml rosdistro
py -3.8 -m pip install -U colcon-common-extensions
# Install Qt5
choco install -y aqt qtcreator
if (-not(Test-Path -Path "C:\Qt\5.12.12\msvc2017_64")) {
aqt install-qt --outputdir C:\Qt windows desktop 5.12.12 win64_msvc2017_64 --modules debug_info
}
Set-Env -Name "Qt5_DIR" -Value "C:\Qt\5.12.12\msvc2017_64"
Set-Env -Name "QT_QPA_PLATFORM_PLUGIN_PATH" -Value "C:\Qt\5.12.12\msvc2017_64\plugins\platforms"
# Install RQt Dependencies
choco install -y graphviz
Set-Path -NewPath "C:\Program Files\Graphviz\bin"
# Install ROS2
$release = Get-Release -Search $Version
if ($release -eq $null) {
Write-Output "Error getting release information"
pause
exit
}
$ROS_DIR = "C:\dev"
Download-File -Uri $release.url -OutFile $release.file -Folder "\ros2-windows"
Extract-File -File $release.file -Dir $ROS_DIR -Folder "\ros2-windows"
if (Test-Path -Path "$ROS_DIR\ros2_$Version") {
Uninstall -Path "$ROS_DIR\ros2_$Version" -Title "ROS2 $Version_Title for Update"
}
Rename-Item -NewName "ros2_$Version" -Path "$ROS_DIR\ros2-windows" -Force
# Create Startup Script
Create-Start-File -Dir "$ROS_DIR\ros2_$Version"
Startup-Add -Content "`$env:RMW_IMPLEMENTATION = `"rmw_fastrtps_cpp`"" -Dir "$ROS_DIR\ros2_$Version"
Startup-Add -Content "`$env:COLCON_PYTHON_EXECUTABLE = `"$PythonPath`"" -Dir "$ROS_DIR\ros2_$Version"
$_python_env = $PythonPath.Replace("python.exe", "Scripts\;") + $PythonPath.Replace("python.exe", ";")
Startup-Add -Content "`$env:Path = `"$_python_env`" + `$env:Path" -Dir "$ROS_DIR\ros2_$Version"
Add_Links -Path "$ROS_DIR\ros2_$Version"
}
function Alternate-Install {
# Install Visual Studio Community
$CONFIG = '{
"version": "1.0",
"components": [
"Microsoft.VisualStudio.Component.CoreEditor",
"Microsoft.VisualStudio.Workload.CoreEditor",
"Microsoft.VisualStudio.Component.NuGet",
"Microsoft.VisualStudio.Component.Roslyn.Compiler",
"Microsoft.VisualStudio.Component.Roslyn.LanguageServices",
"Microsoft.VisualStudio.ComponentGroup.WebToolsExtensions",
"Microsoft.VisualStudio.Component.TypeScript.4.3",
"Microsoft.VisualStudio.Component.JavaScript.TypeScript",
"Microsoft.Component.MSBuild",
"Microsoft.VisualStudio.Component.TextTemplating",
"Microsoft.VisualStudio.Component.Debugger.JustInTime",
"Component.Microsoft.VisualStudio.LiveShare",
"Microsoft.VisualStudio.Component.IntelliCode",
"Microsoft.VisualStudio.Component.VC.CoreIde",
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
"Microsoft.VisualStudio.Component.Graphics.Tools",
"Microsoft.VisualStudio.Component.VC.DiagnosticTools",
"Microsoft.VisualStudio.Component.Windows10SDK.19041",
"Microsoft.VisualStudio.Component.VC.Redist.14.Latest",
"Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Core",
"Microsoft.VisualStudio.Component.VC.ATL",
"Microsoft.VisualStudio.Component.VC.TestAdapterForBoostTest",
"Microsoft.VisualStudio.Component.VC.TestAdapterForGoogleTest",
"Microsoft.VisualStudio.Component.VC.ASAN",
"Microsoft.VisualStudio.Workload.NativeDesktop",
"Microsoft.VisualStudio.ComponentGroup.WebToolsExtensions.CMake",
"Microsoft.VisualStudio.Component.VC.CMake.Project"
]
}'
Set-Content -Path ($DownloadDir + "\vs_2019_ros2.vsconfig") -Value $CONFIG
if (Test-Path -Path "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community") {
Start-Process -FilePath 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installershell.exe' -ArgumentList ("modify --passive --norestart --force --installpath 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community' --config " + $DownloadDir + "\vs_2019_ros2.vsconfig")
} else {
choco install -y visualstudio2019community --package-parameters ("--passive --config " + $DownloadDir + "\vs_2019_ros2.vsconfig")
}
# Install Git
choco upgrade git -y
# Install ROS
$env:ChocolateyInstall = "c:\opt\chocolatey"
choco source add -n=ros-win -s="https://aka.ms/ros/public" --priority=1
choco upgrade ros-humble-desktop -y --execution-timeout=0 -pre
Add_Links -Path "C:\opt\ros\$Version\x64\"
}
function Uninstall-Ros {
# Uninstall ROS2 Standard
$ROS_DIR = "C:\dev"
if (Test-Path -Path $ROS_DIR) {
$ROS_DIR_INSTALL = "$ROS_DIR\ros2_$Version"
$ROS_START = "$ROS_DIR_INSTALL\start.ps1"
if (-not(Test-Path -Path ($ROS_START) -PathType Leaf)) {
$ROS_START = "$ROS_DIR_INSTALL\local_setup.ps1"
}
if (Test-Path -Path $ROS_DIR_INSTALL) {
Uninstall -Path $ROS_DIR_INSTALL -Title "ROS2 $Version_Title Standard"
}
$ROS_INSTALL_COUNT = (Get-ChildItem -Directory -Path $ROS_DIR | Measure-Object).Count
if ($ROS_INSTALL_COUNT -eq 0) {
Remove-Item -Path $ROS_DIR
}
}
# Uninstall ROS2 Alternate Build
if (Test-Path -Path "C:\opt") {
$ROS_START = "C:\opt\ros\$Version\x64\local_setup.ps1"
$env:ChocolateyInstall = "c:\opt\chocolatey"
choco uninstall -y ros-humble-desktop --skipautouninstaller
Uninstall -Path "C:\opt\ros\$Version" -Title "ROS2 $Version_Title Alternate Build"
$ROS_INSTALL_COUNT = (Get-ChildItem -Directory -Path $ROS_DIR | Measure-Object).Count
if ($ROS_INSTALL_COUNT -eq 0) {
Remove-Item -Path "C:\opt" -Recurse -Force
}
$REG_KEY = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\{b78a5b27-3d5b-4c7c-b424-10c1fe73c352}_is1"
if (Test-Path -Path $REG_KEY -PathType Leaf) {
Remove-Item -Path $REG_KEY -Force -Verbose
}
}
# Removing Links
$Documents = ([Environment]::GetFolderPath("MyDocuments") + "\WindowsPowerShell")
$ProfileFile = "$Documents\Microsoft.PowerShell_profile.ps1"
if ((Test-Path -Path $ProfileFile -PathType Leaf) -and $ROS_START -ne $null) {
$SEL = Select-String -Path $ProfileFile -Pattern $ROS_START -SimpleMatch
if ($SEL -ne $null)
{
$REMOVED_LINK = Get-Content $ProfileFile | Where-Object {$_ -notlike $ROS_START}
Set-Content $ProfileFile -Value $REMOVED_LINK -Force
}
}
$Link = ([Environment]::GetFolderPath("Desktop") + "\ROS2 $Version_Title Terminal.lnk")
if (Test-Path -Path $Link -PathType Leaf) {
Remove-Item -Path $Link
}
}
function Uninstall-Dep {
# Set Custom Chocolatey location
$env:ChocolateyInstall = "C:\dev\chocolatey"
$env:Path = "C:\dev\chocolatey\bin;" + $env:Path
# Uninstall python packages
py -3.8 -m pip uninstall -y catkin_pkg cryptography empy importlib-metadata lark==1.1.1 lxml matplotlib netifaces numpy opencv-python PyQt5 pillow psutil pycairo pydot pyparsing==2.4.7 pyyaml rosdistro
py -3.8 -m pip uninstall -y pip setuptools==59.6.0
py -3.8 -m pip uninstall -Y colcon-common-extensions
# Uninstall Chocolaty packages
ECHO Y | choco uninstall -y graphviz -n
choco uninstall -y aqt qtcreator
choco uninstall -y asio cunit eigen tinyxml-usestl tinyxml2 bullet
ECHO Y | choco uninstall -y cmake
choco uninstall -y visualstudio2019community
choco uninstall -y openssl
choco uninstall -y vcredist2013 vcredist140
choco uninstall -y python --version 3.8.3 python3 --version 3.8.3
# Uninstall Others
Uninstall -Path "C:\Qt" -Title "Qt5"
Uninstall -Path "C:\opencv" -Title "Qt5"
Uninstall -Path "C:\Python38" -Title "Python Leftovers"
# Remove Environment variables
Set-Env -Name "Qt5_DIR" -Value ""
Set-Env -Name "QT_QPA_PLATFORM_PLUGIN_PATH" -Value ""
Set-Env -Name "OpenCV_DIR" -Value ""
Remove-Path -RemovePath "C:\opencv\x64\vc16\bin"
Remove-Path -RemovePath "C:\Program Files\CMake\bin"
Remove-Path -RemovePath "C:\Program Files\Graphviz\bin"
Remove-Path -RemovePath "C:\Program Files\OpenSSL-Win64\bin"
Remove-Path -RemovePath "C:\Python38\"
Remove-Path -RemovePath "C:\Python38\Scripts\"
}
Start-Installer