在Windows10上安装ROS并测试
前言:
有時開發一個東西,必須在公司的Ubuntu服務器開發,是很不方便的。近來開發ROS-SLAM機器人,為了在筆記本win10也能進行,特意安裝了Win10版本的ROS。為此做一個筆錄以保存記憶。
1 Windows操作系統版本要求
- ROS-for-Windows需要64位Windows 10桌面或Windows 10物聯網企業版。
- 請確保已在系統路徑中安裝Powershell。
- 從實時病毒掃描程序中排除c:\opt(以及稍后的工作區文件夾),因為它們可能會干擾安裝和開發。
2 為安裝預留空間
- 繼續之前,請清理并備份c:\opt下的所有現有數據。
- c:\opt是所需的安裝位置。當前未啟用重新定位。
- 請確保C:\驅動器上有10 GB的可用空間用于安裝和開發。
3 安裝Visual Studio 2019
(安裝VC2019帖子很多,在網上找找吧)
- Vcpkg is used for managing dependent libraries. It requires that the English language pack be installed.
- Include "Desktop development with C++" workload.
- In the Individual Components, select "Windows 10 SDK (10.0.19041.0)".
注意:安裝完VC2019后,有一個VC版本的命令行工具很重要,如圖:
?凡進行64位的軟件操作,都需要打開此命令行進行。
??
4 “巧克力”-Chocolatey安裝
4.1 首先安裝一個chocolatey,它類同于apt-get
- 在開始菜單中,找到“VS 2019的x64本機工具命令提示符”項。
- 右鍵單擊,選擇“更多”,然后選擇“以管理員身份運行”
- ?復制以下命令行:
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
- 將其粘貼到命令窗口中。
- ?批準任何提示
- 完成后,關閉命令提示符以完成
5 安裝Git
- 如上所述,重新打開Visual Studio命令窗口。
- 請使用此處的命令安裝Git,即使您已將其作為應用程序安裝。
choco upgrade git -y
安裝Git后,確保Git現在在VisualStudio命令窗口中可用
git --version- 如上所述,關閉并重新打開Visual Studio命令窗口.
5 ROS軟件包安裝
推薦安裝步驟:
?5.1 ROS Last Known Good (LKG) 安裝Noetic版本
要開始工作,請安裝推薦的桌面完整元軟件包。元包是其他包的集合。桌面完整元包是指構建、運行、調試和可視化機器人所需的許多其他包。
如上所述,重新打開Visual Studio命令窗口
mkdir c:\opt\chocolatey set ChocolateyInstall=c:\opt\chocolatey choco source add -n=ros-win -s="https://aka.ms/ros/public" --priority=1 choco upgrade ros-noetic-desktop_full -y --execution-timeout=05.2 ROS 2 安裝
要開始使用ROS2,還可以按照類似的步驟從相同的巧克力源安裝ROS2。
例如,如果要安裝ROS2 Foxy build,請打開上面創建的ROS命令提示符,如果尚未打開,請批準管理提升。
mkdir c:\opt\chocolatey set ChocolateyInstall=c:\opt\chocolatey choco source add -n=ros-win -s="https://aka.ms/ros/public" --priority=1 choco upgrade ros-foxy-desktop -y --execution-timeout=06 生成ROS命令行的快捷
為了在Windows上使用ROS,需要在每個命令窗口中調用ROS設置腳本。為了避免將來忘記,有一個ROS快捷方式可以自動完成這項工作,這是很有幫助的。
1 創建快捷方式(管理員登錄的-具有Visual-Studio-64位)
? ? 1)在桌面右鍵后-建立快捷方式彈出
? ? 2 )在此空格上添加路徑:
? ? 使用VC-Community版本的,添加:
C:\Windows\System32\cmd.exe /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\VsDevCmd.bat" -arch=amd64 -host_arch=amd64&& set ChocolateyInstall=c:\opt\chocolatey&& c:\opt\ros\noetic\x64\setup.bat
? ?使用VC-Professional版本的,添加:
?C:\Windows\System32\cmd.exe /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\Tools\VsDevCmd.bat" -arch=amd64 -host_arch=amd64&& set ChocolateyInstall=c:\opt\chocolatey&& c:\opt\ros\noetic\x64\setup.bat
?使用VC-Enterprisel版本的,添加:
C:\Windows\System32\cmd.exe /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\VsDevCmd.bat" -arch=amd64 -host_arch=amd64&& set ChocolateyInstall=c:\opt\chocolatey&& c:\opt\ros\noetic\x64\setup.bat
7 設定快捷的管理員模式
- Set that shortcut as Administrator
- 對于桌面的ROS右鍵進入
- 選中快捷方式Tab
- 選中高級buttom
- 勾選“用管理員身份進入”
- 選“確定”buttom設定成功
?8 測試所ROS的安裝
打開桌面命令行輸入:
roscore
再打開一個命令行輸入:
rosrun turtlesim turtlesim_node
顯示圖片:
?再次打開命令行:
rosrun turtlesim turtle_teleop_key.exe
9 采用windows新的終端(Using the new Windows Terminal)
(不用也行,僅供參考)
Microsoft released a new open source terminal for Windows, which includes many improvements over the built in command line, including tabs and appearance customization. You can install it from the Microsoft Store.
To set up the terminal for ROS:
- Find the Windows Terminal from the start menu, right click and select 'Run as Administrator'
- Select settings from the drop down arrow next to the Add Tab (+) Button.
- In the list array in the "profiles" object, add a new block for ROS.
-
from a Visual Studio command window, use the command uuidgen to generate a globally unique identifier (aka universally unique identifier).
- copy the guid (select the text, then right click to copy)
- Replace xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxxxx with the text copied above.
- (Optionally) Set this guid as the "defaultProfile"
When launching the new Windows terminal, please remember to Run as Administrator, by right clicking on the Windows Terminal and Select *Run as Administrator*. There is a Always Run Terminal elevated feature request that needs to be implemented before this requirement is lifted.
Alternatively, Ctrl+Shift+clicking on the terminal icon in either the start menu or task bar is a handy shortcut to run as administrator.
10 更新到最新版本(Stay Up to Date)
如果您想更新您的ROS安裝,可以使用Chocolate進行升級。
打開上面創建的快捷,并用管理員身份進入。
運行以下命令:
set ChocolateyInstall=c:\opt\chocolatey choco upgrade all -y --execution-timeout=0建議添加--execution timeout=0,以適應由于網絡速度較慢而導致的巧克力安裝失敗。
11 卸載ROS
1.卸載所有ROS版本
1)卸載全部ros:
sudo apt-get autoremove --purge ros-*
2)卸載某個ros版本(ros版本可以共存,每次需要切換)
如indigo:
sudo apt-get autoremove --purge ros-indigo
3)或者先卸載包
sudo apt-get purge ros-*
然后刪除依賴,配置
sudo apt-get autoremove
2 檢查ros文件夾是否卸載掉
進入到~/.bashrc 以及/opt/目錄,查看是否有ros文件夾存在,如果無,則卸載成功。
至此全部內容介紹完畢!
下載VSCODE-IDE開發環境。
https://code.visualstudio.com
參考文章:
Windows系統下安裝ROS系統_尋找靈魂的機器狗的博客-CSDN博客
總結
以上是生活随笔為你收集整理的在Windows10上安装ROS并测试的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 深入理解ROS技术 【2】ROS下的模块
- 下一篇: ROS学习:创建机器人的urdf