在Windows10上安装ROS并测试

在Windows10上安装ROS并测试

前言:
有时开发一个东西,必须在公司的Ubuntu服务器开发,是很不方便的。近来开发ROS-SLAM机器人,为了在笔记本win10也能进行,特意安装了Win10版本的ROS。为此做一个笔录以保存记忆。

1 Windows操作系统版本要求
(1)、ROS-for-Windows需要64位Windows 10桌面或Windows 10物联网企业版。
(2)、请确保已在系统路径中安装Powershell。
(3)、从实时病毒扫描程序中排除c:\opt(以及稍后的工作区文件夹),因为它们可能会干扰安装和开发。

2 为安装预留空间
(1)继续之前,请清理并备份c:\opt下的所有现有数据。
(2)c:\opt是所需的安装位置。当前未启用重新定位。
(3)请确保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=0

5.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=0

6 生成 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.

 "profiles" :
    {
        list: 
        [
            ...
            {
                "commandline" : "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",
                "guid" : "{xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxxxx}",
                "icon" : "ms-appx:///ProfileIcons/{0caa0dad-35be-5f56-a8ff-afceeeaa6101}.png",
                "name" : "ROS Noetic",
                "startingDirectory" : "c:\\ws"
        },

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”

 "alwaysShowTabs" : true,
        "copyOnSelect" : false,
        "defaultProfile" : "{xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxxxx}",
        ....

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

  • 1
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值