本机配置
win10,1903,安装ros1,最新的是melodic。
安装过程
参考官方安装指南,出现一些错误,比如总是说vcpkg没有安装,再参考github上的issue,其中提供了一些解决办法。
Version is Win 10 Pro 1809 (Build 17763.1098).
shortcut: well … I was stuck at section 5.1 in the installation manual, and that hint to the cmd is in section 6, I just did not continue reading the manual 😄
After all, I figured it out. I completely removed the c:\opt and the c:\ProgramData\chocolately folders to get rid of the crappy installations before. I restarted all steps from section 4, but I used a cmd with the “bypass” option.
Might be a good idea to adapt the manual http://wiki.ros.org/Installation/Windows :
Move section 6 inbetween 3 and 4 and modify it slightly: I removed the last statement (&& c:\opt\ros\melodic\x64\setup.bat), because I did not want the setup.bat to be executed in the steps 4 and 5 already, I just wanted the console with the bypass which worked fine (maybe it would not harm to have setup.bat here already, I do no know). I used that modified cmd for steps in section 4 and 5 and when I reached section 6, I added the “…\setup.bat” part to the link.
Honestly, I do not know why there is a difference between setting “set ChocolateyInstall=…” in the link instead of calling it in the console itself, but on my system that made the difference. Maybe that is a Windows secret 😃
You could add the workaround for vcpkg to section 5.1 (and probably 5.2), so people do no longer need to search this thread. At least it does not harm I think, although it might not be necessary in all cases:
choco upgrade ros-vcpkg -y --execution-timeout=0
It might also be good to add the hint with regard to Powershell path issues that I had. Users should check their User Path variables and add “%SYSTEMROOT%\System32\WindowsPowerShell\v1.0” if it does not exist. That solved my build issues with regard to vcpkg.
That’s it for me …
Chocolatey upgraded 10/10 packages.
See the log for details (c:\opt\chocolatey\logs\chocolatey.log).
Done 😄
经验总结
把上面的话翻译过来就是,在安装好visual studio之后,(visual studio 2019还要装上英语包,就是在visual studio installer里面修改一下,没有英语包,后面的vcpkg装sdl2就会出错,真的很无奈)可以创建一个快捷方式,在执行路径里面填
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
然后设置为管理员权限启动,确定保存之后,再运行,再进行后续的安装命令。这个执行路径在ros全部安装好之后,还要改的,还要在后面增加
&& c:\opt\ros\melodic\x64\setup.bat。
(vcpkg安装的时候,要先cd到vcpkg.exe所在的目录,然后用vcpkg.exe去安装某某软件,比如
vcpkg.exe install sdl2 --triplet x64-windows
建议后面的安装过程,全部在ladder下进行,否则由于国内网不好,dns转发太多次,最后会经常出现readtimeout这样的错误,非常的烦恼。
不知道chocolatey为什么没有国内源,真的很无语,国外的太慢了。官方源对中国非常不友好。而下载的ros的源也没有国内的,清华的tuna只有ubuntu的ros,没有windows10下的,到这里,真的感叹,做开发不要在windows10下面做,还是滚回ubuntu吧,win10真的只能用来娱乐。
整个安装过程,会多次失败,不断的重复尝试吧,大概率都是网络的原因。
ros-vcpkg这个包建议单独用choco安装。
整个过程会有许多安装失败了的,后续可以用choco命令单独装一下,(逐个安装,但是不明白为什么chocolatey装的软件会自动解压到rosdep中去?很奇怪,难道是当前命令行的环境的原因吗?)然后再重新装ros-melodic-desktop_full。
安装好后,更改前面创建的快捷方式。然后用roscore测试安装是否成功。
说实话,虽然我写完了,但是我直到现在还没装好,已经折腾了两天了。开发还是用ubuntu吧,win10真的搞不定。
整个安装过程大致是:先装python27相关的包,然后装rosdep里面的包,间隔还会装一些python的包,总的来说,包还是相当多的,要有耐心装下去,我装了两天,今天下午终于装好了,玩了一会儿小乌龟,不过也很没劲。装好了的感觉,还是很爽的,不管怎么样,都是能搞定的,对么!
如何使用vscode进行ros开发?
继续发扬折腾的精神!
在win10下,如何实现在vscode中进行ros开发?首先在vscode中装好插件:ROS,然后打开前面设置好的快捷方式终端,在终端里输入
code <你的catkin workspace>
workspace里面的文件组织参考这里。
此时,vscode所运行的环境中就有ros了,就可以参考这里的命令,按ctrl+shift+P,然后键入相关命令,比如设置
ros.updateCppProperties
它用来Update the C++ include path to include ROS,然后你就可以愉快的开发ROS了。
references
https://github.com/microsoft/vcpkg/issues/6617
https://zhuanlan.zhihu.com/p/101971604
https://github.com/ms-iot/ROSOnWindows/issues/203
https://zhuanlan.zhihu.com/p/26007106
https://github.com/ms-iot/ROSOnWindows/issues/203