ros2与windows入门教程-编译ROS2包
说明:
- 介绍如何在windows系统上编译ROS2包
前提条件:
- 已安装windows 10系统
步骤:
choco upgrade git -y
安装curl
- 下载地址:https://curl.se/download.html
- 在最底部找到Windows的版本,下载的版本是curl-7.83.1_3-win64-mingw
- curl可执行文件的路径为 C:\tools\curl-7.83.1_3-win64-mingw\curl-7.83.1_3-win64-mingw\bin
- 新建系统变量CURL_HOME,内容即curl.exe的所在目录;然后修改系统变量path,在最前部加入%CURL_HOME%;
- 检查环境变量配置是否成功
curl
curl: try 'curl --help' for more information
curl --help
- 安装cmake
choco install -y cmake
CMake bin文件路径C:\Program Files\CMake\bin添加到系统环境的PATH
- 安装python3.8.3
choco install -y python --version 3.8.3
从GitHub存储库下载这些包
asio.1.12.1.nupkg
bullet.2.89.0.nupkg
cunit.2.1.3.nupkg
eigen-3.3.4.nupkg
tinyxml-usestl.2.6.2.nupkg
tinyxml2.6.0.0.nupkg
log4cxx.0.10.0.nupkg
choco install -y -s <PATH\TO\DOWNLOADS\> asio cunit eigen tinyxml-usestl tinyxml2 log4cxx bullet
<PATH\TO\DOWNLOADS>为您将软件包下载到的文件夹
- 安装python依赖
python -m pip install --upgrade pip
python -m pip install -U catkin_pkg cryptography empy ifcfg importlib-metadata lark-parser lxml matplotlib netifaces numpy opencv-python PyQt5 pip pillow psutil pycairo pydot pyparsing pyyaml rosdistro setuptools
- 安装graphviz,以便运行rqt_graph
choco install graphviz
- 安装OpenCV,下载OpenCV 3.4.6 的预编译版本,将其解压缩为C:\opencv,以管理员身份打开命令提示符cmd,运行以下命令
setx /m OpenCV_DIR C:\opencv
将opencv的路径C:\opencv\x64\vc16\bin,添加到系统环境的PATH
- 安装qt5,从Qt网站下载5.12.X offline installer,下载的版本是qt-opensource-windows-x86-5.12.12
先断网,再安装,运行安装程序,选择Qt -> Qt 5.12.12 -> MSVC 2017 64-bit
setx /m Qt5_DIR C:\Qt\Qt5.12.12\5.12.12\msvc2017_64
setx /m QT_PLUGIN_PATH C:\Qt\Qt5.12.12\5.12.12\msvc2017_64\plugins
setx /m QT_QPA_PLATFORM_PLUGIN_PATH C:\Qt\Qt5.12.12\5.12.12\msvc2017_64\plugins\platforms
pip install -U pydot PyQt5
- 安装Visual C++ Redistributables
choco install -y vcredist2013 vcredist140
安装OpenSSL,Win64 OpenSSL v1.1.1o EXE
下载地址:https://slproweb.com/products/Win32OpenSSL.html
安装路径为:C:\Program Files\OpenSSL-Win64\bin
新建系统变量OPENSSL_HOME,内容即openssl.exe的所在目录;然后修改系统变量path,在最前部加入%OPENSSL_HOME%;
创建工作空间
cd c:\
mkdir c:\nav2_ws\src
- 下载Robotis Turtlebot3 Navigation2 源
call C:\opt\ros\foxy\x64\local_setup.bat
pushd c:\nav2_ws
curl -o nav2.repos https://raw.githubusercontent.com/ms-iot/ROSOnWindows/master/docs/ros2/navigation2_foxy.repos
git config --global http.sslVerify "false"
vcs import src < nav2.repos
- 编译nav2_ws工作空间,新建一个cmd命令提示符,运行以下命令
pushd C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\
call vcvars64.bat
pushd c:\nav2_ws
call C:\opt\ros\foxy\x64\local_setup.bat
call c:\opt\ros\foxy\x64\share\gazebo\setup.bat
set "SDF_PATH=c:\opt\ros\foxy\x64\share\sdformat\1.6"
colcon build
- 需要单独编译turtlebot3_gazebo包
colcon build --packages-select turtlebot3_gazebo --cmake-args "-Wno-dev"
获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号