Rviz crash with exception raised by qt.qpa.screen
It's a really weird problem. When I'm trying to launch my launch file using the terminal embedded in VIsual Studio Code, I got an error called "qt.qpa.screen: QXcbConnection: Could not connect to display Could not connect to any X display." But rviz seems totally OK while using the vanilla terminal.
Part of my launch file is shown below:
<launch>
<node type="rviz" name="rviz" pkg="rviz" args=" $(find detect_core)/rviz/config.rviz" />
<node pkg="detect_core" type="detect_core_node" name="detect_core_node" output="screen"/>
</launch>
When I launch this file in VSCode, it shows the following message while all the other processes works normally:
qt.qpa.screen: QXcbConnection: Could not connect to display Could not connect to any X display. [rviz-4] process has died [pid 2702, exit code 1, cmd /opt/ros/melodic/lib/rviz/rviz /home/hcd/ROS_LiDAR/src/LiDAR/detect_core/rviz/config.rviz __name:=rviz __log:=/home/hcd/.ros/log/053e51c0-f088-11e9-91c8-d0abd582c8c3/rviz-4.log]. log file: /home/hcd/.ros/log/053e51c0-f088-11e9-91c8-d0abd582c8c3/rviz-4*.log
But when I launch rviz directly from terminal, it works perfectly fine.
(base) <font color="#8AE234"><b>hcd@hcd-PC</b></font>:<font color="#729FCF"><b>~</b></font>$ rviz
[ INFO] [1571281807.940736481]: rviz version 1.13.4
[ INFO] [1571281807.940797989]: compiled against Qt version 5.9.5
[ INFO] [1571281807.940823596]: compiled against OGRE version 1.9.0 (Ghadamon)
[ INFO] [1571281807.944071605]: Forcing OpenGl version 0.
[ INFO] [1571281808.422031984]: Stereo is NOT SUPPORTED
[ INFO] [1571281808.422139032]: OpenGl version: 4.6 (GLSL 4.6).
Thank you for your help~~