安装wsl和ubuntu都没问题,
为了后续配置,需要看看自己的wsl是1还是2
使用如下命令
wsl -l -v
在zshrc或bashrc中添加如下代码(我是wsl1)
export DISPLAY=:0 # in WSL 1
# export DISPLAY=$(awk '/nameserver / {print $2; exit}' /etc/resolv.conf 2>/dev/null):0 # in WSL 2
export LIBGL_ALWAYS_INDIRECT=
export LIBGL_ALWASY_SOFTWARE=1
然后
source ~/.zshrc
在windows中下载安装Xming并启动
https://sourceforge.net/projects/xming/
启动windows terminal(按住alt点击顶部的+可以打开第二个terminal)
roscore
rosrun turtlesim turtlesim_node
rosrun turtlesim turtle_teleop_key
实验一下,能够顺利跑起来显示小乌龟即说明成功。
注:
期间启动turtlesim时发生了一个问题:
/opt/ros/noetic/lib/rviz/rviz: error while loading shared libraries: libQt5Core.so.5: cannot open shared object file: No such file or directory
解决办法参照:https://askubuntu.com/questions/1034313/ubuntu-18-4-libqt5core-so-5-cannot-open-shared-object-file-no-such-file-or-dir
whereis libQt5Core.so.5
#把路径复制下来
sudo strip --remove-section=.note.ABI-tag /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
然后问题就解决了,据说是The above command “strips out” a piece of code which is looking in the kernel for something not there, and allows the module to load.(上面的命令“删除”了一段在内核中寻找不存在的东西的代码,并允许加载该模块。)