ROS2安装
一、Win11(PowerShell与Cmd搭配)
忒麻烦了,毛病还多
官方DOC
1.1 安装 Chocolatey
是Windows平台上的包管理器,通过它可以集中安装、管理、更新各种各样的软件。
是和apt-get,brew差不都的一个东西。
在PowerShell(管理员)中输入:
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
测试是否安装成功:
choco –version
1.2 安装 Python 3.8.3
choco install -y python --version 3.8.3
1.3 安装 Visual C++ Redistributables
choco install -y vcredist2013 vcredist140
1.4 安装 Win64 OpenSSL v1.1.1
这里安装 Win64 OpenSSL v1.1.1,傻瓜式一路向北。
配置环境变量:
(1)先在cmd中:
setx /m OPENSSL_CONF "C:\Program Files\OpenSSL-Win64\bin\openssl.cfg"
(2)然后手动添加至PATH:
C:\Program Files\OpenSSL-Win64\bin\
1.5 安装 VS2022
安装C++部分
1.6 安装 OpenCV 3.4.6
这里安装 OpenCV 3.4.6
配置环境变量:
(1)先在cmd中:
setx /m OpenCV_DIR 路径\opencv"
(2)然后手动添加至PATH:
路径\opencv\x64\vc16\bin
1.7 安装依赖
1.7.1 cmake
choco install -y cmake
1.7.2 dependencies
将dependencies全部包下载安装到ROS2\dependencies路径后,
choco install -y -s C:\Users\11814\Software\ROS2\dependencies\ asio cunit eigen tinyxml-usestl tinyxm2 bullet
python -m pip install -U pip setuptools==59.6.0
python -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
1.8 安装 Qt5
在这里下载Qt5,选择5.12.x Offline Installers下的Qt 5.12.12 for Windows。
安装过程中在select components 这一步选择
Qt:MSVC 2017 64-bit
Developer and Designer Tools:Qt Creator与MinGW 7.3.0 64-bit
安装完成后配置环境变量:
配置环境变量:
在cmd中:
setx /m Qt5_DIR 路径\5.12.12\msvc2017_64
setx /m QT_QPA_PLATFORM_PLUGIN_PATH 路径\5.12.12\msvc2017_64\plugins\platforms
1.9 安装 ROS2
在这里获取
解压后在cmd
call ROS路径\local_setup.bat
测试小海龟
ros2 run turtlesim turtlesim_node
如果报错'package'module没找到,则需要配置ROS2的环境:
- 新建指令文件
C:\Users\你的名字\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
内容:
路径\humble\local_setup.ps1
Unblock-File 路径\humble\local_setup.ps1
2. 在搜索栏中搜索windows PowerShell ISE
输入:
set-ExecutionPolicy RemoteSigned
1.10 安装Colcon
pip install -U colcon-common-extensions
二、遇到过的一些问题
1.1
C:\Users\11814\WorkSpace\Proj\ROS\Test>colcon build --merge-install --packages-select interfaces_test
WARNING: Package name "4test" does not follow the naming conventions. It should start with a lower case letter and only contain lower case letters, digits, underscores, and dashes.
Starting >>> interfaces_test
--- stderr: interfaces_test
CMake Warning (dev) at C:/Users/11814/Software/ROS2/humble/share/rosidl_generator_py/cmake/rosidl_generator_py_generate_interfaces.cmake:20 (find_package):
Policy CMP0148 is not set: The FindPythonInterp and FindPythonLibs modules
are removed. Run "cmake --help-policy CMP0148" for policy details. Use
the cmake_policy command to set the policy and suppress this warning.
Call Stack (most recent call first):
C:/Users/11814/Software/ROS2/humble/share/ament_cmake_core/cmake/core/ament_execute_extensions.cmake:48 (include)
C:/Users/11814/Software/ROS2/humble/share/rosidl_cmake/cmake/rosidl_generate_interfaces.cmake:286 (ament_execute_extensions)
CMakeLists.txt:15 (rosidl_generate_interfaces)
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Warning (dev) at C:/Users/11814/Software/ROS2/humble/share/python_cmake_module/cmake/Modules/FindPythonExtra.cmake:52 (find_package):
Policy CMP0148 is not set: The FindPythonInterp and FindPythonLibs modules
are removed. Run "cmake --help-policy CMP0148" for policy details. Use
the cmake_policy command to set the policy and suppress this warning.
Call Stack (most recent call first):
C:/Users/11814/Software/ROS2/humble/share/rosidl_generator_py/cmake/rosidl_generator_py_generate_interfaces.cmake:23 (find_package)
C:/Users/11814/Software/ROS2/humble/share/ament_cmake_core/cmake/core/ament_execute_extensions.cmake:48 (include)
C:/Users/11814/Software/ROS2/humble/share/rosidl_cmake/cmake/rosidl_generate_interfaces.cmake:286 (ament_execute_extensions)
CMakeLists.txt:15 (rosidl_generate_interfaces)
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Warning (dev) at C:/Users/11814/Software/ROS2/humble/share/python_cmake_module/cmake/Modules/FindPythonExtra.cmake:140 (find_package):
Policy CMP0148 is not set: The FindPythonInterp and FindPythonLibs modules
are removed. Run "cmake --help-policy CMP0148" for policy details. Use
the cmake_policy command to set the policy and suppress this warning.
Call Stack (most recent call first):
C:/Users/11814/Software/ROS2/humble/share/rosidl_generator_py/cmake/rosidl_generator_py_generate_interfaces.cmake:23 (find_package)
C:/Users/11814/Software/ROS2/humble/share/ament_cmake_core/cmake/core/ament_execute_extensions.cmake:48 (include)
C:/Users/11814/Software/ROS2/humble/share/rosidl_cmake/cmake/rosidl_generate_interfaces.cmake:286 (ament_execute_extensions)
CMakeLists.txt:15 (rosidl_generate_interfaces)
This warning is for project developers. Use -Wno-dev to suppress it.
---
Failed <<< interfaces_test [5.92s, exited with code 1]
Summary: 0 packages finished [6.30s]
1 package failed: interfaces_test
1 package had stderr output: interfaces_test
WNDPROC return value cannot be converted to LRESULT
TypeError: WPARAM is simple, so must be an int object (got NoneType)
1.2
CMake Error at CMakeLists.txt:10 (find_package):
By not providing "Findrosidl_default_generators.cmake" in CMAKE_MODULE_PATH
this project has asked CMake to find a package configuration file provided
by "rosidl_default_generators", but CMake did not find one.
Could not find a package configuration file provided by
"rosidl_default_generators" with any of the following names:
rosidl_default_generatorsConfig.cmake
rosidl_default_generators-config.cmake
Add the installation prefix of "rosidl_default_generators" to
CMAKE_PREFIX_PATH or set "rosidl_default_generators_DIR" to a directory
containing one of the above files. If "rosidl_default_generators" provides
a separate development package or SDK, be sure it has been installed.
原因,
忘记导入启动信息
解决办法,source ros2根目录下的setup脚本
call C:\opt\ros\galactic\x64\setup.bat

浙公网安备 33010602011771号