这几天试了WINDOWS10搭建ROS2,废了好几天,卡在COLCON那里,没办法,网上搜不到解决办法。只能换了MAC,差点也卡住。

按ROS2的mac教程操作:https://index.ros.org/doc/ros2/Installation/Foxy/macOS-Install-Binary/
如果最后在运行ros2 run demo_nodes_py listener时出现:
”Fatal Python error: _PyInterpreterState_Get(): no current thread state
Python runtime state: unknown“错误,那就是mac系统的python版本冲突引起的,所以如果自己装了几个版本的ptyhon,那么在一开始的时候,这几个命令一定要运行一下,如果运行时有错误,按错误提示运行就可以。
brew install python@3.8
brew unlink python
brew link --force python@3.8

安装到最后遇到. ~/ros2_foxy/ros2-osx/setup.bash的时候,可能运行会出现 "not found /users/abc/local_setup.bat"
那么你可以试试“. ~/ros2_foxy/ros2-osx/setup.zsh", 也就是看你用的是zsh还是bash。

运行后又会出现:[connext_cmake_module] Warning: The location at which Connext was found when the workspace was built [[/Applications/rti_connext_dds-5.3.1]] does not point to a valid directory, and the NDDSHOME environment variable has not been set. Support for Connext will not be available.

可以不理睬,继续运行ros2 run demo_nodes_cpp talker发送消息, 并运行新窗口的ros2 run demo_nodes_py listener就会出现对应的接受 消息。表示运行成功。就可以下一步操作了。